i try to put dataquery to block with place event smth like
BlockSnapshot block = event.getTransactions().get(0).getFinal();
block.toContainer().set(DataQuery.of(“UnsafeData”,“reg”), “reg”);
event.getTransactions().get(0).setCustom(block);
and check on break event but seem not work
anyone have good way to detect ?
: i try to do auto regenerate block but i don’t know how to point block that need to regenerate
BlockSnapshot
is immutable i.e. you cannot change an existing one.
You need to create a new BlockSnapshot
with the new data, like this:
BlockSnapshot block = event.getTransactions().get(0).getFinal();
BlockSnapshot newBlock = block.withContainer(block.toContainer().set(DataQuery.of("UnsafeData","reg"), "reg"));
event.getTransactions().get(0).setCustom(newBlock);
Thx for help
but now i try to figure out how to detect with breakblock event
i try
player.sendMessage(Text.of(event.getTransactions().get(0).getOriginal().toContainer().get(DataQuery.of(“UnsafeData”, “reg”)).get().toString()));
but seem not work
ERROR log : [11:06:20] [Server thread/WARN] [Sponge]: /* Owning Mod/Plugin: penumbracore - Pastebin.com
**i try to check present but it not present how can i get dataquery from block
What block type are you trying this with?
Custom data containers only work on tile entities due to tile entities having NBT, whereas non-TE blocks don’t store any NBT.
Thx for reply that what i thought cus NBT seem store in tile thing
i will find different way