Jump to content

[1.8.8]Tile Entity saving... Kind of?[solved]


Recommended Posts

Posted

After a long while, I have gotten my tile entity to work just the way I want it to...

I just want to add a couple lines of text that display information about what the Tile Entity contains, such as it's current amount of "Energy" and "Energy Rate"

 

Pictures and explanations

 

  Reveal hidden contents

 

 

I Believe the problem begins with the creation of a new TileEntity

When I start up the game, I notice that the method "createNewTileEntity" is called

 

BlockKineticRelocator: -- (When activated, passes TileEntity it obtains from a location.  Somehow, it isn't correct?)

http://pastebin.com/JzpxCrZu

 

GuiKineticRelocator -- (Information here is correct until restart)

http://pastebin.com/XA6AgdrY

 

KineticRelocatorTileEntity

http://pastebin.com/DTdX0yKy

 

As in the last gif, it's obvious a Tile Entity has the data I'm looking for, but I'm unsure how to find it.  Everytime I use the method, "World.getTileEntity(pos)" , it returns a tileEntity but it doesn't have the correct information.  (The data I'm looking for are all 0)

 

While T300kCapsule is being charged, if I debug and set breakpoints in the tile entity that takes care of that, it shows the data correctly.

 

I know this is a lot to take in, but hopefully it's just something silly that's happening...

Thanks a bunch for anyone that helps

Posted

I had this same problem. Simply call the super for #writeToNBT, and #readFromNBT in your TileEntity class.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted
  On 1/19/2016 at 10:31 AM, HappyKiller1O1 said:

I had this same problem. Simply call the super for #writeToNBT, and #readFromNBT in your TileEntity class.

 

Unfortunately, I've already done that.

 

I probably should have included that code.  I've edited my previous post and have added it.

Posted

I believe, from looking at the furnace, you need to use the #getFields() and #setFields() for easy client to server sync. I haven't tried it, but it seems the furnace TileEntity uses it.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted
  On 1/19/2016 at 4:53 PM, diesieben07 said:

- You will need to sync the data that is visible in your GUI in your Container. You can look at e.g. ContainerFurnace for a vanilla example.

- Why on earth are you storing all your data in the Items list? :o You can have more than one top-level entry in your NBT data (like you already do with the custom name).

 

Would it be the method "detectAndSendChanges()"?

I'll try it when I get back home.

Thanks

Posted

That's the one. If it doesn't work, look up how to use the #getFields() in the ISidedInventory.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

@Override
public void detectAndSendChanges() {
	// TODO Auto-generated method stub
	super.detectAndSendChanges();

	//I Understand I need to loop through all of these for each player, just not yet
	ICrafting icrafting = (ICrafting)this.crafters.get(0);

	if(this.tileentitycharge != this.te.getField(0)){
		/**								this, id, the TileEntity variable */
		icrafting.sendProgressBarUpdate(this, 0, this.te.getField(0));
	}

	this.tileentitycharge = this.te.getField(0);
}

 

@Override
public int getField(int id) {
	switch(id){
		case(0): return this.TileEntityCharge;
	}
    return 0;
}

@Override
public void setField(int id, int value) {
	switch(id){
	case(0): this.TileEntityCharge = value; break;
	}
}

@Override
public int getFieldCount() {
    return 1;
}

 

did this, but it's still not updating the gui screen variables after restarting the game.  Have I missed something?

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.

Announcements



×
×
  • Create New...

Important Information

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