mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-28 16:06:28 +01:00
I'm partial to compiler errors
- Update PartialModel events - Flywheel compiles!
This commit is contained in:
parent
d9da952dc2
commit
1e9b0ee85c
1 changed files with 9 additions and 10 deletions
|
@ -8,9 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelEvent;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
|
||||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for loading and accessing json models.
|
* A helper class for loading and accessing json models.
|
||||||
|
@ -18,10 +16,10 @@ import net.minecraftforge.client.model.ForgeModelBakery;
|
||||||
* Creating a PartialModel will make the associated modelLocation automatically load.
|
* Creating a PartialModel will make the associated modelLocation automatically load.
|
||||||
* PartialModels must be initialized in the mod class constructor.
|
* PartialModels must be initialized in the mod class constructor.
|
||||||
* <br>
|
* <br>
|
||||||
* Once {@link ModelBakeEvent} finishes, all PartialModels (with valid modelLocations)
|
* Once {@link ModelEvent.RegisterAdditional} finishes, all PartialModels (with valid modelLocations)
|
||||||
* will have their bakedModel fields populated.
|
* will have their bakedModel fields populated.
|
||||||
* <br>
|
* <br>
|
||||||
* Attempting to create a PartialModel after {@link ModelRegistryEvent} will cause an error.
|
* Attempting to create a PartialModel after {@link ModelEvent.RegisterAdditional} will cause an error.
|
||||||
*/
|
*/
|
||||||
public class PartialModel {
|
public class PartialModel {
|
||||||
private static final List<PartialModel> ALL = new ArrayList<>();
|
private static final List<PartialModel> ALL = new ArrayList<>();
|
||||||
|
@ -37,15 +35,16 @@ public class PartialModel {
|
||||||
ALL.add(this);
|
ALL.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onModelRegistry(ModelRegistryEvent event) {
|
public static void onModelRegistry(ModelEvent.RegisterAdditional event) {
|
||||||
for (PartialModel partial : ALL)
|
for (PartialModel partial : ALL) {
|
||||||
ForgeModelBakery.addSpecialModel(partial.getLocation());
|
event.register(partial.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
tooLate = true;
|
tooLate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onModelBake(ModelBakeEvent event) {
|
public static void onModelBake(ModelEvent.BakingCompleted event) {
|
||||||
Map<ResourceLocation, BakedModel> modelRegistry = event.getModelRegistry();
|
var modelRegistry = event.getModels();
|
||||||
for (PartialModel partial : ALL)
|
for (PartialModel partial : ALL)
|
||||||
partial.set(modelRegistry.get(partial.getLocation()));
|
partial.set(modelRegistry.get(partial.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue