Begin cleaning up model registration

This commit is contained in:
Nick 2016-02-09 19:07:56 -08:00
parent f613c00970
commit 325cda2f71
16 changed files with 200 additions and 51 deletions

View file

@ -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);

View file

@ -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());

View file

@ -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);

View file

@ -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
{
/**

View file

@ -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);
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "builtin/generated",
"transform": "forge:default-item"
},
"variants": {
"type": {
"altarmaker": {
"textures": {
"layer0": "bloodmagic:items/AltarMaker"
}
}
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "builtin/generated",
"transform": "forge:default-item"
},
"variants": {
"type": {
"arcaneashes": {
"textures": {
"layer0": "bloodmagic:items/ArcaneAshes"
}
}
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "builtin/generated",
"transform": "forge:default-item"
},
"variants": {
"type": {
"monstersoul": {
"textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul"
}
}
}
}
}

View file

@ -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"
}
}
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "builtin/generated",
"transform": "forge:default-item"
},
"variants": {
"type": {
"soulsnare": {
"textures": {
"layer0": "bloodmagic:items/SoulSnare"
}
}
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "builtin/generated",
"transform": "forge:default-item"
},
"variants": {
"type": {
"upgradetome": {
"textures": {
"layer0": "bloodmagic:items/UpgradeTome"
}
}
}
}
}

View file

@ -1,10 +0,0 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SoulGemPetty"
}
}

View file

@ -1,11 +0,0 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SoulGemLesser"
}
}

View file

@ -1,6 +0,0 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SoulGemCommon"
}
}

View file

@ -1,7 +0,0 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SoulGemGreater"
}
}

View file

@ -1,7 +0,0 @@
{
"parent":"bloodmagic:item/ItemModelBase",
"textures": {
"layer0":"bloodmagic:items/SoulGemGrand"
}
}