use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket 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.network.protocol.game.ClientboundRemoveEntitiesPacket 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.network.protocol.game.ClientboundRemoveEntitiesPacket in project Denizen-For-Bukkit by DenizenScript.
the class ProfileEditorImpl method updatePlayer.
@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
final ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
final UUID uuid = player.getUniqueId();
ClientboundRemoveEntitiesPacket destroyPacket = new ClientboundRemoveEntitiesPacket(entityPlayer.getId());
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (!p.getUniqueId().equals(uuid)) {
PacketHelperImpl.send(p, destroyPacket);
}
}
new BukkitRunnable() {
@Override
public void run() {
ClientboundPlayerInfoPacket playerInfo = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, entityPlayer);
ClientboundAddPlayerPacket spawnPacket = new ClientboundAddPlayerPacket(entityPlayer);
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
PacketHelperImpl.send(player, playerInfo);
if (!player.getUniqueId().equals(uuid)) {
PacketHelperImpl.send(player, spawnPacket);
} else {
if (isSkinChanging) {
((CraftServer) Bukkit.getServer()).getHandle().respawn(entityPlayer, (ServerLevel) entityPlayer.level, true, player.getLocation(), false);
}
player.updateInventory();
}
}
}
}.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project SpongeCommon by SpongePowered.
the class HumanEntity method respawnOnClient.
private void respawnOnClient() {
this.pushPackets(new ClientboundRemoveEntitiesPacket(this.getId()), this.createPlayerListPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER));
this.pushPackets(this.getAddEntityPacket());
this.removeFromTabListDelayed(null, this.createPlayerListPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER));
}
use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project SpongeCommon by SpongePowered.
the class EntityMixin method impl$updateVanishState.
@SuppressWarnings({ "ConstantConditions", "RedundantCast" })
@Inject(method = "tick", at = @At("RETURN"))
private void impl$updateVanishState(final CallbackInfo callbackInfo) {
if (this.impl$pendingVisibilityUpdate && !this.level.isClientSide) {
final ChunkMap_TrackedEntityAccessor trackerAccessor = ((ChunkMapAccessor) ((ServerWorld) this.level).chunkManager()).accessor$entityMap().get(this.shadow$getId());
if (trackerAccessor != null && this.impl$visibilityTicks % 4 == 0) {
if (this.bridge$vanishState().invisible()) {
for (final ServerPlayer entityPlayerMP : trackerAccessor.accessor$seenBy()) {
entityPlayerMP.connection.send(new ClientboundRemoveEntitiesPacket(this.shadow$getId()));
if ((Entity) (Object) this instanceof ServerPlayer) {
entityPlayerMP.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, (ServerPlayer) (Object) this));
}
}
} else {
this.impl$visibilityTicks = 1;
this.impl$pendingVisibilityUpdate = false;
for (final ServerPlayer entityPlayerMP : SpongeCommon.server().getPlayerList().getPlayers()) {
if ((Entity) (Object) this == entityPlayerMP) {
continue;
}
if ((Entity) (Object) this instanceof ServerPlayer) {
final Packet<?> packet = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, (ServerPlayer) (Object) this);
entityPlayerMP.connection.send(packet);
}
trackerAccessor.accessor$updatePlayer(entityPlayerMP);
}
}
}
if (this.impl$visibilityTicks > 0) {
this.impl$visibilityTicks--;
} else {
this.impl$pendingVisibilityUpdate = false;
}
}
}
Aggregations