Change item model loading priority to fix model conflicts (#4898)

This commit is contained in:
Ben Staddon authored and LexManos committed 2018-06-27 11:08:38 -07:00
1 parent 1db28d072a
commit a749861cb2
5 files changed
+79 -7

No files matched your search

@@ -301,22 +301,20 @@ public final class ModelLoader extends ModelBakery
Exception exception = null;
try
{
model = ModelLoaderRegistry.getModel(file);
model = ModelLoaderRegistry.getModel(memory);
}
catch(Exception normalException)
catch (Exception blockstateException)
{
// try blockstate json if the item model is missing
FMLLog.log.debug("Item json isn't found for '{}', trying to load the variant from the blockstate json", memory);
try
{
model = ModelLoaderRegistry.getModel(memory);
model = ModelLoaderRegistry.getModel(file);
}
catch (Exception blockstateException)
catch (Exception normalException)
{
exception = new ItemLoadingException("Could not load item model either from the normal location " + file + " or from the blockstate", normalException, blockstateException);
}
}
if(exception != null)
if (exception != null)
{
storeException(memory, exception);
model = ModelLoaderRegistry.getMissingModel(memory, exception);
@@ -0,0 +1,63 @@
package net.minecraftforge.debug.client.model;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
@Mod.EventBusSubscriber
@Mod(modid = ItemModelConflictTest.MODID, name = "Test mod for model conflicts", version = "1.0", acceptableRemoteVersions = "*")
public class ItemModelConflictTest
{
public static final String MODID = "item_model_conflict_test";
@GameRegistry.ObjectHolder(MODID + ":item")
public static final Item TEST_ITEM = null;
@GameRegistry.ObjectHolder(MODID + ":test")
public static final Block TEST_BLOCK = null;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(
new Block(Material.ROCK)
.setRegistryName(MODID, "test")
.setUnlocalizedName(MODID + ".test")
.setCreativeTab(CreativeTabs.BUILDING_BLOCKS)
);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().registerAll(
new Item()
.setRegistryName(MODID, "item")
.setUnlocalizedName(MODID + ".item")
.setCreativeTab(CreativeTabs.MISC),
new ItemBlock(TEST_BLOCK)
.setRegistryName(TEST_BLOCK.getRegistryName())
);
}
@Mod.EventBusSubscriber(modid = MODID, value = Side.CLIENT)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TEST_BLOCK), 0, new ModelResourceLocation(TEST_BLOCK.getRegistryName(), "normal"));
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID + ":test", "inventory"));
}
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "item_model_conflict_test:test" }
}
}
@@ -0,0 +1,3 @@
{
"parent": "minecraft:block/cobblestone"
}
@@ -0,0 +1,3 @@
{
"parent": "minecraft:item/torch"
}