mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Minor checks + FakePlayerController#finishDigging
This commit is contained in:
parent
e8a2c54485
commit
c15a795a74
@ -29,6 +29,12 @@ public class FakePlayer extends Player {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a FakePlayer not registered in {@link ConnectionManager}
|
||||
*
|
||||
* @param uuid the player uuid
|
||||
* @param username the player username
|
||||
*/
|
||||
public FakePlayer(UUID uuid, String username) {
|
||||
this(uuid, username, false);
|
||||
}
|
||||
|
@ -129,6 +129,14 @@ public class FakePlayerController {
|
||||
addToQueue(playerDiggingPacket);
|
||||
}
|
||||
|
||||
public void finishDigging(BlockPosition blockPosition) {
|
||||
ClientPlayerDiggingPacket playerDiggingPacket = new ClientPlayerDiggingPacket();
|
||||
playerDiggingPacket.status = ClientPlayerDiggingPacket.Status.FINISHED_DIGGING;
|
||||
playerDiggingPacket.blockPosition = blockPosition;
|
||||
playerDiggingPacket.blockFace = ClientPlayerDiggingPacket.BlockFace.BOTTOM; // TODO not hardcode
|
||||
addToQueue(playerDiggingPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the player receives a packet
|
||||
* WARNING: pretty much unsafe, used internally to redirect packets here,
|
||||
|
@ -114,6 +114,9 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
|
||||
//
|
||||
protected void sendChunkUpdate(Collection<Player> players, Chunk chunk) {
|
||||
if (ChunkUtils.isChunkUnloaded(this, chunk))
|
||||
return;
|
||||
|
||||
ByteBuf chunkData = chunk.getFullDataPacket();
|
||||
players.forEach(player -> {
|
||||
if (!PlayerUtils.isNettyClient(player))
|
||||
@ -124,12 +127,17 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
}
|
||||
|
||||
protected void sendChunkSectionUpdate(Chunk chunk, int section, Collection<Player> players) {
|
||||
if (ChunkUtils.isChunkUnloaded(this, chunk))
|
||||
return;
|
||||
|
||||
PacketWriterUtils.writeAndSend(players, getChunkSectionUpdatePacket(chunk, section));
|
||||
}
|
||||
|
||||
public void sendChunkSectionUpdate(Chunk chunk, int section, Player player) {
|
||||
if (!PlayerUtils.isNettyClient(player))
|
||||
return;
|
||||
if (ChunkUtils.isChunkUnloaded(this, chunk))
|
||||
return;
|
||||
|
||||
PacketWriterUtils.writeAndSend(player, getChunkSectionUpdatePacket(chunk, section));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user