mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +01:00
Fix block destruction
This commit is contained in:
parent
2b89fa1527
commit
e3942e68d3
@ -190,22 +190,19 @@ public class InstanceContainer extends Instance {
|
|||||||
public boolean breakBlock(@NotNull Player player, @NotNull BlockPosition blockPosition) {
|
public boolean breakBlock(@NotNull Player player, @NotNull BlockPosition blockPosition) {
|
||||||
final Chunk chunk = getChunkAt(blockPosition);
|
final Chunk chunk = getChunkAt(blockPosition);
|
||||||
Check.notNull(chunk, "You cannot break blocks in a null chunk!");
|
Check.notNull(chunk, "You cannot break blocks in a null chunk!");
|
||||||
|
|
||||||
// Cancel if the chunk is read-only
|
// Cancel if the chunk is read-only
|
||||||
if (chunk.isReadOnly()) {
|
if (chunk.isReadOnly()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chunk unloaded, stop here
|
// Chunk unloaded, stop here
|
||||||
if (!ChunkUtils.isLoaded(chunk))
|
if (!ChunkUtils.isLoaded(chunk))
|
||||||
return false;
|
return false;
|
||||||
|
final Block block = getBlock(blockPosition);
|
||||||
|
|
||||||
final int x = blockPosition.getX();
|
final int x = blockPosition.getX();
|
||||||
final int y = blockPosition.getY();
|
final int y = blockPosition.getY();
|
||||||
final int z = blockPosition.getZ();
|
final int z = blockPosition.getZ();
|
||||||
|
|
||||||
final Block block = getBlock(x, y, z);
|
|
||||||
|
|
||||||
// The player probably have a wrong version of this chunk section, send it
|
// The player probably have a wrong version of this chunk section, send it
|
||||||
if (block.isAir()) {
|
if (block.isAir()) {
|
||||||
chunk.sendChunkSectionUpdate(ChunkUtils.getSectionAt(y), player);
|
chunk.sendChunkSectionUpdate(ChunkUtils.getSectionAt(y), player);
|
||||||
@ -218,7 +215,7 @@ public class InstanceContainer extends Instance {
|
|||||||
if (allowed) {
|
if (allowed) {
|
||||||
// Break or change the broken block based on event result
|
// Break or change the broken block based on event result
|
||||||
final Block resultBlock = blockBreakEvent.getResultBlock();
|
final Block resultBlock = blockBreakEvent.getResultBlock();
|
||||||
setBlock(x, y, z, resultBlock);
|
UNSAFE_setBlock(chunk, x, y, z, resultBlock, player);
|
||||||
|
|
||||||
// Send the block break effect packet
|
// Send the block break effect packet
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user