More error fix

This commit is contained in:
TheMode 2021-05-24 22:00:18 +02:00
parent 86f7fa7e27
commit b15422f406
8 changed files with 98 additions and 270 deletions

View File

@ -3,7 +3,6 @@ package net.minestom.server.command.builder.arguments.minecraft.registry;
import net.minestom.server.command.builder.NodeMaker;
import net.minestom.server.instance.block.Block;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import net.minestom.server.registry.Registries;
import org.jetbrains.annotations.NotNull;
public class ArgumentBlockState extends ArgumentRegistry<Block> {
@ -14,7 +13,7 @@ public class ArgumentBlockState extends ArgumentRegistry<Block> {
@Override
public Block getRegistry(@NotNull String value) {
return Registries.getBlock(value);
return Block.fromNamespaceId(value);
}
@Override

View File

@ -4,39 +4,54 @@ import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.event.PlayerEvent;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.BlockManager;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlayerBlockBreakEvent extends PlayerEvent implements CancellableEvent {
private static final BlockManager BLOCK_MANAGER = MinecraftServer.getBlockManager();
private final Block block;
private Block resultBlock;
private final BlockPosition blockPosition;
private final short blockStateId;
private final CustomBlock customBlock;
private short resultBlockStateId;
private short resultCustomBlockId;
private boolean cancelled;
public PlayerBlockBreakEvent(@NotNull Player player, @NotNull BlockPosition blockPosition,
short blockStateId, @Nullable CustomBlock customBlock,
short resultBlockStateId, short resultCustomBlockId) {
public PlayerBlockBreakEvent(@NotNull Player player,
@NotNull Block block, @NotNull Block resultBlock, @NotNull BlockPosition blockPosition) {
super(player);
this.block = block;
this.resultBlock = resultBlock;
this.blockPosition = blockPosition;
}
this.blockStateId = blockStateId;
this.customBlock = customBlock;
/**
* Gets the block to break
*
* @return the block
*/
public @NotNull Block getBlock() {
return block;
}
this.resultBlockStateId = resultBlockStateId;
this.resultCustomBlockId = resultCustomBlockId;
/**
* Gets the block which will replace {@link #getBlock()}.
*
* @return the result block
*/
public @NotNull Block getResultBlock() {
return resultBlock;
}
/**
* Changes the result of the event.
*
* @param resultBlock the new block
*/
public void setResultBlock(@NotNull Block resultBlock) {
this.resultBlock = resultBlock;
}
/**
@ -44,104 +59,10 @@ public class PlayerBlockBreakEvent extends PlayerEvent implements CancellableEve
*
* @return the block position
*/
@NotNull
public BlockPosition getBlockPosition() {
public @NotNull BlockPosition getBlockPosition() {
return blockPosition;
}
/**
* Gets the broken block state id.
*
* @return the block id
*/
public short getBlockStateId() {
return blockStateId;
}
/**
* Gets the broken custom block.
*
* @return the custom block,
* null if not any
*/
@Nullable
public CustomBlock getCustomBlock() {
return customBlock;
}
/**
* Gets the visual block id result, which will be placed after the event.
*
* @return the block id that will be set at {@link #getBlockPosition()}
* set to 0 to remove
*/
public short getResultBlockStateId() {
return resultBlockStateId;
}
/**
* Changes the visual block id result.
*
* @param resultBlockStateId the result block id
*/
public void setResultBlockId(short resultBlockStateId) {
this.resultBlockStateId = resultBlockStateId;
}
/**
* Gets the custom block id result, which will be placed after the event.
* <p>
* Warning: the visual block will not be changed, be sure to call {@link #setResultBlockId(short)}
* if you want the visual to be the same as {@link CustomBlock#getDefaultBlockStateId()}.
*
* @return the custom block id that will be set at {@link #getBlockPosition()}
* set to 0 to remove
*/
public short getResultCustomBlockId() {
return resultCustomBlockId;
}
/**
* Changes the custom block id result, which will be placed after the event.
*
* @param resultCustomBlockId the custom block id result
*/
public void setResultCustomBlockId(short resultCustomBlockId) {
this.resultCustomBlockId = resultCustomBlockId;
}
/**
* Sets both the blockId and customBlockId.
*
* @param customBlock the result custom block
*/
public void setResultCustomBlock(@NotNull CustomBlock customBlock) {
setResultBlockId(customBlock.getDefaultBlockStateId());
setResultCustomBlockId(customBlock.getCustomBlockId());
}
/**
* Sets both the blockStateId and customBlockId.
*
* @param customBlockId the result custom block
*/
public void setResultCustomBlock(short customBlockId) {
final CustomBlock customBlock = BLOCK_MANAGER.getCustomBlock(customBlockId);
Check.notNull(customBlock, "The custom block with the id '" + customBlockId + "' does not exist");
setResultCustomBlock(customBlock);
}
/**
* Sets both the blockId and customBlockId.
*
* @param customBlockId the result custom block id
*/
public void setResultCustomBlock(@NotNull String customBlockId) {
final CustomBlock customBlock = BLOCK_MANAGER.getCustomBlock(customBlockId);
Check.notNull(customBlock, "The custom block with the identifier '" + customBlockId + "' does not exist");
setResultCustomBlock(customBlock);
}
@Override
public boolean isCancelled() {
return cancelled;

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.event.PlayerEvent;
import net.minestom.server.instance.block.Block;
import net.minestom.server.utils.BlockPosition;
import org.jetbrains.annotations.NotNull;
@ -16,17 +17,24 @@ import org.jetbrains.annotations.NotNull;
*/
public class PlayerStartDiggingEvent extends PlayerEvent implements CancellableEvent {
private final Block block;
private final BlockPosition blockPosition;
private final int blockStateId;
private final int customBlockId;
private boolean cancelled;
public PlayerStartDiggingEvent(@NotNull Player player, @NotNull BlockPosition blockPosition, int blockStateId, int customBlockId) {
public PlayerStartDiggingEvent(@NotNull Player player, @NotNull Block block, @NotNull BlockPosition blockPosition) {
super(player);
this.block = block;
this.blockPosition = blockPosition;
this.blockStateId = blockStateId;
this.customBlockId = customBlockId;
}
/**
* Gets the block which is being dug.
*
* @return the block
*/
public @NotNull Block getBlock() {
return block;
}
/**
@ -34,29 +42,10 @@ public class PlayerStartDiggingEvent extends PlayerEvent implements CancellableE
*
* @return the {@link BlockPosition}
*/
@NotNull
public BlockPosition getBlockPosition() {
public @NotNull BlockPosition getBlockPosition() {
return blockPosition;
}
/**
* Gets the block state id.
*
* @return the block state id
*/
public int getBlockStateId() {
return blockStateId;
}
/**
* Gets the custom block id.
*
* @return the custom block id
*/
public int getCustomBlockId() {
return customBlockId;
}
@Override
public boolean isCancelled() {
return cancelled;

View File

@ -85,7 +85,7 @@ public class DynamicChunk extends Chunk {
// Update pathfinder
if (columnarSpace != null) {
final ColumnarOcclusionFieldList columnarOcclusionFieldList = columnarSpace.occlusionFields();
final PFBlockDescription blockDescription = PFBlockDescription.getBlockDescription(blockStateId);
final PFBlockDescription blockDescription = PFBlockDescription.getBlockDescription(block);
columnarOcclusionFieldList.onBlockChanged(x, y, z, blockDescription, 0);
}
}

View File

@ -18,7 +18,6 @@ import net.minestom.server.storage.StorageLocation;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.PacketUtils;
import net.minestom.server.utils.Position;
import net.minestom.server.utils.block.CustomBlockUtils;
import net.minestom.server.utils.callback.OptionalCallback;
import net.minestom.server.utils.chunk.ChunkCallback;
import net.minestom.server.utils.chunk.ChunkSupplier;
@ -142,21 +141,12 @@ public class InstanceContainer extends Instance {
final BlockPosition blockPosition = new BlockPosition(x, y, z);
if (isAlreadyChanged(blockPosition, blockStateId)) { // do NOT change the block again.
if (isAlreadyChanged(blockPosition, block)) { // do NOT change the block again.
// Avoids StackOverflowExceptions when onDestroy tries to destroy the block itself
// This can happen with nether portals which break the entire frame when a portal block is broken
return;
}
setAlreadyChanged(blockPosition, blockStateId);
final int index = ChunkUtils.getBlockIndex(x, y, z);
final CustomBlock previousBlock = chunk.getCustomBlock(index);
final Data previousBlockData = previousBlock != null ? chunk.getBlockData(index) : null;
if (previousBlock != null) {
// Remove digging information for the previous custom block
previousBlock.removeDiggingInformation(this, blockPosition);
}
setAlreadyChanged(blockPosition, block);
// Change id based on neighbors
block = executeBlockPlacementRule(block, blockPosition);
@ -169,21 +159,11 @@ public class InstanceContainer extends Instance {
// Refresh player chunk block
sendBlockChange(chunk, blockPosition, block);
// Call the destroy listener for the previously destroyed block
if (previousBlock != null) {
callBlockDestroy(previousBlock, previousBlockData, blockPosition);
}
// Call the place listener for newly placed custom block
if (isCustomBlock) {
callBlockPlace(chunk, index, blockPosition);
}
}
}
private void setAlreadyChanged(@NotNull BlockPosition blockPosition, short blockStateId) {
currentlyChangingBlocks.put(blockPosition, Block.fromStateId(blockStateId));
private void setAlreadyChanged(@NotNull BlockPosition blockPosition, Block block) {
currentlyChangingBlocks.put(blockPosition, block);
}
/**
@ -191,14 +171,14 @@ public class InstanceContainer extends Instance {
* Prevents StackOverflow with blocks trying to modify their position in onDestroy or onPlace.
*
* @param blockPosition the block position
* @param blockStateId the block state id
* @param block the block
* @return true if the block changed since the last update
*/
private boolean isAlreadyChanged(@NotNull BlockPosition blockPosition, short blockStateId) {
private boolean isAlreadyChanged(@NotNull BlockPosition blockPosition, @NotNull Block block) {
final Block changedBlock = currentlyChangingBlocks.get(blockPosition);
if (changedBlock == null)
return false;
return changedBlock.getBlockId() == blockStateId;
return changedBlock.getBlockId() == block.getBlockId();
}
/**
@ -215,27 +195,10 @@ public class InstanceContainer extends Instance {
previousBlock.onDestroy(this, blockPosition, previousBlockData);
}
/**
* Calls {@link CustomBlock#onPlace(Instance, BlockPosition, Data)} for the current custom block at the position.
* <p>
* WARNING {@code chunk} needs to be synchronized.
*
* @param chunk the chunk where the block is
* @param index the block index
* @param blockPosition the block position
*/
private void callBlockPlace(@NotNull Chunk chunk, int index, @NotNull BlockPosition blockPosition) {
final CustomBlock actualBlock = chunk.getCustomBlock(index);
if (actualBlock == null)
return;
final Data previousData = chunk.getBlockData(index);
actualBlock.onPlace(this, blockPosition, previousData);
}
/**
* Calls the {@link BlockPlacementRule} for the specified block state id.
*
* @param block the block to modify
* @param block the block to modify
* @param blockPosition the block position
* @return the modified block state id
*/
@ -244,7 +207,7 @@ public class InstanceContainer extends Instance {
if (blockPlacementRule != null) {
return blockPlacementRule.blockUpdate(this, blockPosition, block);
}
return blockStateId;
return block;
}
/**
@ -269,28 +232,16 @@ public class InstanceContainer extends Instance {
if (chunk == null)
continue;
final short neighborStateId = chunk.getBlockStateId(neighborX, neighborY, neighborZ);
final BlockPlacementRule neighborBlockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(neighborStateId);
final Block neighborBlock = chunk.getBlock(neighborX, neighborY, neighborZ);
final BlockPlacementRule neighborBlockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(neighborBlock);
if (neighborBlockPlacementRule != null) {
final BlockPosition neighborPosition = new BlockPosition(neighborX, neighborY, neighborZ);
final short newNeighborId = neighborBlockPlacementRule.blockUpdate(this,
neighborPosition, neighborStateId);
if (neighborStateId != newNeighborId) {
refreshBlockStateId(neighborPosition, newNeighborId);
final Block newNeighborBlock = neighborBlockPlacementRule.blockUpdate(this,
neighborPosition, neighborBlock);
if (neighborBlock != newNeighborBlock) {
setBlock(neighborPosition, newNeighborBlock);
}
}
// Update neighbors
final CustomBlock customBlock = getCustomBlock(neighborX, neighborY, neighborZ);
if (customBlock != null) {
boolean directNeighbor = false; // only if directly connected to neighbor (no diagonals)
if (offsetX != 0 ^ offsetZ != 0) {
directNeighbor = offsetY == 0;
} else if (offsetX == 0 && offsetZ == 0) {
directNeighbor = true;
}
customBlock.updateFromNeighbor(this, new BlockPosition(neighborX, neighborY, neighborZ), blockPosition, directNeighbor);
}
}
}
}
@ -316,37 +267,34 @@ public class InstanceContainer extends Instance {
final int y = blockPosition.getY();
final int z = blockPosition.getZ();
final short blockStateId = getBlockStateId(x, y, z);
final Block block = getBlock(x, y, z);
// The player probably have a wrong version of this chunk section, send it
if (blockStateId == 0) {
if (block.isAir()) {
chunk.sendChunkSectionUpdate(ChunkUtils.getSectionAt(y), player);
return false;
}
final CustomBlock customBlock = getCustomBlock(x, y, z);
PlayerBlockBreakEvent blockBreakEvent = new PlayerBlockBreakEvent(player, blockPosition, blockStateId, customBlock, (short) 0, (short) 0);
PlayerBlockBreakEvent blockBreakEvent = new PlayerBlockBreakEvent(player, block, Block.AIR, blockPosition);
player.callEvent(PlayerBlockBreakEvent.class, blockBreakEvent);
final boolean allowed = !blockBreakEvent.isCancelled();
if (allowed) {
// Break or change the broken block based on event result
final short resultState = blockBreakEvent.getResultBlockStateId();
final short resultCustom = blockBreakEvent.getResultCustomBlockId();
setSeparateBlocks(x, y, z, resultState, resultCustom);
final Block resultBlock = blockBreakEvent.getResultBlock();
setBlock(x, y, z, resultBlock);
// Send the block break effect packet
{
EffectPacket effectPacket = new EffectPacket();
effectPacket.effectId = 2001; // Block break + block break sound
effectPacket.position = blockPosition;
effectPacket.data = blockStateId;
effectPacket.data = resultBlock.getStateId();
effectPacket.disableRelativeVolume = false;
PacketUtils.sendGroupedPacket(chunk.getViewers(), effectPacket,
(viewer) -> {
// Prevent the block breaker to play the particles and sound two times
return (customBlock != null && customBlock.enableCustomBreakDelay()) || !viewer.equals(player);
return !viewer.equals(player);
});
}

View File

@ -99,10 +99,7 @@ public class RedstonePlacementRule extends BlockPlacementRule {
public Block blockPlace(@NotNull Instance instance,
@NotNull Block block, @NotNull BlockFace blockFace, @NotNull BlockPosition blockPosition,
@NotNull Player pl) {
final short belowBlockId = instance.getBlockStateId(blockPosition.getX(), blockPosition.getY() - 1, blockPosition.getZ());
if (!Block.fromStateId(belowBlockId).getData().isSolid()) {
return null;
}
return block;
final Block belowBlock = instance.getBlock(blockPosition.getX(), blockPosition.getY() - 1, blockPosition.getZ());
return belowBlock.isSolid() ? block : null;
}
}

View File

@ -1,7 +1,6 @@
package net.minestom.server.listener;
import net.minestom.server.MinecraftServer;
import net.minestom.server.data.Data;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.GameMode;
@ -14,7 +13,6 @@ import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.BlockFace;
import net.minestom.server.instance.block.BlockManager;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.instance.block.rule.BlockPlacementRule;
import net.minestom.server.inventory.PlayerInventory;
import net.minestom.server.item.ItemStack;
@ -53,21 +51,8 @@ public class BlockPlacementListener {
// Interact at block
// FIXME: onUseOnBlock
final boolean cancel = false;//usedItem.onUseOnBlock(player, hand, blockPosition, direction);
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(player, blockPosition, hand, blockFace);
playerBlockInteractEvent.setCancelled(cancel);
playerBlockInteractEvent.setBlockingItemUse(cancel);
player.callCancellableEvent(PlayerBlockInteractEvent.class, playerBlockInteractEvent, () -> {
final CustomBlock customBlock = instance.getCustomBlock(blockPosition);
if (customBlock != null) {
final Data data = instance.getBlockData(blockPosition);
final boolean blocksItem = customBlock.onInteract(player, hand, blockPosition, data);
if (blocksItem) {
playerBlockInteractEvent.setBlockingItemUse(true);
}
}
});
player.callEvent(PlayerBlockInteractEvent.class, playerBlockInteractEvent);
if (playerBlockInteractEvent.isBlockingItemUse()) {
return;
}
@ -150,23 +135,16 @@ public class BlockPlacementListener {
if (!playerBlockPlaceEvent.isCancelled()) {
// BlockPlacementRule check
short blockStateId = playerBlockPlaceEvent.getBlockStateId();
final Block resultBlock = Block.fromStateId(blockStateId);
Block resultBlock = playerBlockPlaceEvent.getBlock();
final BlockPlacementRule blockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(resultBlock);
if (blockPlacementRule != null) {
// Get id from block placement rule instead of the event
blockStateId = blockPlacementRule.blockPlace(instance, resultBlock, blockFace, blockPosition, player);
resultBlock = blockPlacementRule.blockPlace(instance, resultBlock, blockFace, blockPosition, player);
}
final boolean placementRuleCheck = blockStateId != BlockPlacementRule.CANCEL_CODE;
final boolean placementRuleCheck = resultBlock != null;
if (placementRuleCheck) {
// Place the block
final short customBlockId = playerBlockPlaceEvent.getCustomBlockId();
final Data blockData = playerBlockPlaceEvent.getBlockData(); // Possibly null
instance.setSeparateBlocks(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(),
blockStateId, customBlockId, blockData);
instance.setBlock(blockPosition, resultBlock);
// Block consuming
if (playerBlockPlaceEvent.doesConsumeBlock()) {
// Consume the block in the player's hand

View File

@ -37,11 +37,11 @@ public class PlayerDiggingListener {
return;
if (status == ClientPlayerDiggingPacket.Status.STARTED_DIGGING) {
final short blockStateId = instance.getBlockStateId(blockPosition);
final Block block = instance.getBlock(blockPosition);
//Check if the player is allowed to break blocks based on their game mode
if (player.getGameMode() == GameMode.SPECTATOR) {
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.STARTED_DIGGING, false);
return; //Spectators can't break blocks
} else if (player.getGameMode() == GameMode.ADVENTURE) {
@ -49,7 +49,7 @@ public class PlayerDiggingListener {
ItemStack itemInMainHand = player.getItemInMainHand();
Block destroyedBlock = instance.getBlock(blockPosition);
if (!itemInMainHand.getMeta().getCanDestroy().contains(destroyedBlock)) {
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.STARTED_DIGGING, false);
return;
}
@ -57,23 +57,21 @@ public class PlayerDiggingListener {
final boolean instantBreak = player.isCreative() ||
player.isInstantBreak() ||
Block.fromStateId(blockStateId).breaksInstantaneously();
block.breaksInstantaneously();
if (instantBreak) {
// No need to check custom block
breakBlock(instance, player, blockPosition, blockStateId, status);
breakBlock(instance, player, blockPosition, block, status);
} else {
final CustomBlock customBlock = instance.getCustomBlock(blockPosition);
final int customBlockId = customBlock == null ? 0 : customBlock.getCustomBlockId();
PlayerStartDiggingEvent playerStartDiggingEvent = new PlayerStartDiggingEvent(player, blockPosition, blockStateId, customBlockId);
PlayerStartDiggingEvent playerStartDiggingEvent = new PlayerStartDiggingEvent(player, block, blockPosition);
player.callEvent(PlayerStartDiggingEvent.class, playerStartDiggingEvent);
if (playerStartDiggingEvent.isCancelled()) {
addEffect(player);
// Unsuccessful digging
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.STARTED_DIGGING, false);
} else if (customBlock != null) {
// Start digging the custom block
@ -82,31 +80,31 @@ public class PlayerDiggingListener {
addEffect(player);
}
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.STARTED_DIGGING, true);
}
}
} else if (status == ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING) {
final short blockStateId = instance.getBlockStateId(blockPosition);
final Block block = instance.getBlock(blockPosition);
// Remove custom block target
player.resetTargetBlock();
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING, true);
} else if (status == ClientPlayerDiggingPacket.Status.FINISHED_DIGGING) {
final short blockStateId = instance.getBlockStateId(blockPosition);
final Block block = instance.getBlock(blockPosition);
final CustomBlock customBlock = instance.getCustomBlock(blockPosition);
if (customBlock != null && customBlock.enableCustomBreakDelay()) {
// Is not supposed to happen, probably a bug
sendAcknowledgePacket(player, blockPosition, blockStateId,
sendAcknowledgePacket(player, blockPosition, block,
ClientPlayerDiggingPacket.Status.FINISHED_DIGGING, false);
} else {
// Vanilla block
breakBlock(instance, player, blockPosition, blockStateId, status);
breakBlock(instance, player, blockPosition, block, status);
}
} else if (status == ClientPlayerDiggingPacket.Status.DROP_ITEM_STACK) {
@ -169,7 +167,7 @@ public class PlayerDiggingListener {
private static void breakBlock(Instance instance,
Player player,
BlockPosition blockPosition, int blockStateId,
BlockPosition blockPosition, Block block,
ClientPlayerDiggingPacket.Status status) {
// Finished digging, remove effect if any
player.resetTargetBlock();
@ -177,15 +175,13 @@ public class PlayerDiggingListener {
// Unverified block break, client is fully responsible
final boolean result = instance.breakBlock(player, blockPosition);
final int updatedBlockId = instance.getBlockStateId(blockPosition);
final Block updatedBlock = instance.getBlock(blockPosition);
// Send acknowledge packet to allow or cancel the digging process
sendAcknowledgePacket(player, blockPosition, updatedBlockId,
status, result);
sendAcknowledgePacket(player, blockPosition, updatedBlock, status, result);
if (!result) {
final boolean solid = Block.fromStateId((short) blockStateId).isSolid();
if (solid) {
if (block.isSolid()) {
final BlockPosition playerBlockPosition = player.getPosition().toBlockPosition();
// Teleport the player back if he broke a solid block just below him
@ -252,15 +248,15 @@ public class PlayerDiggingListener {
*
* @param player the player
* @param blockPosition the block position
* @param blockStateId the block state id
* @param block the block
* @param status the status of the digging
* @param success true to notify of a success, false otherwise
*/
private static void sendAcknowledgePacket(@NotNull Player player, @NotNull BlockPosition blockPosition, int blockStateId,
private static void sendAcknowledgePacket(@NotNull Player player, @NotNull BlockPosition blockPosition, Block block,
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
acknowledgePlayerDiggingPacket.blockPosition = blockPosition;
acknowledgePlayerDiggingPacket.blockStateId = blockStateId;
acknowledgePlayerDiggingPacket.blockStateId = block.getStateId();
acknowledgePlayerDiggingPacket.status = status;
acknowledgePlayerDiggingPacket.successful = success;