Search in sources :

Example 1 with SPacketSpawnPainting

use of net.minecraft.network.play.server.SPacketSpawnPainting 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;
}
Also used : EntityTrackerEntry(net.minecraft.entity.EntityTrackerEntry) EntityTracker(net.minecraft.entity.EntityTracker) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.world.WorldServer) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IMixinEntityPlayerMP(org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayerMP) EntityPainting(net.minecraft.entity.item.EntityPainting) SPacketSpawnPainting(net.minecraft.network.play.server.SPacketSpawnPainting) SPacketDestroyEntities(net.minecraft.network.play.server.SPacketDestroyEntities)

Aggregations

ArrayList (java.util.ArrayList)1 EntityTracker (net.minecraft.entity.EntityTracker)1 EntityTrackerEntry (net.minecraft.entity.EntityTrackerEntry)1 EntityPainting (net.minecraft.entity.item.EntityPainting)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SPacketDestroyEntities (net.minecraft.network.play.server.SPacketDestroyEntities)1 SPacketSpawnPainting (net.minecraft.network.play.server.SPacketSpawnPainting)1 WorldServer (net.minecraft.world.WorldServer)1 IMixinEntityPlayerMP (org.spongepowered.common.interfaces.entity.player.IMixinEntityPlayerMP)1 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)1