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

Making Entity Data Persistent through logs 1.17x


spiritfilled
 Share

Recommended Posts

Whenever i logout and back-in in the game, the data resets to its define state

(how can i save the entity data to be persistent)

 

the code words, data is used flawlessly, but just doesn't save through game exit

public class TyBoss extends Monster{

	public static final EntityDataAccessor<Boolean> STILL_HOSTILE = SynchedEntityData.defineId(TyBoss.class, EntityDataSerializers.BOOLEAN);
	private static final EntityDataAccessor<Byte> SCOUNT_TAG = SynchedEntityData.defineId(TyBoss.class, EntityDataSerializers.BYTE);
(...)
      
	protected void defineSynchedData() {
	    super.defineSynchedData();
	    this.entityData.define(SCOUNT_TAG, (byte) 0);
	    this.entityData.define(STILL_HOSTILE, true);
	}
(...)
      
	public void startSeenByPlayer(ServerPlayer p_01_) {
	    super.startSeenByPlayer(p_01_);
	    if (this.entityData.get(STILL_HOSTILE)) { this.bossEvent.addPlayer(p_01_);}
	}

	public void stopSeenByPlayer(ServerPlayer p_01_) {
	    super.stopSeenByPlayer(p_01_);
	    this.bossEvent.removePlayer(p_01_);    
	}
(...)
}

 

Edited by spiritfilled
Link to comment
Share on other sites

  • spiritfilled changed the title to Making Entity Data Persistent through logs 1.17x

SynchedEntityData is for syncing things to the client, not for saving to disk. If you don't need the data on the client, use a plain field, not SynchedEntityData.

For saving to disk you need to override addAdditionalSaveData and readAdditionalSaveData.

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.