-
Posts
27 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
Here, a diamond.
Islandil's Achievements

Tree Puncher (2/8)
0
Reputation
-
Islandil changed their profile photo
-
Ok. My new ItemRenderRegister public class ItemRenderRegister { public static void preInit() { ResourceLocation[] LOC = new ResourceLocation[LENGTH]; for (int i = 0; i < LOC.length; i++) { LOC[i] = new ResourceLocation(ITEM.getRegistryName().toString() + "_" + ITEM.getVar(i)); } ModelBakery.registerItemVariants(ITEM, LOC); ModelLoader.setCustomMeshDefinition(ITEM, new MESH()); } } I get null model for my icons. Using a breakpoint inside my getModelLocation I see the correct models being called and I checked the files names. So my problem is : why do I have no model for my icon in my inventory even if the right model is returned by getModelLocation ?
-
Client Proxy public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); ItemRenderRegister.preInit(); } ... } New ItemRenderRegister preInit public static void preInit() { register(ITEM); ResourceLocation[] LOC = new ResourceLocation[LENGTH]; for (int i = 0; i < LOC.length; i++) { LOC[i] = new ResourceLocation(ITEM.getRegistryName().toString() + "_" + ITEM.getVar(i)); } ModelBakery.registerItemVariants(ITEM, LOC); ModelLoader.setCustomMeshDefinition(ITEM, new MESH()); } Same result. All my item have the default texture. No call inside getModelLocation
-
ItemMeshDefinition implementation public class MESH implements ItemMeshDefinition { @Override public ModelResourceLocation getModelLocation(ItemStack itemStack) { if (itemStack != null && itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TAG)) { return new ModelResourceLocation(ITEM.getRegistryName().toString() + "_" + ITEM.getVar(itemStack.getTagCompound().getString(TAG))); } return new ModelResourceLocation(ITEM.getRegistryName().toString()); } } ItemRenderRegister public class ItemRenderRegister { public static void preInit() { ResourceLocation[] LOC = new ResourceLocation[LENGTH]; for (int i = 0; i < LOC.length; i++) { LOC[i] = new ResourceLocation(ITEM.getRegistryName().toString() + "_" + ITEM.getVar(i)); } ModelBakery.registerItemVariants(ITEM, LOC); ModelLoader.setCustomMeshDefinition(ITEM, new MESH()); register(ITEM); } public static void init() { } private static void register(Item item) { register(item, 0, item.getRegistryName().toString()); } private static void register(Item item, int metadata, String file) { ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(file)); } } I declare some subtypes in my ITEM class with NBT used to define textures. With this code, all my ITEM have the default texture from this location : ITEM.getRegistryName().toString() Also I put breakpoints in : getModelLocation It is never called. If I move register(ITEM); from preInit to init then getModelLocation is called and the resources location are the correct ones but ITEM textures are now all null. I don't have any error in my stack trace.
-
Did this implementation (otherwise I was getting a out of bounds exception) @Nullable @Override public ItemStack decrStackSize(int index, int amount) { ItemStack stack; if (inventory[getLinkedIndex(index)].stackSize <= amount) { stack = inventory[getLinkedIndex(index)]; inventory[getLinkedIndex(index)] = null; } else { stack = inventory[getLinkedIndex(index)].splitStack(amount); if (inventory[getLinkedIndex(index)].stackSize == 0) { inventory[getLinkedIndex(index)] = null; } } return stack; } And it works. Thanks a lot !
-
Changed the getLinkedIndex to return the index parameter. Now isIndexInRange throw IndexOutOfBoundsException. Because the index given is 36 and 37 and is out side 0-1. private boolean isIndexInRange(int index) { index = getLinkedIndex(index); if (index >= 0 && index < getSizeInventory()) { return true; } else { throw new IndexOutOfBoundsException("Access index " + index + " is outside inventory index range, max " + getSizeInventory()); } } private int getLinkedIndex(int index) { return index; } It seems that the Container send the slot index and not the inventory index. Is there a problem in my Container ?