diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-03 01:24:24 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-03 01:24:24 +0100 |
commit | e2677d6ee5c3f74d5f547ca48bf6641f047a2a1e (patch) | |
tree | fecc0322e48a399df7697da11adfb022d5641a6c /src/main/java/moe/nea/firmament/mixins/custommodels/ReferenceCustomModelsPatch.java | |
parent | 646843ba3b960ac48f9866b3640438d3cc1dafc4 (diff) | |
download | Firmament-e2677d6ee5c3f74d5f547ca48bf6641f047a2a1e.tar.gz Firmament-e2677d6ee5c3f74d5f547ca48bf6641f047a2a1e.tar.bz2 Firmament-e2677d6ee5c3f74d5f547ca48bf6641f047a2a1e.zip |
1.21.3 WIP
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)))); + + } +} |