Finish implementation of explosion repair

This commit is contained in:
Tara 2023-01-07 05:39:13 -07:00
parent 1126306c2c
commit aadb2a5bf5
7 changed files with 146 additions and 47 deletions

View file

@ -21,12 +21,17 @@ public class StoredBlock
private BlockState state;
private CompoundTag blockEntity;
private int tick;
private int tries;
public void tick(){
this.tick--;
}
public void setTick(int tick){
this.tick=tick;
}
public boolean isExpired() {
return tick <= 0;
@ -95,12 +100,20 @@ public class StoredBlock
tag.put("pos", position.serialize());
tag.put("state", NbtUtils.writeBlockState(state));
tag.putInt("tick", tick);
tag.putInt("tries", tries);
if(blockEntity != null) tag.put("entity", blockEntity);
return tag;
}
public int getTries(){
return tries;
}
public void tickTries(){
tries++;
}
public void deserialize(final CompoundTag tag)
{
@ -115,6 +128,9 @@ public class StoredBlock
final CompoundTag tmp = tag.getCompound("entity");
blockEntity = tmp.isEmpty() ? null : tmp;
tick = tag.getInt("tick");
tries=tag.getInt("tries");
}