use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project UltraCosmetics by iSach.
the class EntityUtil method sendDestroyPacket.
@Override
public void sendDestroyPacket(Player player, org.bukkit.entity.Entity entity) {
ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(((CraftEntity) entity).getHandle().getId());
((CraftPlayer) player).getHandle().connection.send(packet);
}
use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project UltraCosmetics by iSach.
the class EntityUtil method clearBlizzard.
@Override
public void clearBlizzard(Player player) {
if (!fakeArmorStandsMap.containsKey(player))
return;
for (ArmorStand as : fakeArmorStandsMap.get(player)) {
if (as == null) {
continue;
}
for (Player pl : player.getWorld().getPlayers()) {
sendPacket(pl, new ClientboundRemoveEntitiesPacket(as.getId()));
}
}
fakeArmorStandsMap.remove(player);
cooldownJumpMap.remove(player);
}
use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project Sponge 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 Sponge by SpongePowered.
the class PaintingData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(Painting.class).create(Keys.ART_TYPE).get(h -> (ArtType) h.motive).setAnd((h, v) -> {
if (!h.level.isClientSide) {
final Motive oldArt = h.motive;
h.motive = (Motive) v;
((HangingEntityAccessor) h).invoker$setDirection(h.getDirection());
if (!h.survives()) {
h.motive = oldArt;
((HangingEntityAccessor) h).invoker$setDirection(h.getDirection());
return false;
}
final ChunkMapAccessor chunkManager = (ChunkMapAccessor) ((ServerLevel) h.level).getChunkSource().chunkMap;
final ChunkMap_TrackedEntityAccessor paintingTracker = chunkManager.accessor$entityMap().get(h.getId());
if (paintingTracker == null) {
return true;
}
final List<ServerPlayer> players = new ArrayList<>();
for (final ServerPlayer player : paintingTracker.accessor$seenBy()) {
final ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(h.getId());
player.connection.send(packet);
players.add(player);
}
for (final ServerPlayer player : players) {
SpongeCommon.serverScheduler().submit(Task.builder().plugin(Launch.instance().commonPlugin()).delay(new SpongeTicks(SpongeGameConfigs.getForWorld(h.level).get().entity.painting.respawnDelay)).execute(() -> {
final ClientboundAddPaintingPacket packet = new ClientboundAddPaintingPacket(h);
player.connection.send(packet);
}).build());
}
return true;
}
return true;
});
}
use of net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket in project Sponge 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