Jump to content

Islandil

Members
  • Posts

    27
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Here, a diamond.

Islandil's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Adding "inventory" in getModelLocation solved the issue. return new ModelResourceLocation(ITEM.getRegistryName().toString() + "_" + ITEM.getVar(itemStack.getTagCompound().getString(TAG)), "inventory");
  2. 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 ?
  3. Annnnd I am not ! Because I wrongly placed my breakpoint to test. And the calls are in the correct order. See my edit.
  4. Maybe you are speaking about item register and not about item render register. My item register is in the preInit of my CommonProxy, which is called before my ClientProxy preInit. Is this the correct order ? Edit : other way around.
  5. 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
  6. 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.
  7. Yes ! Many hours were lost on this, I want, sadly, to spend even more and know why.
  8. 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 !
  9. No change. Shift click works, not left click pickup.
  10. 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 ?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.