use of net.minecraft.server.level.ChunkMap in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method sendHidePacket.
/*
Hide Entity
*/
@Override
public void sendHidePacket(Player pl, Entity entity) {
if (entity instanceof Player) {
pl.hidePlayer(Denizen.getInstance(), (Player) entity);
return;
}
CraftPlayer craftPlayer = (CraftPlayer) pl;
ServerPlayer entityPlayer = craftPlayer.getHandle();
if (entityPlayer.connection != null && !craftPlayer.equals(entity)) {
ChunkMap tracker = ((ServerLevel) craftPlayer.getHandle().level).getChunkSource().chunkMap;
net.minecraft.world.entity.Entity other = ((CraftEntity) entity).getHandle();
ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId());
if (entry != null) {
entry.removePlayer(entityPlayer);
}
if (Denizen.supportsPaper) {
// Workaround for Paper issue
entityPlayer.connection.send(new ClientboundRemoveEntitiesPacket(other.getId()));
}
}
}
use of net.minecraft.server.level.ChunkMap in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method getPlayersThatSee.
@Override
public List<Player> getPlayersThatSee(Entity entity) {
ChunkMap tracker = ((ServerLevel) ((CraftEntity) entity).getHandle().level).getChunkSource().chunkMap;
ChunkMap.TrackedEntity entityTracker = tracker.entityMap.get(entity.getEntityId());
ArrayList<Player> output = new ArrayList<>();
if (entityTracker == null) {
return output;
}
for (ServerPlayerConnection player : entityTracker.seenBy) {
output.add(player.getPlayer().getBukkitEntity());
}
return output;
}
use of net.minecraft.server.level.ChunkMap in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method sendShowPacket.
@Override
public void sendShowPacket(Player pl, Entity entity) {
if (entity instanceof Player) {
pl.showPlayer(Denizen.getInstance(), (Player) entity);
return;
}
CraftPlayer craftPlayer = (CraftPlayer) pl;
ServerPlayer entityPlayer = craftPlayer.getHandle();
if (entityPlayer.connection != null && !craftPlayer.equals(entity)) {
ChunkMap tracker = ((ServerLevel) craftPlayer.getHandle().level).getChunkProvider().chunkMap;
net.minecraft.world.entity.Entity other = ((CraftEntity) entity).getHandle();
ChunkMap.TrackedEntity entry = tracker.G.get(other.getId());
if (entry != null) {
entry.removePlayer(entityPlayer);
entry.updatePlayer(entityPlayer);
}
}
}
use of net.minecraft.server.level.ChunkMap in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method sendHidePacket.
/*
Hide Entity
*/
@Override
public void sendHidePacket(Player pl, Entity entity) {
if (entity instanceof Player) {
pl.hidePlayer(Denizen.getInstance(), (Player) entity);
return;
}
CraftPlayer craftPlayer = (CraftPlayer) pl;
ServerPlayer entityPlayer = craftPlayer.getHandle();
if (entityPlayer.connection != null && !craftPlayer.equals(entity)) {
ChunkMap tracker = ((ServerLevel) craftPlayer.getHandle().level).getChunkProvider().chunkMap;
net.minecraft.world.entity.Entity other = ((CraftEntity) entity).getHandle();
ChunkMap.TrackedEntity entry = tracker.G.get(other.getId());
if (entry != null) {
entry.removePlayer(entityPlayer);
}
if (Denizen.supportsPaper) {
// Workaround for Paper issue
entityPlayer.connection.send(new ClientboundRemoveEntitiesPacket(other.getId()));
}
}
}
use of net.minecraft.server.level.ChunkMap in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method getPlayersThatSee.
@Override
public List<Player> getPlayersThatSee(Entity entity) {
ChunkMap tracker = ((ServerLevel) ((CraftEntity) entity).getHandle().level).getChunkProvider().chunkMap;
ChunkMap.TrackedEntity entityTracker = tracker.G.get(entity.getEntityId());
ArrayList<Player> output = new ArrayList<>();
if (entityTracker == null) {
return output;
}
for (ServerPlayerConnection player : entityTracker.seenBy) {
output.add(player.getPlayer().getBukkitEntity());
}
return output;
}
Aggregations