use of net.minecraft.network.play.server.SPacketDestroyEntities in project SpongeCommon by SpongePowered.
the class EntityHuman method respawnOnClient.
private void respawnOnClient() {
this.pushPackets(new SPacketDestroyEntities(this.getEntityId()), this.createPlayerListPacket(SPacketPlayerListItem.Action.ADD_PLAYER));
this.pushPackets(this.createSpawnPacket());
removeFromTabListDelayed(null, this.createPlayerListPacket(SPacketPlayerListItem.Action.REMOVE_PLAYER));
}
use of net.minecraft.network.play.server.SPacketDestroyEntities in project SpongeCommon by SpongePowered.
the class MixinEntity method spongeOnUpdate.
@Inject(method = "onUpdate", at = @At("RETURN"))
private void spongeOnUpdate(CallbackInfo callbackInfo) {
if (this.pendingVisibilityUpdate && !this.world.isRemote) {
final EntityTracker entityTracker = ((WorldServer) this.world).getEntityTracker();
final EntityTrackerEntry lookup = entityTracker.trackedEntityHashTable.lookup(this.getEntityId());
if (this.visibilityTicks % 4 == 0) {
if (this.isVanished) {
for (EntityPlayerMP entityPlayerMP : lookup.trackingPlayers) {
entityPlayerMP.connection.sendPacket(new SPacketDestroyEntities(this.getEntityId()));
if (((Object) this) instanceof EntityPlayerMP) {
entityPlayerMP.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, (EntityPlayerMP) (Object) this));
}
}
} else {
this.visibilityTicks = 1;
this.pendingVisibilityUpdate = false;
for (EntityPlayerMP entityPlayerMP : SpongeImpl.getServer().getPlayerList().getPlayers()) {
if (((Object) this) == entityPlayerMP) {
continue;
}
if (((Object) this) instanceof EntityPlayerMP) {
Packet<?> packet = new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, (EntityPlayerMP) (Object) this);
entityPlayerMP.connection.sendPacket(packet);
}
// creates the spawn packet for us
Packet<?> newPacket = lookup.createSpawnPacket();
entityPlayerMP.connection.sendPacket(newPacket);
}
}
}
if (this.visibilityTicks > 0) {
this.visibilityTicks--;
} else {
this.pendingVisibilityUpdate = false;
}
}
}
use of net.minecraft.network.play.server.SPacketDestroyEntities in project SpongeCommon by SpongePowered.
the class EntityUtil method refreshPainting.
public static boolean refreshPainting(EntityPainting painting, EntityPainting.EnumArt art) {
EntityPainting.EnumArt oldArt = painting.art;
painting.art = art;
painting.updateFacingWithBoundingBox(painting.facingDirection);
if (!painting.onValidSurface()) {
painting.art = oldArt;
painting.updateFacingWithBoundingBox(painting.facingDirection);
return false;
}
final EntityTracker paintingTracker = ((WorldServer) painting.world).getEntityTracker();
EntityTrackerEntry paintingEntry = paintingTracker.trackedEntityHashTable.lookup(painting.getEntityId());
List<EntityPlayerMP> playerMPs = new ArrayList<>();
for (EntityPlayerMP player : paintingEntry.trackingPlayers) {
SPacketDestroyEntities packet = new SPacketDestroyEntities(painting.getEntityId());
player.connection.sendPacket(packet);
playerMPs.add(player);
}
for (EntityPlayerMP playerMP : playerMPs) {
SpongeImpl.getGame().getScheduler().createTaskBuilder().delayTicks(SpongeImpl.getGlobalConfig().getConfig().getEntity().getPaintingRespawnDelaly()).execute(() -> {
final SPacketSpawnPainting packet = new SPacketSpawnPainting(painting);
playerMP.connection.sendPacket(packet);
}).submit(SpongeImpl.getPlugin());
}
return true;
}
Aggregations