Jump to content

(Solved) Tile NBT sharing between all Tiles of same type & Tile not loading NBT on world load


Tyhone

Recommended Posts

Hey all, I've got 2 issues that I think are most likely related.

First is that my Tileenttity "Jar" is sharing its NBT with other instances of "Jar", seemingly at random, whenever one sends a new packet.

Next is that the NBT is being found at world load, but then not being applied, until the "Jar" is being updated. See below
Loading world

Spoiler

//WORLD LOADED

[19:29:55] [Server thread/INFO] [arcanacraft]: Compoud did not save (empty)     //Placed Jar in world
[19:29:55] [main/INFO] [arcanacraft]: Compoud failed to load     //readFromNBT
[19:30:03] [Server thread/INFO] [arcanacraft]: Added tinkture: rebus, Current Amount: 8     //Added tinkture to Jar, marking dirty and notifying world of block update.
[19:30:03] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:8,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}     //writeToNBT
[19:30:03] [main/INFO] [arcanacraft]: Compoud load: {amount:8,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}        //readFromNBT
[19:30:16] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:8,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}    //writeToNBT
[19:30:22] [Server thread/INFO] [arcanacraft]: Added tinkture: rebus, Current Amount: 16     //Added another tinkture to Jar, to show amount goes up
[19:30:22] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:16,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}     //writeToNBT
[19:30:22] [main/INFO] [arcanacraft]: Compoud load: {amount:16,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}    //readFromNBT
[19:30:34] [Server thread/INFO]: Saving and pausing game...
[19:30:34] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[19:30:34] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:16,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}    //writeToNBT
[19:30:34] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[19:30:34] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[19:30:39] [Server thread/INFO]: Stopping server

 

And reloading world

Spoiler

//WORLD LAODING
[19:36:37] [Server thread/INFO] [arcanacraft]: Compoud load: {amount:16,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}     //readFromNBT
[19:36:37] [Server thread/INFO]: Player296[local:E:78af2ee6] logged in with entity id 5131 at (267.6679107901526, 71.0, 278.9398614026179)
[19:36:37] [Server thread/INFO]: Player296 joined the game
[19:36:38] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:0,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"empty"}     //writeToNBT
[19:36:38] [Server thread/INFO]: Saving and pausing game...
[19:36:38] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[19:36:38] [main/INFO] [arcanacraft]: Compoud load: {amount:0,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"empty"}         //readFromNBT
[19:36:38] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:0,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"empty"}     //writeToNBT
[19:36:38] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[19:36:38] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[19:36:42] [main/INFO] [arcanacraft]: TinktureType: empty, Amount: 0    //Checking current amount stored
[19:36:42] [Server thread/INFO] [arcanacraft]: TinktureType: empty, Amount: 0    //Checking current amount stored
[19:36:44] [Server thread/INFO] [arcanacraft]: Added tinkture: rebus, Current Amount: 24    //Added tinkture to Jar, marking dirty and notifying world of block update.
[19:36:44] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:24,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}     //writeToNBT
[19:36:44] [main/INFO] [arcanacraft]: Compoud load: {amount:24,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}     //readFromNBT
[19:37:22] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:24,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}    //writeToNBT
[19:38:07] [Server thread/INFO] [arcanacraft]: Compoud save: {amount:24,x:269,y:71,z:278,id:"minecraft:arcanacraft.jar",type:"rebus"}    //wri

 

 

Here is the code for my TileEntityJar

//ModTileEntityBase extends TilEntity
	@Override
    public NBTTagCompound getUpdateTag() {
        return writeToNBT(new NBTTagCompound());
    }

    @Nullable
    @Override
    public SPacketUpdateTileEntity getUpdatePacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        this.writeToNBT(nbtTag);
        return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
    }

    @Override
    public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
        this.readFromNBT(packet.getNbtCompound());
    }

	//This is called whenever the contained TinktureStacks amount/type is changed
	public void markForClean(){
		markDirty();
		if (world != null){
			IBlockState state = getWorld().getBlockState(getPos());
			getWorld().notifyBlockUpdate(getPos(), state, state, 3);
		}
    }

