Hello guys,
I'm trying to make a mod that adds auto miner block. To do this I created a block and a block entity that save the itemStack when a user right click on the block (the auo miner will generate item depending on the itemStack set), and I need to save this itemstack in order to keep it even after a game restart.
If I understood correctly, we need to use the "saveAdditional" function in order to save some tag on the entity. The thing is, how do you trigger this function everytime a user right click on the corresponding block entity ? In my case this function is sometimes called when we right click on the block entity and sometimes it takes many seconds before the function is called.
Just below it's the saveAdditional fuction I'm using in a class that extends BlockEntity.
@Override
protected void saveAdditional(CompoundTag pTag) {
if (target != null) {
System.out.println("target not null");
pTag.put("target", target.serializeNBT());
}
super.saveAdditional(pTag);
}
Thanks