Search in sources :

Example 1 with SPacketUnloadChunk

use of net.minecraft.network.play.server.SPacketUnloadChunk in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method destroy.

public void destroy() {
    wrapper.setDead();
    ArrayList<EntityPlayerMP> watchersCopy = (ArrayList<EntityPlayerMP>) watchingPlayers.clone();
    for (EntityPlayerMP wachingPlayer : watchersCopy) {
        for (int x = ownedChunks.minX; x <= ownedChunks.maxX; x++) {
            for (int z = ownedChunks.minZ; z <= ownedChunks.maxZ; z++) {
                SPacketUnloadChunk unloadPacket = new SPacketUnloadChunk(x, z);
                ((EntityPlayerMP) wachingPlayer).connection.sendPacket(unloadPacket);
            }
        }
    // NOTICE: This method isnt being called to avoid the watchingPlayers.remove(player) call, which is a waste of CPU time
    // onPlayerUntracking(wachingPlayer);
    }
    watchingPlayers.clear();
    ValkyrienWarfareMod.chunkManager.removeRegistedChunksForShip(wrapper);
    ValkyrienWarfareMod.chunkManager.removeShipPosition(wrapper);
    ValkyrienWarfareMod.chunkManager.removeShipNameRegistry(wrapper);
    ValkyrienWarfareMod.physicsManager.onShipUnload(wrapper);
}
Also used : SPacketUnloadChunk(net.minecraft.network.play.server.SPacketUnloadChunk) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 2 with SPacketUnloadChunk

use of net.minecraft.network.play.server.SPacketUnloadChunk in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method onPlayerUntracking.

/**
	 * TODO: Make this further get the player to stop all further tracking of thos physObject
	 *
	 * @param EntityPlayer
	 *            that stopped tracking
	 */
public void onPlayerUntracking(EntityPlayer untracking) {
    watchingPlayers.remove(untracking);
    for (int x = ownedChunks.minX; x <= ownedChunks.maxX; x++) {
        for (int z = ownedChunks.minZ; z <= ownedChunks.maxZ; z++) {
            SPacketUnloadChunk unloadPacket = new SPacketUnloadChunk(x, z);
            ((EntityPlayerMP) untracking).connection.sendPacket(unloadPacket);
        }
    }
}
Also used : SPacketUnloadChunk(net.minecraft.network.play.server.SPacketUnloadChunk)

Aggregations

SPacketUnloadChunk (net.minecraft.network.play.server.SPacketUnloadChunk)2 ArrayList (java.util.ArrayList)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1