Posted November 21, 201311 yr comment_72883 Hello, Basically I have made a furnace and it works 99.9% the only thing that does not work and is probably the biggest thing is the read/write from/to NBT methods. I have reviewed countless tutorial and whenever they did it, it seemed to work, but when I do it, it does not work. I looked at the minecraft furnace code in the TileEntityFurnace class and noticed no differences between that code and mine. Please tell me what I have done wrong and hint me towards a solution so that I can actually learn from this. Thank you in advance! /** Reads a tile entity from NBT. */ public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList nbttaglist = nbt.getTagList("CFItems"); this.cfslots = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.tagAt(i); byte b0 = nbttagcompound.getByte("CFSlot"); if (b0 >= 0 && b0 < this.cfslots.length) { this.cfslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } this.cfBurnTime = nbt.getShort("CFBurnTime"); this.cfCookTime = nbt.getShort("CFCookTime"); this.cfCurrentItemBurnTime = getItemBurnTime(this.cfslots[1]); if (nbt.hasKey("CFCustomName")) { this.localizedName = nbt.getString("CFCustomName"); } } /** Writes a tile entity from NBT. */ public void writetoNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("CFBurnTime", (short)this.cfBurnTime); nbt.setShort("CFCookTime", (short)this.cfCookTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.cfslots.length; ++i) { if (this.cfslots[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("CFSlot", (byte)i); this.cfslots[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } nbt.setTag("CFItems", nbttaglist); if (this.isInvNameLocalized()) { nbt.setString("CFCustomName", this.localizedName); } }
November 21, 201311 yr comment_72887 Did you register your tile entity? 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.
November 21, 201311 yr Author comment_72892 Did you register your tile entity? I did that is there anything else that could be the issue?
November 21, 201311 yr comment_72902 Yes several. Use breakpoints located at the begining of the write and read methods. Check that they are called and the values of all the variables of your TE as the write method is called. Is it called at all? If so, does the TE have the correct values at the time? If thats all good, let us know so and also tell us if the read method is called and wether it retrives the correct values or not If it does not read the correct values then you have a syncing issue, look into posts about syncing TEs. If you guys dont get it.. then well ya.. try harder...
November 21, 201311 yr Author comment_72917 Yes several. Use breakpoints located at the begining of the write and read methods. Check that they are called and the values of all the variables of your TE as the write method is called. Is it called at all? If so, does the TE have the correct values at the time? If thats all good, let us know so and also tell us if the read method is called and wether it retrives the correct values or not If it does not read the correct values then you have a syncing issue, look into posts about syncing TEs. All right thanks I'll try that and get back to you on that. Thanks again for the advice
November 22, 201311 yr Author comment_72992 Yes several. Use breakpoints located at the begining of the write and read methods. Check that they are called and the values of all the variables of your TE as the write method is called. Is it called at all? If so, does the TE have the correct values at the time? If thats all good, let us know so and also tell us if the read method is called and wether it retrives the correct values or not If it does not read the correct values then you have a syncing issue, look into posts about syncing TEs. It seems as though the read/write methods do not get called at all. I added break points at the beginning of each method and nothing happened, I even put system out print lines in multiple parts of each method and returned no results. I am now going to look at syncing and see what that entails. But I do appreciate the help, thank you.
November 22, 201311 yr comment_72999 If the read and write methods are not being called then it's not a syncing problem (atm ). The problem is either: 1. Your TileEntity is not getting registered. Check that the line registrating it is indeed getting called (printline should suffice) 2. Does your write and read methods match the ones in the TileEntity class you are overriding? You can check this manually but the simplest way is to just add @Override to the line above the method. Then eclipse will check that it's correctly overriding a method or mark it as an error If you guys dont get it.. then well ya.. try harder...
November 22, 201311 yr Author comment_73064 If the read and write methods are not being called then it's not a syncing problem (atm ). The problem is either: 1. Your TileEntity is not getting registered. Check that the line registrating it is indeed getting called (printline should suffice) 2. Does your write and read methods match the ones in the TileEntity class you are overriding? You can check this manually but the simplest way is to just add @Override to the line above the method. Then eclipse will check that it's correctly overriding a method or mark it as an error Oh alright gotcha . By the way thank you for all your advice it is EXTREMELY helpful. PS. DUDE you will not believe what my problem was. right after I put in the @Override on the writeToNBT method I got an error, that error occurred because I name the method writetoNBT not writeToNBT, so when I called the super.writeToNBT it didn't recognize the method writetoNBT so I changed it and now it works perfectly. Thanks again!
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.