diff options
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java b/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java new file mode 100644 index 0000000..14c84ab --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java @@ -0,0 +1,37 @@ +package moe.nea.firmament.mixins.custommodels; + +import moe.nea.firmament.events.BakeExtraModelsEvent; +import net.minecraft.client.render.model.BlockStatesLoader; +import net.minecraft.client.render.model.ItemModel; +import net.minecraft.client.render.model.ReferencedModelsCollector; +import net.minecraft.client.render.model.UnbakedModel; +import net.minecraft.client.util.ModelIdentifier; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Map; + +@Mixin(ReferencedModelsCollector.class) +public abstract class ReferenceCustomModelsPatch { + @Shadow + protected abstract void addTopLevelModel(ModelIdentifier modelId, UnbakedModel model); + + @Shadow + @Final + private Map<Identifier, UnbakedModel> inputs; + + @Inject(method = "addBlockStates", at = @At("RETURN")) + private void addFirmamentReferencedModels( + BlockStatesLoader.BlockStateDefinition definition, CallbackInfo ci + ) { + inputs.keySet().stream().filter(it->it.toString().contains("firm")).forEach(System.out::println); + BakeExtraModelsEvent.Companion.publish(new BakeExtraModelsEvent( + (modelIdentifier, identifier) -> addTopLevelModel(modelIdentifier, new ItemModel(identifier)))); + + } +} |