The Meaning of Life, the Universe, and Everything.
Join Date:
2/11/2017
Posts:
662
Member Details
I would like to develop an algorithm that can seemingly store an entity and then respawn it at the player's will. The context is that I have a store where one can buy "vehicles" as entities. I want the player to be able to despawn and respawn the vehicle at will using a written book. The entity needs to be unique to each player, as this is on a multiplayer realm.
I thought of storing basic properties of the vehicle inside the NBT of the player, but I cannot edit player NBT data. I thought of storing data for all players inside some shared entity, but I would not knowhow to access the data for any arbitrary player. I thought of storing the NBT inside the book itself, but I'm not sure if one can merge item data with entity data that way. Are there any other ways I could achieve my goal?
Rollback Post to RevisionRollBack
Remember those versions that minecraft pranked us with? Specifically:
Minecraft 2.0
Minecraft 1.VR-Pre1
Snapshot 15w14a
Minecraft 3D
Those are still downloadable! Watch this video for 2.0:
To download the other ones you need to make a folder in the versions folder for minecraft and put the client and JSON file for the versions in there. They all need to be named the same aside from file extensions. Once you do that, you will be able to choose that version when making a new profile with the minecraft launcher.
I would like to develop an algorithm that can seemingly store an entity and then respawn it at the player's will. The context is that I have a store where one can buy "vehicles" as entities. I want the player to be able to despawn and respawn the vehicle at will using a written book. The entity needs to be unique to each player, as this is on a multiplayer realm.
I thought of storing basic properties of the vehicle inside the NBT of the player, but I cannot edit player NBT data. I thought of storing data for all players inside some shared entity, but I would not knowhow to access the data for any arbitrary player. I thought of storing the NBT inside the book itself, but I'm not sure if one can merge item data with entity data that way. Are there any other ways I could achieve my goal?
You can store entity data inside an item but you have to keep in mind that there is a byte limit for the data stored and the chunk the item is in will not save if you pass that limit.
Note: since you can't modify the player data, the item has to be on the ground in order for this to work.
So let's say you made a system where when you drop a book on the ground near that vehicle, the vehicle data is stored inside the book. Here is how I would do it:
/execute as <vehicle_entity> at @s run data modify entity @e[type=item,limit=1,sort=nearest,nbt={Item:{id:"minecraft:book"},OnGround:1b}] Item.tag.VehicleData set from entity @s
this will create a new tag called "VehicleData" inside of the book's NBT and store all of the vehicle's NBT data inside that tag. To merge the data onto a new vehicle, simply reverse the command like this:
/execute as @e[type=item,nbt={Item:{id:"minecraft:book"},OnGround:1b}] at @s run data modify entity <vehicle_entity> {} merge from entity @s Item.tag.VehicleData
I would also add a name to the book when the data is being stored (with a simple /data merge command) so that you avoid storing data inside of a book which already has data in it.
This is just a simple example but there are obviously more things that could be added to ensure accuracy such as:
-a tag to avoid data being stored in a book which already contains data
-mark the nearest book with a tag so the vehicle knows it's writing data to that book and not any other book in the area
I would like to develop an algorithm that can seemingly store an entity and then respawn it at the player's will. The context is that I have a store where one can buy "vehicles" as entities. I want the player to be able to despawn and respawn the vehicle at will using a written book. The entity needs to be unique to each player, as this is on a multiplayer realm.
I thought of storing basic properties of the vehicle inside the NBT of the player, but I cannot edit player NBT data. I thought of storing data for all players inside some shared entity, but I would not knowhow to access the data for any arbitrary player. I thought of storing the NBT inside the book itself, but I'm not sure if one can merge item data with entity data that way. Are there any other ways I could achieve my goal?
Remember those versions that minecraft pranked us with? Specifically:
Those are still downloadable! Watch this video for 2.0:
https://www.youtube.com/watch?v=PQdu9LKAdIU
To download the other ones you need to make a folder in the versions folder for minecraft and put the client and JSON file for the versions in there. They all need to be named the same aside from file extensions. Once you do that, you will be able to choose that version when making a new profile with the minecraft launcher.
15w14a is on this link:
http://minecraft.gamepedia.com/15w14a
1.RV-Pre1 is here:
http://minecraft.gamepedia.com/1.RV-Pre1
Minecraft 3D is here:
https://minecraft.gamepedia.com/Java_Edition_3D_Shareware_v1.34
You can store entity data inside an item but you have to keep in mind that there is a byte limit for the data stored and the chunk the item is in will not save if you pass that limit.
Note: since you can't modify the player data, the item has to be on the ground in order for this to work.
So let's say you made a system where when you drop a book on the ground near that vehicle, the vehicle data is stored inside the book. Here is how I would do it:
this will create a new tag called "VehicleData" inside of the book's NBT and store all of the vehicle's NBT data inside that tag. To merge the data onto a new vehicle, simply reverse the command like this:
I would also add a name to the book when the data is being stored (with a simple /data merge command) so that you avoid storing data inside of a book which already has data in it.
This is just a simple example but there are obviously more things that could be added to ensure accuracy such as:
-a tag to avoid data being stored in a book which already contains data
-mark the nearest book with a tag so the vehicle knows it's writing data to that book and not any other book in the area
here is a video in case this is still not clear:
Command block engineer // Developer // #TeamTrees