3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-09-29 16:00:04 +02:00

Fix NBT not applying when BlockState stays the same

Dieser Commit ist enthalten in:
Moulberry 2024-02-09 23:12:54 +08:00
Ursprung f4b22cfa02
Commit 288b9f87c3

Datei anzeigen

@ -218,12 +218,13 @@ public class SetBlockBufferPacketListener {
if (checker != null && !checker.allowed(x, y, z)) continue;
Block block = blockState.getBlock();
BlockState old = section.setBlockState(x, y, z, blockState, true);
if (blockState != old) {
sectionChanged = true;
blockPos.set(bx, by, bz);
Block block = blockState.getBlock();
motionBlocking.update(x, by, z, blockState);
motionBlockingNoLeaves.update(x, by, z, blockState);
oceanFloor.update(x, by, z, blockState);
@ -237,7 +238,21 @@ public class SetBlockBufferPacketListener {
}
}
// Update Light
sectionLightChanged |= LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState);
// Update Poi
Optional<Holder<PoiType>> newPoi = containerMaybeHasPoi ? PoiTypes.forState(blockState) : Optional.empty();
Optional<Holder<PoiType>> oldPoi = sectionMaybeHasPoi ? PoiTypes.forState(old) : Optional.empty();
if (!Objects.equals(oldPoi, newPoi)) {
if (oldPoi.isPresent()) world.getPoiManager().remove(blockPos);
if (newPoi.isPresent()) world.getPoiManager().add(blockPos, newPoi.get());
}
}
if (blockState.hasBlockEntity()) {
blockPos.set(bx, by, bz);
BlockEntity blockEntity = chunk.getBlockEntity(blockPos, LevelChunk.EntityCreationType.CHECK);
if (blockEntity == null) {
@ -274,18 +289,6 @@ public class SetBlockBufferPacketListener {
} else if (old.hasBlockEntity()) {
chunk.removeBlockEntity(blockPos);
}
// Update Light
sectionLightChanged |= LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState);
// Update Poi
Optional<Holder<PoiType>> newPoi = containerMaybeHasPoi ? PoiTypes.forState(blockState) : Optional.empty();
Optional<Holder<PoiType>> oldPoi = sectionMaybeHasPoi ? PoiTypes.forState(old) : Optional.empty();
if (!Objects.equals(oldPoi, newPoi)) {
if (oldPoi.isPresent()) world.getPoiManager().remove(blockPos);
if (newPoi.isPresent()) world.getPoiManager().add(blockPos, newPoi.get());
}
}
}
}
}