Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Atijaf
 Share

Recommended Posts

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

 

 

 

Adding the power source

https://gyazo.com/aca0d76b0da029cde249ea9bfb6530f0

 

outcome - Current Energy is moving down at 200 per tick and placed into block on right

https://gyazo.com/b507219e38d945e31c87e633e5c6991c

 

When Block is removed from right, Current Energy is no longer being removed

https://gyazo.com/295bcd0fbb7a112fb36e9a87206da346

 

After saving and quiting - (The problem occurs)

https://gyazo.com/763bfcc8b670eb25c9113b47fca69663

 

The TileEntity still has the data inside.  I've debugged and saw that, but one of the tile Entities, (The one displaying the screen) is the incorrect one... I think, but am unsure as to how to obtain the correct one.

 

Shows it still works, but doesn't update "Current Energy" or "Energy Rate"

https://gyazo.com/1ae5981a764581560e31845a156f439e

 

 

 

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

- 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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

- 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

Link to comment
Share on other sites

@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?

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.