mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Check current block state before changing block count.
This commit is contained in:
parent
65bf6261a5
commit
385c8fe342
1 changed files with 8 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue