Jump to content

How to store data into Data entities


ItzPray

Recommended Posts

I am trying to store the player that placed down the block as soon as it gets placed down so whenever a player interacts with the block it will check if that player is the owner or not. Is there anyway to add data to the Block Entity and have it saved in that block to be checked whenever anyone interacts with it?

Link to comment
Share on other sites

44 minutes ago, Luis_ST said:

You can use a Capability, take a look at this FCW page for more infos

I looked at it for a while and I tried to implement it but it cant figure out how to get it to work. Is there anyway you can give me an example of how I can do this with Capabilities? It would be greatly appreciated.

Link to comment
Share on other sites

You only need a capability if you want to do it for other people's block entities.

 

If its your BlockEntity, you can just store the player's UUID in your block entity

You can see how ConduitBlockEntity does this to remember its "destroy target".

For actually changing the data in your block entity at placement see something like: AbstractBannerBlock.setPlacedBy()

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

20 minutes ago, warjort said:

You only need a capability if you want to do it for other people's block entities.

 

If its your BlockEntity, you can just store the player's UUID in your block entity

You can see how ConduitBlockEntity does this to remember its "destroy target".

For actually changing the data in your block entity at placement see something like: AbstractBannerBlock.setPlacedBy()

Yes I am trying to set the data in my BlockEntity. I am trying to store the players UUID in my block Entity on place. Is it just as simple as setting a variable in that block entity to the players uuid or is there more too it? If you could show an example i would love that.

Link to comment
Share on other sites

Quote

 

 Is it just as simple as setting a variable in that block entity to the players uuid

 

Yes.

You also need to load/save it, see the Conduit block. That's why you use the UUID, you can store that in NBT.

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.