Minor checks + FakePlayerController#finishDigging

This commit is contained in:
Felix Cravic 2020-05-25 15:42:54 +02:00
parent e8a2c54485
commit c15a795a74
3 changed files with 22 additions and 0 deletions

View File

@ -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);
}

View File

@ -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,

View File

@ -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));
}