Check current block state before changing block count.

This commit is contained in:
Steveice10 2019-05-27 17:49:40 -07:00
parent 65bf6261a5
commit 385c8fe342

View file

@ -89,12 +89,6 @@ public class BlockStorage {
}
public void set(int x, int y, int z, BlockState state) {
if (state.getId() != AIR.getId()) {
blockCount++;
} else {
blockCount--;
}
int id = this.bitsPerEntry <= 8 ? this.states.indexOf(state) : stateToRaw(state);
if(id == -1) {
this.states.add(state);
@ -118,6 +112,14 @@ public class BlockStorage {
id = this.bitsPerEntry <= 8 ? this.states.indexOf(state) : stateToRaw(state);
}
int index = index(x, y, z);
int curr = this.storage.get(index)
if(state.getId() != AIR.getId() && curr == AIR.getId()) {
this.blockCount++;
} else if(state.getId() == AIR.getId() && curr != AIR.getId()) {
this.blockCount--;
}
this.storage.set(index(x, y, z), id);
}