From 9f77b3458fe788cac9434b41572adcfc831a552f Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sun, 31 Jan 2016 19:24:39 +0100 Subject: [PATCH] use ModelLoader and move all model stuff to preInit --- .../java/storagecraft/proxy/ClientProxy.java | 116 +++++++++--------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/src/main/java/storagecraft/proxy/ClientProxy.java b/src/main/java/storagecraft/proxy/ClientProxy.java index 7e57085c3..4a2ebf384 100644 --- a/src/main/java/storagecraft/proxy/ClientProxy.java +++ b/src/main/java/storagecraft/proxy/ClientProxy.java @@ -1,8 +1,6 @@ package storagecraft.proxy; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemMeshDefinition; -import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; @@ -30,6 +28,12 @@ public class ClientProxy extends CommonProxy { super.preInit(e); + // TESRs + ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, TileCable.class); + + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, new ModelResourceLocation("storagecraft:cable", "inventory")); + + // Item Variants ModelBakery.registerItemVariants(StorageCraftItems.STORAGE_CELL, new ResourceLocation("storagecraft:1k_storage_cell"), new ResourceLocation("storagecraft:4k_storage_cell"), @@ -65,9 +69,58 @@ public class ClientProxy extends CommonProxy new ResourceLocation("storagecraft:wireless_grid_disconnected") ); - ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, TileCable.class); + // Items + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_1K, new ModelResourceLocation("storagecraft:1k_storage_cell", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_4K, new ModelResourceLocation("storagecraft:4k_storage_cell", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_16K, new ModelResourceLocation("storagecraft:16k_storage_cell", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_64K, new ModelResourceLocation("storagecraft:64k_storage_cell", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_CREATIVE, new ModelResourceLocation("storagecraft:creative_storage_cell", "inventory")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, new ModelResourceLocation("storagecraft:cable", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_1K, new ModelResourceLocation("storagecraft:1k_storage_part", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_4K, new ModelResourceLocation("storagecraft:4k_storage_part", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_16K, new ModelResourceLocation("storagecraft:16k_storage_part", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_64K, new ModelResourceLocation("storagecraft:64k_storage_part", "inventory")); + + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_BASIC, new ModelResourceLocation("storagecraft:basic_printed_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_IMPROVED, new ModelResourceLocation("storagecraft:improved_printed_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_ADVANCED, new ModelResourceLocation("storagecraft:advanced_printed_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_BASIC, new ModelResourceLocation("storagecraft:basic_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_IMPROVED, new ModelResourceLocation("storagecraft:improved_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_ADVANCED, new ModelResourceLocation("storagecraft:advanced_processor", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_SILICON, new ModelResourceLocation("storagecraft:printed_silicon", "inventory")); + + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.SILICON, 0, new ModelResourceLocation("storagecraft:silicon", "inventory")); + + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.QUARTZ_ENRICHED_IRON, 0, new ModelResourceLocation("storagecraft:quartz_enriched_iron", "inventory")); + + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.CORE, ItemCore.TYPE_CONSTRUCTION, new ModelResourceLocation("storagecraft:construction_core", "inventory")); + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.CORE, ItemCore.TYPE_DESTRUCTION, new ModelResourceLocation("storagecraft:destruction_core", "inventory")); + + ModelLoader.setCustomModelResourceLocation(StorageCraftItems.WIRELESS_GRID_PLATE, 0, new ModelResourceLocation("storagecraft:wireless_grid_plate", "inventory")); + ModelLoader.setCustomMeshDefinition(StorageCraftItems.WIRELESS_GRID, new ItemMeshDefinition() + { + @Override + public ModelResourceLocation getModelLocation(ItemStack stack) + { + return new ModelResourceLocation("storagecraft:wireless_grid_" + (ItemWirelessGrid.isValid(stack) ? "connected" : "disconnected"), "inventory"); + } + }); + + // Blocks + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.NORMAL.getId(), new ModelResourceLocation("storagecraft:grid", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.CRAFTING.getId(), new ModelResourceLocation("storagecraft:grid", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.MACHINE_CASING), 0, new ModelResourceLocation("storagecraft:machine_casing", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.EXPORTER), 0, new ModelResourceLocation("storagecraft:exporter", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.IMPORTER), 0, new ModelResourceLocation("storagecraft:importer", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.EXTERNAL_STORAGE), 0, new ModelResourceLocation("storagecraft:external_storage", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.DRIVE), 0, new ModelResourceLocation("storagecraft:drive", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CONTROLLER), EnumControllerType.NORMAL.getId(), new ModelResourceLocation("storagecraft:controller", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CONTROLLER), EnumControllerType.CREATIVE.getId(), new ModelResourceLocation("storagecraft:controller", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CONSTRUCTOR), 0, new ModelResourceLocation("storagecraft:constructor", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.DESTRUCTOR), 0, new ModelResourceLocation("storagecraft:destructor", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.SOLDERER), 0, new ModelResourceLocation("storagecraft:solderer", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("storagecraft:wireless_transmitter", "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.DETECTOR), 0, new ModelResourceLocation("storagecraft:detector", "inventory")); ModelLoader.setCustomStateMapper(StorageCraftBlocks.STORAGE, (new StateMap.Builder()) .ignore(StorageCraftBlocks.STORAGE.DIRECTION) @@ -88,60 +141,5 @@ public class ClientProxy extends CommonProxy super.init(e); ClientRegistry.bindTileEntitySpecialRenderer(TileCable.class, BlockCableRenderer.INSTANCE); - - ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); - - // Items - mesher.register(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_1K, new ModelResourceLocation("storagecraft:1k_storage_cell", "inventory")); - mesher.register(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_4K, new ModelResourceLocation("storagecraft:4k_storage_cell", "inventory")); - mesher.register(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_16K, new ModelResourceLocation("storagecraft:16k_storage_cell", "inventory")); - mesher.register(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_64K, new ModelResourceLocation("storagecraft:64k_storage_cell", "inventory")); - mesher.register(StorageCraftItems.STORAGE_CELL, ItemStorageCell.TYPE_CREATIVE, new ModelResourceLocation("storagecraft:creative_storage_cell", "inventory")); - - mesher.register(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_1K, new ModelResourceLocation("storagecraft:1k_storage_part", "inventory")); - mesher.register(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_4K, new ModelResourceLocation("storagecraft:4k_storage_part", "inventory")); - mesher.register(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_16K, new ModelResourceLocation("storagecraft:16k_storage_part", "inventory")); - mesher.register(StorageCraftItems.STORAGE_PART, ItemStoragePart.TYPE_64K, new ModelResourceLocation("storagecraft:64k_storage_part", "inventory")); - - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_BASIC, new ModelResourceLocation("storagecraft:basic_printed_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_IMPROVED, new ModelResourceLocation("storagecraft:improved_printed_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_ADVANCED, new ModelResourceLocation("storagecraft:advanced_printed_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_BASIC, new ModelResourceLocation("storagecraft:basic_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_IMPROVED, new ModelResourceLocation("storagecraft:improved_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_ADVANCED, new ModelResourceLocation("storagecraft:advanced_processor", "inventory")); - mesher.register(StorageCraftItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_SILICON, new ModelResourceLocation("storagecraft:printed_silicon", "inventory")); - - mesher.register(StorageCraftItems.SILICON, 0, new ModelResourceLocation("storagecraft:silicon", "inventory")); - - mesher.register(StorageCraftItems.QUARTZ_ENRICHED_IRON, 0, new ModelResourceLocation("storagecraft:quartz_enriched_iron", "inventory")); - - mesher.register(StorageCraftItems.CORE, ItemCore.TYPE_CONSTRUCTION, new ModelResourceLocation("storagecraft:construction_core", "inventory")); - mesher.register(StorageCraftItems.CORE, ItemCore.TYPE_DESTRUCTION, new ModelResourceLocation("storagecraft:destruction_core", "inventory")); - - mesher.register(StorageCraftItems.WIRELESS_GRID_PLATE, 0, new ModelResourceLocation("storagecraft:wireless_grid_plate", "inventory")); - mesher.register(StorageCraftItems.WIRELESS_GRID, new ItemMeshDefinition() - { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) - { - return new ModelResourceLocation("storagecraft:wireless_grid_" + (ItemWirelessGrid.isValid(stack) ? "connected" : "disconnected"), "inventory"); - } - }); - - // Blocks - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.NORMAL.getId(), new ModelResourceLocation("storagecraft:grid", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.CRAFTING.getId(), new ModelResourceLocation("storagecraft:grid", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.MACHINE_CASING), 0, new ModelResourceLocation("storagecraft:machine_casing", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.EXPORTER), 0, new ModelResourceLocation("storagecraft:exporter", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.IMPORTER), 0, new ModelResourceLocation("storagecraft:importer", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.EXTERNAL_STORAGE), 0, new ModelResourceLocation("storagecraft:external_storage", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.DRIVE), 0, new ModelResourceLocation("storagecraft:drive", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.CONTROLLER), EnumControllerType.NORMAL.getId(), new ModelResourceLocation("storagecraft:controller", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.CONTROLLER), EnumControllerType.CREATIVE.getId(), new ModelResourceLocation("storagecraft:controller", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.CONSTRUCTOR), 0, new ModelResourceLocation("storagecraft:constructor", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.DESTRUCTOR), 0, new ModelResourceLocation("storagecraft:destructor", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.SOLDERER), 0, new ModelResourceLocation("storagecraft:solderer", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("storagecraft:wireless_transmitter", "inventory")); - mesher.register(Item.getItemFromBlock(StorageCraftBlocks.DETECTOR), 0, new ModelResourceLocation("storagecraft:detector", "inventory")); } }