Posted March 27, 20178 yr Just a heads up: english is not my native language, I'm new to Java therefore to Minecraft modding too and I'm following as base the EE3 and MinecraftByExample Codes as well as McJty Wiki (http://wiki.mcjty.eu/modding/index.php/Main_Page); OBS.: McJty's Code it's actually ported to 1.10.2 and I use it to understand the How's to make a TileEntity with GUI and a Inventory. Right now I have two errors, at least that it´s all think I have. NUMBER 1: I've been struggling with localization. Basically it was all fine until I tried to upgrade my ItemBase.class (it's package "com.mavigno.modtest.common.items.base") so I would be able to add ItemVariants too my Mod, now nothing seems to be localized any more; NUMBER 2: In the past couple weeks I've been trying to make a TIleEntity that can hold Items and have a GUI, like a Chest. I got everything set and ready, but the TileEntity won't save it's content on a world close. Container related classes are in this package "com.mavigno.modtest.client.gui.container.base", "com.mavigno.modtest.client.gui.GuiBasicInventory" is the class responsable for drawing the GUI, everything related to how I'm handling TileEntities it's ih this package "com.mavigno.modtest.tileentity", GuiHandler "com.mavigno.modtest.handler.GuiHandler". IDE: IntellijIDEA 2017.1; Forge Version: 1.11-13.19.1.2189; Minecraft Version: 1.11; Java: 1.8; GitHub Access to the Code: https://github.com/Mavigno42/ModTest; Anything out of common please point out, this Mod is attempt of trying to learn how to actually do it!
March 27, 20178 yr 1) https://github.com/Mavigno42/ModTest/tree/master/src/main/resources/assets/modtest/lang You need to rename that file as en_us.lang as all resources must be in lower case. 2) Part a: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L15 You don't need implements ICapabilityProvider, TileEntity already implements that interface. Part b: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L17 Pretty sure you can't create the ItemHandler like this, as the SIZE value is coming from the constructor, but at the time that this field is initialized, the constructor has not yet been called. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 27, 20178 yr Author 11 hours ago, Draco18s said: 1) https://github.com/Mavigno42/ModTest/tree/master/src/main/resources/assets/modtest/lang You need to rename that file as en_us.lang as all resources must be in lower case. 2) Part a: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L15 You don't need implements ICapabilityProvider, TileEntity already implements that interface. Part b: https://github.com/Mavigno42/ModTest/blob/master/src/main/java/com/mavigno/modtest/tileentity/base/TileEntityBasicInventory.java#L17 Pretty sure you can't create the ItemHandler like this, as the SIZE value is coming from the constructor, but at the time that this field is initialized, the constructor has not yet been called. 1) I renamed the Lang file to en_us.lang, but it didn't change anything. 2) Changed some things, still doesn't work: public class TileEntityBasicInventory extends TileEntityBase { protected NonNullList<ItemStack> tileEntityContents; protected StackHandler stackHandler; public TileEntityBasicInventory(String name, short numberOfSlots) { super(name, numberOfSlots); tileEntityContents = NonNullList.<ItemStack>func_191197_a(numberOfSlots, ItemStack.field_190927_a); stackHandler = new StackHandler(this, numberOfSlots); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); ItemStackHelper.func_191283_b(compound, this.tileEntityContents); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); ItemStackHelper.func_191282_a(compound, this.tileEntityContents); return compound; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing enumFacing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; return super.hasCapability(capability, enumFacing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing enumFacing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) stackHandler; return super.getCapability(capability, enumFacing); } } StackHandler class public class StackHandler extends ItemStackHandler { private final TileEntityBase tileEntityBase; public StackHandler(TileEntityBase tileEntityBase, int size) { super(size); this.tileEntityBase = tileEntityBase; } @Override protected void onContentsChanged(int slot) { tileEntityBase.markDirty(); } } The Log - (from World Start to World Close) MinecraftLog.txt I didn't Push the changes to the GitHub access by the way.
March 27, 20178 yr There's a lot I can only infer, namely all those SRG function names. I assume you're calling the right methods, but I have no way to tell. Are you on the latest MCP mapping? Edited March 27, 20178 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 27, 20178 yr Update them. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 27, 20178 yr My lang file assignments omit my mod name from the middle . Try deleting "modtest:" from your test case to see if it works. Example: tile.ruby_block.name=Block of Ruby Also, my last lang filename (for mc 1.10.2) capitalized the US (imitating vanilla). Is that changing in 1.11+? I suppose I'll find out in a hurry when I do my next upgrade cycle. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
March 27, 20178 yr 4 minutes ago, jeffryfisher said: Also, my last lang filename (for mc 1.10.2) capitalized the US (imitating vanilla). Is that changing in 1.11+? I suppose I'll find out in a hurry when I do my next upgrade cycle. Yes. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 27, 20178 yr Author 2 hours ago, Draco18s said: Update them. I did the update, but it still the same
March 27, 20178 yr Author 30 minutes ago, jeffryfisher said: My lang file assignments omit my mod name from the middle . Try deleting "modtest:" from your test case to see if it works. Example: tile.ruby_block.name=Block of Ruby Tried that, it didn't work, and if did it would be very confusing since I'm handling the getUnlocalizedName. @Override public String getUnlocalizedName(ItemStack itemStack) { if (hasSubtypes && itemStack.getMetadata() < VARIANTS.length) return String.format("item.%s:%s", Reference.MOD_ID, VARIANTS[itemStack.getMetadata()]); else return String.format("item.%s:%s", Reference.MOD_ID, ITEM_BASE_NAME); }
March 29, 20178 yr Author On 27/03/2017 at 0:34 PM, Draco18s said: Update them. Did the MCP update and updated my code to suit the change public class TileEntityBasicInventory extends TileEntityBase { protected NonNullList<ItemStack> tileEntityContents; protected StackHandler stackHandler; public TileEntityBasicInventory(String name, short numberOfSlots) { super(name, numberOfSlots); tileEntityContents = NonNullList.<ItemStack>withSize(numberOfSlots, ItemStack.EMPTY); stackHandler = new StackHandler(this, numberOfSlots); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); ItemStackHelper.loadAllItems(compound, this.tileEntityContents); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); ItemStackHelper.saveAllItems(compound, this.tileEntityContents); return compound; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing enumFacing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; return super.hasCapability(capability, enumFacing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing enumFacing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) stackHandler; return super.getCapability(capability, enumFacing); } } StackHandler public class StackHandler extends ItemStackHandler { private final TileEntityBase tileEntityBase; public StackHandler(TileEntityBase tileEntityBase, int size) { super(size); this.tileEntityBase = tileEntityBase; } @Override protected void onContentsChanged(int slot) { tileEntityBase.markDirty(); } } Nothing changed I actually had to redo my setup and create a new Repo and run setupDecompWorkspace... But the Gradle Idea setup wasn't perfect, I had to manually reassign the Source and Resources Directories.
March 29, 20178 yr Author 2 minutes ago, diesieben07 said: The updated version still works fine for me. It must be something wrong at my end, later I will figure it out. But can you check if the TileEntity actually works?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.