//TileEntityJar
	@Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        
    	
        if(compound.hasKey(TAG_TYPE)){
        	Arcanacraft.logger.info("Compoud load: " + compound);
        	TinktureType type = TinktureStackUtil.getTinktureTypeFromString(compound.getString(TAG_TYPE));
        	int amount = compound.getInteger(TAG_AMOUNT);
            tinktureStack = new TinktureStack(type, amount);
        }
        else{
        	Arcanacraft.logger.info("Compoud failed to load");
        }
        
    }

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);
        
        if(!tinktureStack.isEmpty()){
        	compound.setString(TAG_TYPE, tinktureStack.getTinktureType().getTinktureName());
        	compound.setInteger(TAG_AMOUNT, tinktureStack.getAmount());

        	Arcanacraft.logger.info("Compoud save: " + compound);
        }
        else{
        	Arcanacraft.logger.info("Compoud did not save (empty)");
        }
        return compound;
    }

 

Any help would be greatly appreciated, I dont have any of these issues with other TileEntities that contain ItemStacks and whatnot

Edit: Github link for Jar
https://github.com/The-PurpleOrange/Arcanacraft/blob/master/src/main/java/com/tyhone/arcanacraft/common/tileentity/TileEntityJar.java

Edit Edit: Oh my god. I was comparing two strings with "==" instead of ".equals", I thought I was going insane, that's what 14 straight hours of coding does to you, second time ive made that mistake, eclipse should flag it as an error honestly.
Can someone lock this please?

Edited by Tyhone
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Is there a way to copy effect for example Darkness or Nausea? Like an absolute copy
    • Tapi sebelum itu kalian sudah tahu belum kenapa kami menyarankan DUTA89 kepada kalian semua? Karena DUTA89 bisa dikatakan sebagai salah satu tempat atau wadah untuk menghasilkan uang dengan cepat dan mudah hanya dengan modal receh dan rebahan saja
    • It is painful to invest and lose, binary options are more of a gamble if you ask me, especially when your broker decides to invest on your behalf. That's how I lost all my funds thanks to my broker who claimed to have invested on my behalf and lost a sum of 115,000 USD. This made me realize that people should really be careful out there especially when funds are involved, this is not to say recovery is not possible even though there are several frauds out there who claim they can recover your funds. This will only depend if you have done your research on the recovery agent that you would want to use to help you. After what happened to me, I wouldn’t like the same situation to happen to me, losing money. I did a thorough check on CYBERSPACE HACK PRO after coming across numerous testimonies on him helping lots of people to recover their funds/BTC. It took me a whole week to decide if I would be doing the right thing by hiring him. I emailed on Cyberspacehackpro(@)rescueteam.com and he responded. Asked him various questions and he really did impress me; he really knew his way on recovery. After providing all the necessary details, he did his incredible work and in 4 days time, my funds were recovered. Whether someone outside there feels like whatever I did to recover my funds rather than report it to the police was through unethical means, I wouldn’t care because as far as I am concerned, I don’t care because I was able to retrieve my hard-earned funds taken from me and that’s all, a big thank you to CYBERSPACE HACK PRO Recovery. CONTACT: CYBERSPACE HACK PRO Email: Cyberspacehackpro(@)rescueteam.com
    • Im using exaroton hosting with mods. Im play normally with my friends, and in some point the server freezes, and eventually kicks us for ''time out'', and the server never unfreezes again. when i reload the server, the world doesn't suffer any damage, but the players seem to go back in time. Example: I'm in a cave mining diamonds and I collect them. The server freezes and times out. when I restart the server, the cave diamonds are gone, but they are not in my inventory either. as if the player has gone back in time, but the world has not. Its really annoying for me and my friends. If someone can help me ill be so grateful. It doesn't seem to be any error in the console nor log.
    • Logs: https://pastebin.com/LBZs2U25
  • Topics

×
×
  • Create New...

Important Information

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