Jump to content

[solved] [1.7.10] review how I'm storing data please, tile entity!


LimpLungs

Recommended Posts

So here is the section that is giving me problems:

 

http://pastebin.com/LGj2xqBV

 

Basically, it prints the correct integer for entry in the update entity, but when I go to write it, it prints incorrect. I commented  //this.sendInventory();  and  //this.entry = -1;    but it still doesn't work. The value printed in updateEntity still prints correct, but when I go to write it, it prints wrong before write.

 

I did the same thing that I did to store values in 2 other tile entities, and I can't seem to find anything different going on here. Am I overlooking something, or is this just being obnoxiously picky and not working for some reason?

Link to comment
Share on other sites

Everything in "public void updateEntity()" should be in "if (!worldObj.isRemote)" .    Might be wrong on your "this.updateBlock();" since its code isn't shown. 

 

The redundant "this.markDirty();" is excessive.

 

how do you think this will work?  you are never saving your items NBT to the main nbt.

 

 

 

                NBTTagList items = new NBTTagList();

 

                for (int i = 0; i < getSizeInventory(); i++)

                {

                        ItemStack stack = this.getStackInSlot(i);

 

                        if (stack != null)

                        {

                                NBTTagCompound item = new NBTTagCompound();

                                item.setByte("Slot", (byte) i);

                                stack.writeToNBT(item);

                                items.appendTag(item);

                        }

                }

[\spoiler]

 

What is "entry".  Its not defined anywhere so hard to tell what it is or what you meant to do.  If at this point, it doens't print the right value, then 'entry' is the wrong variables in your code.

 

 

System.out.println(entry);

                compound.setInteger("intEntry", this.entry);

[\spoiler]

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Oh wow, I feel like an idiot now. Yes, the problem was both the not running the code in (!worldObj.isRemote) like my other two tile entities, and I completely forgot the compound.setTag("Items", items);

 

As for the this.entry, I have it being declared as -1 to start, and then whenever an itemstack enters the block, it changes it to the side it entered from. Basically, I'm making a transport block similar to pipes and it needs to lock behind it when it goes through so it doesn't head backwards. It all is working now thank you so much for proofreading that!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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