From a0d3c5669bcf9078b0ff350720382852dd15da06 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 30 Jul 2017 15:44:21 +0200 Subject: [PATCH] Added CTM integration for Grids --- .../refinedstorage/proxy/ProxyClient.java | 59 +++--------- .../render/CustomModelLoaderDefault.java | 33 +++++++ .../refinedstorage/blockstates/grid_glow.json | 89 ++++++++++++++++++ .../models/block/cube_glow.json | 63 +++++++++++++ .../grid_crafting_front_connected_glow.png | Bin 0 -> 555 bytes ...d_crafting_front_connected_glow.png.mcmeta | 9 ++ .../grid_fluid_front_connected_glow.png | Bin 0 -> 513 bytes ...grid_fluid_front_connected_glow.png.mcmeta | 9 ++ .../blocks/grid_front_connected_glow.png | Bin 0 -> 553 bytes .../grid_front_connected_glow.png.mcmeta | 9 ++ .../grid_pattern_front_connected_glow.png | Bin 0 -> 551 bytes ...id_pattern_front_connected_glow.png.mcmeta | 9 ++ 12 files changed, 234 insertions(+), 46 deletions(-) create mode 100644 src/main/java/com/raoulvdberge/refinedstorage/render/CustomModelLoaderDefault.java create mode 100644 src/main/resources/assets/refinedstorage/blockstates/grid_glow.json create mode 100644 src/main/resources/assets/refinedstorage/models/block/cube_glow.json create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_crafting_front_connected_glow.png create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_crafting_front_connected_glow.png.mcmeta create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_fluid_front_connected_glow.png create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_fluid_front_connected_glow.png.mcmeta create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_front_connected_glow.png create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_front_connected_glow.png.mcmeta create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_pattern_front_connected_glow.png create mode 100644 src/main/resources/assets/refinedstorage/textures/blocks/grid_pattern_front_connected_glow.png.mcmeta diff --git a/src/main/java/com/raoulvdberge/refinedstorage/proxy/ProxyClient.java b/src/main/java/com/raoulvdberge/refinedstorage/proxy/ProxyClient.java index c5c65d4d5..47f4e75ce 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/proxy/ProxyClient.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/proxy/ProxyClient.java @@ -32,7 +32,6 @@ import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.resources.IResourceManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; @@ -41,8 +40,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ICustomModelLoader; -import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry; @@ -60,7 +57,6 @@ public class ProxyClient extends ProxyCommon { public void preInit(FMLPreInitializationEvent e) { super.preInit(e); - // TESRs ClientRegistry.bindTileEntitySpecialRenderer(TileStorageMonitor.class, new TileEntitySpecialRendererStorageMonitor()); } @@ -83,13 +79,12 @@ public class ProxyClient extends ProxyCommon { } } - return 0xFFFFFF; // Full white, no need to apply color + return 0xFFFFFF; }, RSItems.PATTERN); } @SubscribeEvent public void registerModels(ModelRegistryEvent e) { - // Item Variants ModelBakery.registerItemVariants(RSItems.STORAGE_DISK, new ResourceLocation("refinedstorage:1k_storage_disk"), new ResourceLocation("refinedstorage:4k_storage_disk"), @@ -145,7 +140,6 @@ public class ProxyClient extends ProxyCommon { new ResourceLocation("refinedstorage:fortune_upgrade") ); - // Items ModelLoader.setCustomModelResourceLocation(RSItems.STORAGE_DISK, ItemStorageDisk.TYPE_1K, new ModelResourceLocation("refinedstorage:1k_storage_disk", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.STORAGE_DISK, ItemStorageDisk.TYPE_4K, new ModelResourceLocation("refinedstorage:4k_storage_disk", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.STORAGE_DISK, ItemStorageDisk.TYPE_16K, new ModelResourceLocation("refinedstorage:16k_storage_disk", "inventory")); @@ -201,12 +195,7 @@ public class ProxyClient extends ProxyCommon { ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_SILK_TOUCH, new ModelResourceLocation("refinedstorage:silk_touch_upgrade", "inventory")); ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_FORTUNE, new ModelResourceLocation("refinedstorage:fortune_upgrade", "inventory")); - // Blocks ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.NORMAL.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=normal")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.CRAFTING.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=crafting")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.PATTERN.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=pattern")); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.FLUID.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=fluid")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.MACHINE_CASING), 0, new ModelResourceLocation("refinedstorage:machine_casing", "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.DISK_DRIVE), 0, new ModelResourceLocation("refinedstorage:disk_drive", "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.EXPORTER), 0, new ModelResourceLocation("refinedstorage:exporter", "inventory")); @@ -241,54 +230,32 @@ public class ProxyClient extends ProxyCommon { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.QUARTZ_ENRICHED_IRON), 0, new ModelResourceLocation("refinedstorage:quartz_enriched_iron_block", "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.STORAGE_MONITOR), 0, new ModelResourceLocation("refinedstorage:storage_monitor", "connected=false,direction=north")); - // Disk Drive - ModelLoaderRegistry.registerLoader(new ICustomModelLoader() { - @Override - public boolean accepts(ResourceLocation modelLocation) { - return modelLocation.getResourceDomain().equals(RS.ID) && modelLocation.getResourcePath().equals("disk_drive"); - } + ModelLoaderRegistry.registerLoader(new CustomModelLoaderDefault(new ResourceLocation(RS.ID, "disk_drive"), ModelDiskDrive::new)); + ModelLoaderRegistry.registerLoader(new CustomModelLoaderDefault(new ResourceLocation(RS.ID, "disk_manipulator"), ModelDiskManipulator::new)); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.NORMAL.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=normal")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.CRAFTING.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=crafting")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.PATTERN.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=pattern")); + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.GRID), GridType.FLUID.getId(), new ModelResourceLocation("refinedstorage:grid", "connected=false,direction=north,type=fluid")); + ModelLoader.setCustomStateMapper(RSBlocks.GRID, new StateMapperBase() { @Override - public IModel loadModel(ResourceLocation modelLocation) throws Exception { - return new ModelDiskDrive(); - } - - @Override - public void onResourceManagerReload(IResourceManager resourceManager) { + protected ModelResourceLocation getModelResourceLocation(IBlockState state) { + return new ModelResourceLocation("refinedstorage:grid" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "connected=" + state.getValue(BlockGrid.CONNECTED) + ",direction=" + state.getValue(RSBlocks.GRID.getDirection().getProperty()) + ",type=" + state.getValue(BlockGrid.TYPE)); } }); - // Disk Manipulator - ModelLoaderRegistry.registerLoader(new ICustomModelLoader() { - @Override - public boolean accepts(ResourceLocation modelLocation) { - return modelLocation.getResourceDomain().equals(RS.ID) && modelLocation.getResourcePath().equals("disk_manipulator"); - } + ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.CONTROLLER), stack -> { + ControllerEnergyType energyType = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? ControllerEnergyType.ON : TileController.getEnergyType(ItemBlockController.getEnergyStored(stack), ItemBlockController.getEnergyCapacity(stack)); - @Override - public IModel loadModel(ResourceLocation modelLocation) throws Exception { - return new ModelDiskManipulator(); - } - - @Override - public void onResourceManagerReload(IResourceManager resourceManager) { - } + return new ModelResourceLocation("refinedstorage:controller" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "energy_type=" + energyType); }); - - // Controller ModelLoader.setCustomStateMapper(RSBlocks.CONTROLLER, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation("refinedstorage:controller" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "energy_type=" + state.getValue(BlockController.ENERGY_TYPE)); } }); - ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.CONTROLLER), stack -> { - ControllerEnergyType energyType = stack.getItemDamage() == ControllerType.CREATIVE.getId() ? ControllerEnergyType.ON : TileController.getEnergyType(ItemBlockController.getEnergyStored(stack), ItemBlockController.getEnergyCapacity(stack)); - return new ModelResourceLocation("refinedstorage:controller" + (Loader.isModLoaded("ctm") ? "_glow" : ""), "energy_type=" + energyType); - }); - - // Portable Grid ModelLoader.setCustomStateMapper(RSBlocks.PORTABLE_GRID, new StateMap.Builder().ignore(BlockPortableGrid.TYPE).build()); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(RSBlocks.PORTABLE_GRID), stack -> { PortableGrid portableGrid = new PortableGrid(null, stack); diff --git a/src/main/java/com/raoulvdberge/refinedstorage/render/CustomModelLoaderDefault.java b/src/main/java/com/raoulvdberge/refinedstorage/render/CustomModelLoaderDefault.java new file mode 100644 index 000000000..d5e431158 --- /dev/null +++ b/src/main/java/com/raoulvdberge/refinedstorage/render/CustomModelLoaderDefault.java @@ -0,0 +1,33 @@ +package com.raoulvdberge.refinedstorage.render; + +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ICustomModelLoader; +import net.minecraftforge.client.model.IModel; + +import java.util.function.Supplier; + +public class CustomModelLoaderDefault implements ICustomModelLoader { + private ResourceLocation modelLocation; + private Supplier model; + + public CustomModelLoaderDefault(ResourceLocation modelLocation, Supplier model) { + this.modelLocation = modelLocation; + this.model = model; + } + + @Override + public boolean accepts(ResourceLocation modelLocation) { + return this.modelLocation.equals(modelLocation); + } + + @Override + public IModel loadModel(ResourceLocation modelLocation) throws Exception { + return model.get(); + } + + @Override + public void onResourceManagerReload(IResourceManager resourceManager) { + // NO OP + } +} diff --git a/src/main/resources/assets/refinedstorage/blockstates/grid_glow.json b/src/main/resources/assets/refinedstorage/blockstates/grid_glow.json new file mode 100644 index 000000000..ccbc4f477 --- /dev/null +++ b/src/main/resources/assets/refinedstorage/blockstates/grid_glow.json @@ -0,0 +1,89 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "refinedstorage:cube_glow", + "textures": { + "particle": "refinedstorage:blocks/side", + "north": "refinedstorage:blocks/grid_disconnected", + "east": "refinedstorage:blocks/grid_left", + "south": "refinedstorage:blocks/grid_back", + "west": "refinedstorage:blocks/grid_right", + "up": "refinedstorage:blocks/grid_top", + "down": "refinedstorage:blocks/bottom", + "glow": "refinedstorage:blocks/none" + } + }, + "variants": { + "connected": { + "true": { + "textures": { + "north_normal": "refinedstorage:blocks/grid_front_connected", + "north_normal_glow": "refinedstorage:blocks/grid_front_connected_glow", + "north_crafting": "refinedstorage:blocks/grid_crafting_front_connected", + "north_crafting_glow": "refinedstorage:blocks/grid_crafting_front_connected_glow", + "north_pattern": "refinedstorage:blocks/grid_pattern_front_connected", + "north_pattern_glow": "refinedstorage:blocks/grid_pattern_front_connected_glow", + "north_fluid": "refinedstorage:blocks/grid_fluid_front_connected", + "north_fluid_glow": "refinedstorage:blocks/grid_fluid_front_connected_glow" + } + }, + "false": { + "textures": { + "north_normal": "refinedstorage:blocks/grid_front", + "north_normal_glow": "refinedstorage:blocks/none", + "north_crafting": "refinedstorage:blocks/grid_crafting_front", + "north_crafting_glow": "refinedstorage:blocks/none", + "north_pattern": "refinedstorage:blocks/grid_pattern_front", + "north_pattern_glow": "refinedstorage:blocks/none", + "north_fluid": "refinedstorage:blocks/grid_fluid_front", + "north_fluid_glow": "refinedstorage:blocks/none" + } + } + }, + "type": { + "normal": { + "textures": { + "north": "#north_normal", + "glow": "#north_normal_glow" + } + }, + "crafting": { + "textures": { + "north": "#north_crafting", + "glow": "#north_crafting_glow" + } + }, + "pattern": { + "textures": { + "north": "#north_pattern", + "glow": "#north_pattern_glow" + } + }, + "fluid": { + "textures": { + "north": "#north_fluid", + "glow": "#north_fluid_glow", + "east": "refinedstorage:blocks/grid_fluid_left", + "south": "refinedstorage:blocks/grid_fluid_back", + "west": "refinedstorage:blocks/grid_fluid_right", + "up": "refinedstorage:blocks/grid_fluid_top", + "down": "refinedstorage:blocks/bottom" + } + } + }, + "direction": { + "north": { + "y": 0 + }, + "east": { + "y": 90 + }, + "south": { + "y": 180 + }, + "west": { + "y": 270 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/models/block/cube_glow.json b/src/main/resources/assets/refinedstorage/models/block/cube_glow.json new file mode 100644 index 000000000..0cd891c83 --- /dev/null +++ b/src/main/resources/assets/refinedstorage/models/block/cube_glow.json @@ -0,0 +1,63 @@ +{ + "parent": "block/cube", + "ambientocclusion": false, + "elements": [ + { + "from": [ + 0, + 0, + 0 + ], + "to": [ + 16, + 16, + 16 + ], + "faces": { + "down": { + "texture": "#down", + "cullface": "down" + }, + "up": { + "texture": "#up", + "cullface": "up" + }, + "north": { + "texture": "#north", + "cullface": "north" + }, + "south": { + "texture": "#south", + "cullface": "south" + }, + "west": { + "texture": "#west", + "cullface": "west" + }, + "east": { + "texture": "#east", + "cullface": "east" + } + } + }, + { + "from": [ + 0, + 0, + 0 + ], + "to": [ + 16, + 16, + 16 + ], + "shade": false, + "faces": { + "north": { + "texture": "#glow", + "cullface": "north" + } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/refinedstorage/textures/blocks/grid_crafting_front_connected_glow.png b/src/main/resources/assets/refinedstorage/textures/blocks/grid_crafting_front_connected_glow.png new file mode 100644 index 0000000000000000000000000000000000000000..1531ca42e940913a78393ee9c2353484f9448365 GIT binary patch literal 555 zcmV+`0@VG9P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E-^MlX|MGF00EmxL_t(IPoUBp5~7ppB4 z9Xcp3qMh1WP&?EiB8cGZ=n!;tbkj-kR&8T7=m}C2Bqm0yMh6i=6mL1XoLf9;O-vk~ zeyea!F*^Ks`F=d#!}}Hh&x&Q4Pb|xP^5D_4q2dV34DKlm?Z$C##TW?2>DyH43YokQ zM``jz1ZpGb2&RzC9K%ORcC;)*2O8^%JGypK^zQw^t!HWUUJKMl;0Pw^Jh{PnXfn93 z;oMEqzirU{+oU~^;Zw+<-g7BX8^Om-gI}q8oMDYX{0>J*$17&1=sSEW^Jr1F>2xeI~X2;MH8@p|owhEPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!v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