From fd9a57671457d680991331d9570435c48a0c5800 Mon Sep 17 00:00:00 2001 From: Up Date: Sat, 13 Jan 2024 12:19:10 +0100 Subject: [PATCH] register backpack model layer definitions --- .../neoforge/entrypoints/Client.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/entrypoints/Client.java b/NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/entrypoints/Client.java index 4f3909b..17a4d36 100644 --- a/NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/entrypoints/Client.java +++ b/NeoForge/src/main/java/dev/cammiescorner/camsbackpacks/neoforge/entrypoints/Client.java @@ -4,6 +4,7 @@ import dev.cammiescorner.camsbackpacks.CamsBackpacks; import dev.cammiescorner.camsbackpacks.block.BackpackBlock; import dev.cammiescorner.camsbackpacks.client.CamsBackpacksClient; +import dev.cammiescorner.camsbackpacks.client.models.BackpackModel; import dev.cammiescorner.camsbackpacks.config.BackpacksConfig; import dev.cammiescorner.camsbackpacks.init.ModBlocks; import dev.cammiescorner.camsbackpacks.item.BackpackItem; @@ -14,16 +15,16 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.ConfigScreenHandler; +import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.ForgeRegistries; @OnlyIn(Dist.CLIENT) -@Mod.EventBusSubscriber(modid = CamsBackpacks.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.FORGE) +@Mod.EventBusSubscriber(modid = CamsBackpacks.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public class Client { public static void init() { @@ -34,14 +35,18 @@ public static void init() { (minecraft, parent) -> new ConfigScreen(parent, null, CamsBackpacks.CONFIGURATOR.getConfig(BackpacksConfig.class)) ) ); - - FMLJavaModLoadingContext.get().getModEventBus().addListener(Client::clientSetup); } - private static void clientSetup(FMLClientSetupEvent event) { + @SubscribeEvent + public static void clientSetup(FMLClientSetupEvent event) { event.enqueueWork(CamsBackpacksClient::init); } + @SubscribeEvent + public static void registerModelDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) { + event.registerLayerDefinition(CamsBackpacksClient.BACKPACK, BackpackModel::getTexturedModelData); + } + @SubscribeEvent public static void registerBlockColors(RegisterColorHandlersEvent.Block event) { event.register((state, world, pos, tintIndex) -> ColorHelper.dyeToDecimal(((BackpackBlock) state.getBlock()).getColour()), ForgeRegistries.BLOCKS.getValues().stream().filter(block -> block instanceof BackpackBlock backpack && (backpack.getColour() != DyeColor.WHITE || backpack == ModBlocks.WHITE_BACKPACK.get())).toArray(Block[]::new));