From 325cda2f715d56f9d87465ff393dcbfe4bfdf1cd Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 9 Feb 2016 19:07:56 -0800 Subject: [PATCH] Begin cleaning up model registration --- .../bloodmagic/proxy/ClientProxy.java | 9 ++++ .../bloodmagic/proxy/CommonProxy.java | 7 +++ .../bloodmagic/registry/ModItems.java | 22 ++++---- .../util/helper/InventoryRenderHelper.java | 3 ++ .../util/helper/InventoryRenderHelperV2.java | 53 +++++++++++++++++++ .../blockstates/item/ItemAltarMaker.json | 16 ++++++ .../blockstates/item/ItemArcaneAshes.json | 16 ++++++ .../blockstates/item/ItemMonsterSoul.json | 16 ++++++ .../blockstates/item/ItemSoulGem.json | 36 +++++++++++++ .../blockstates/item/ItemSoulSnare.json | 16 ++++++ .../blockstates/item/ItemUpgradeTome.json | 16 ++++++ .../bloodmagic/models/item/ItemSoulGem0.json | 10 ---- .../bloodmagic/models/item/ItemSoulGem1.json | 11 ---- .../bloodmagic/models/item/ItemSoulGem2.json | 6 --- .../bloodmagic/models/item/ItemSoulGem3.json | 7 --- .../bloodmagic/models/item/ItemSoulGem4.json | 7 --- 16 files changed, 200 insertions(+), 51 deletions(-) create mode 100644 src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelperV2.java create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemAltarMaker.json create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemArcaneAshes.json create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulGem.json create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulSnare.json create mode 100644 src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTome.json delete mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemSoulGem0.json delete mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemSoulGem1.json delete mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemSoulGem2.json delete mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemSoulGem3.json delete mode 100644 src/main/resources/assets/bloodmagic/models/item/ItemSoulGem4.json diff --git a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java index a9d8eb03..ec9c542f 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.proxy; +import WayofTime.bloodmagic.util.helper.InventoryRenderHelperV2; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.common.MinecraftForge; @@ -28,6 +29,7 @@ import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; public class ClientProxy extends CommonProxy { private InventoryRenderHelper renderHelper; + private InventoryRenderHelperV2 renderHelperV2; @Override public InventoryRenderHelper getRenderHelper() @@ -35,6 +37,12 @@ public class ClientProxy extends CommonProxy return renderHelper; } + @Override + public InventoryRenderHelperV2 getRenderHelperV2() + { + return renderHelperV2; + } + @Override public void preInit() { @@ -42,6 +50,7 @@ public class ClientProxy extends CommonProxy MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); renderHelper = new InventoryRenderHelper(Constants.Mod.DOMAIN); + renderHelperV2 = new InventoryRenderHelperV2(Constants.Mod.DOMAIN); OBJLoader.instance.addDomain(Constants.Mod.MODID); diff --git a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java index d32d5303..90c05ddf 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.proxy; +import WayofTime.bloodmagic.util.helper.InventoryRenderHelperV2; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import WayofTime.bloodmagic.util.handler.EventHandler; @@ -7,11 +8,17 @@ import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; public class CommonProxy { + @Deprecated public InventoryRenderHelper getRenderHelper() { return null; } + public InventoryRenderHelperV2 getRenderHelperV2() + { + return null; + } + public void preInit() { MinecraftForge.EVENT_BUS.register(new EventHandler()); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java index 95f69d44..d37b269c 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.registry; +import WayofTime.bloodmagic.util.helper.InventoryRenderHelperV2; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.EnumHelper; @@ -228,6 +229,7 @@ public class ModItems public static void initRenders() { InventoryRenderHelper renderHelper = BloodMagic.proxy.getRenderHelper(); + InventoryRenderHelperV2 renderHelperV2 = BloodMagic.proxy.getRenderHelperV2(); renderHelper.itemRenderAll(bloodOrb); OrbRegistry.registerOrbTexture(orbWeak, new ResourceLocation(Constants.Mod.DOMAIN + "ItemBloodOrbWeak")); @@ -325,17 +327,17 @@ public class ModItems renderHelper.itemRender(sentientArmourLegs, "ItemSentientArmour2"); renderHelper.itemRender(sentientArmourBoots, "ItemSentientArmour3"); - renderHelper.itemRender(altarMaker); - renderHelper.itemRender(upgradeTome); + renderHelperV2.registerRender(altarMaker, "altarMaker"); + renderHelperV2.registerRender(upgradeTome, "upgradeTome"); - renderHelper.itemRender(arcaneAshes); - renderHelper.itemRender(monsterSoul, 0); - renderHelper.itemRender(soulGem, 0); - renderHelper.itemRender(soulGem, 1); - renderHelper.itemRender(soulGem, 2); - renderHelper.itemRender(soulGem, 3); - renderHelper.itemRender(soulGem, 4); - renderHelper.itemRender(soulSnare); + renderHelperV2.registerRender(arcaneAshes, "arcaneAshes"); + renderHelperV2.registerRender(monsterSoul, "monsterSoul"); + renderHelperV2.registerRender(soulGem, 0, "petty"); + renderHelperV2.registerRender(soulGem, 1, "lesser"); + renderHelperV2.registerRender(soulGem, 2, "common"); + renderHelperV2.registerRender(soulGem, 3, "greater"); + renderHelperV2.registerRender(soulGem, 4, "grand"); + renderHelperV2.registerRender(soulSnare, "soulSnare"); renderHelper.customItemRender(sentientSword, 0); renderHelper.customItemRender(sentientSword, 1); diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java index 02e7f4c7..fe6f23cd 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java @@ -24,7 +24,10 @@ import net.minecraftforge.client.model.ModelLoader; * * If you pass a Block through here that uses the default ItemBlock, you * should specify a custom name. + * + * @deprecated in favor of {@link InventoryRenderHelperV2} */ +@Deprecated public class InventoryRenderHelper { /** diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelperV2.java b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelperV2.java new file mode 100644 index 00000000..e03293d4 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelperV2.java @@ -0,0 +1,53 @@ +package WayofTime.bloodmagic.util.helper; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.ItemMeshDefinition; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ModelLoader; + +public class InventoryRenderHelperV2 { + + private final String domain; + + public InventoryRenderHelperV2(String domain) { + this.domain = domain.endsWith(":") ? domain.replace(":", "") : domain; + } + + public void registerMesher(Item item, ItemMeshDefinition meshDefinition) { + ModelLoader.setCustomMeshDefinition(item, meshDefinition); + } + + public void registerRender(Item item, int meta, String name, String variant) { + ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(domain, "item/" + name), "type=" + variant)); + } + + public void registerRender(Item item, int meta, String variant) { + registerRender(item, meta, item.getRegistryName().split(":")[1], variant); + } + + public void registerRender(Item item, String name, String variant) { + registerRender(item, 0, name, variant); + } + + public void registerRender(Item item, String variant) { + registerRender(item, item.getRegistryName().split(":")[1], variant); + } + + public void registerRender(Block block, int meta, String name, String variant) { + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(domain, name), variant)); + } + + public void registerRender(Block block, int meta, String variant) { + registerRender(block, meta, block.getRegistryName().split(":")[1], variant); + } + + public void registerRender(Block block, String name, String variant) { + registerRender(block, 0, name, variant); + } + + public void registerRender(Block block, String variant) { + registerRender(block, block.getRegistryName().split(":")[1], variant); + } +} diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemAltarMaker.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemAltarMaker.json new file mode 100644 index 00000000..d9853286 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemAltarMaker.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "altarmaker": { + "textures": { + "layer0": "bloodmagic:items/AltarMaker" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemArcaneAshes.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemArcaneAshes.json new file mode 100644 index 00000000..df9edd3c --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemArcaneAshes.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "arcaneashes": { + "textures": { + "layer0": "bloodmagic:items/ArcaneAshes" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json new file mode 100644 index 00000000..d9d3497b --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "monstersoul": { + "textures": { + "layer0": "bloodmagic:items/BaseMonsterSoul" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulGem.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulGem.json new file mode 100644 index 00000000..e06aea91 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulGem.json @@ -0,0 +1,36 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "petty": { + "textures": { + "layer0": "bloodmagic:items/SoulGemPetty" + } + }, + "lesser": { + "textures": { + "layer0": "bloodmagic:items/SoulGemLesser" + } + }, + "common": { + "textures": { + "layer0": "bloodmagic:items/SoulGemCommon" + } + }, + "greater": { + "textures": { + "layer0": "bloodmagic:items/SoulGemGreater" + } + }, + "grand": { + "textures": { + "layer0": "bloodmagic:items/SoulGemGrand" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulSnare.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulSnare.json new file mode 100644 index 00000000..e643b138 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSoulSnare.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "soulsnare": { + "textures": { + "layer0": "bloodmagic:items/SoulSnare" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTome.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTome.json new file mode 100644 index 00000000..1562c045 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemUpgradeTome.json @@ -0,0 +1,16 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "builtin/generated", + "transform": "forge:default-item" + }, + "variants": { + "type": { + "upgradetome": { + "textures": { + "layer0": "bloodmagic:items/UpgradeTome" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem0.json b/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem0.json deleted file mode 100644 index 3014c7e2..00000000 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem0.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "parent":"bloodmagic:item/ItemModelBase", - "textures": { - "layer0":"bloodmagic:items/SoulGemPetty" - } -} - - - - diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem1.json b/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem1.json deleted file mode 100644 index e73193d2..00000000 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem1.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "parent":"bloodmagic:item/ItemModelBase", - "textures": { - "layer0":"bloodmagic:items/SoulGemLesser" - } -} - - - - - diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem2.json b/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem2.json deleted file mode 100644 index aaad761b..00000000 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent":"bloodmagic:item/ItemModelBase", - "textures": { - "layer0":"bloodmagic:items/SoulGemCommon" - } -} diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem3.json b/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem3.json deleted file mode 100644 index 3df1111e..00000000 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem3.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "parent":"bloodmagic:item/ItemModelBase", - "textures": { - "layer0":"bloodmagic:items/SoulGemGreater" - } -} - diff --git a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem4.json b/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem4.json deleted file mode 100644 index cf0bd8ff..00000000 --- a/src/main/resources/assets/bloodmagic/models/item/ItemSoulGem4.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "parent":"bloodmagic:item/ItemModelBase", - "textures": { - "layer0":"bloodmagic:items/SoulGemGrand" - } -} -