I dont know, is it working or not, because I do not know what (or how) I need write in config to test it?(
When you get the item back, you should be able to use advanced tool tips to see the amount of nbt tags.
You can also chuck it on the ground and type /entitydata @e[type=item,c=1] {}
Thatâll work, but thatâs moderately annoying as well.
Oh, I am was using config wrongly, as alwaysâŚ
Thank you!
One more question, how I can add NBT to entity?
Entity#setRawData(DataView)
I tried it, but it is not working, like ItemStack::setRawData
not working too,
(Only item = ItemStack.builder().fromContainer(container).build()
).
I suspect youâre right.
Well, you can use EntityUniverse
(i.e. World
)#createEntity(DataContainer)
to create an entity from the result of toContainer
.
I tried:
private void createEntity() {
World world = location.getExtent();
location.getExtent().loadChunk(location.getChunkPosition(), true);
Entity entity = world.createEntity(entity_type, location.getPosition());
entity.setCreator(GWMCrates.PLUGIN_UUID);
if (name.isPresent()) {
entity.offer(Keys.DISPLAY_NAME, name.get());
entity.offer(Keys.CUSTOM_NAME_VISIBLE, true);
}
entity.offer(Keys.AI_ENABLED, false);
entity.offer(Keys.HAS_GRAVITY, false);
DataContainer container = entity.toContainer();
LinkedHashMap nbt_map = new LinkedHashMap(nbt);
if (container.get(DataQuery.of("UnsafeData")).isPresent()) {
Map unsafe_data_map = container.getMap(DataQuery.of("UnsafeData")).get();
nbt_map.putAll(unsafe_data_map);
}
entity = world.createEntity(container).get(); //bad line
world.spawnEntity(entity, GWMCrates.getInstance().getDefaultCause());
this.entity = entity;
}
But I got âNo value presentâ exception (at âbad lineâ). Without this line - code works good (but without NBT ofcourse )
Try deleting the UUID field, wherever it is, from the returned DataContainer. It could be erroring because it canât create two entities with the same UUID.
How I can do it (delete UUID field from returned DataContainter)?
Print it so you can see where the field is, and then call DataContainer#remove(DataQuery)
OhhhâŚ
What from it I should remove?
Both UUIDLeast
and UUIDMost
from UnsafeData
OKay, really stupid question⌠But how I can remove them?
I tried this, but I think it not what I needâŚ
container = container.remove(DataQuery.of("UnsafeData", "UUIDLeast"));
container = container.remove(DataQuery.of("UnsafeData", "UUIDMost"));
Well, that should be it. If that doesnât work, Iâm stumped.
Hm, this is so sadly(