/** Teleports the entity to another dimension. Params: Dimension number to teleport to */ public static void travelEntityToDimension(Entity entity, int dimensionId, int x, int y, int z) { if (!entity.worldObj.isRemote && !entity.isDead) { entity.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); int j = entity.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(j); WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId); entity.dimension = dimensionId; if (j == 1 && dimensionId == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); entity.dimension = 0; } entity.worldObj.removeEntity(entity); entity.isDead = false; entity.worldObj.theProfiler.startSection("reposition"); minecraftserver .getConfigurationManager() .transferEntityToWorld(entity, j, worldserver, worldserver1); entity.worldObj.theProfiler.endStartSection("reloading"); Entity newEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1); if (newEntity != null) { newEntity.copyDataFrom(entity, true); if (j == 1 && dimensionId == 1) { ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint(); chunkcoordinates.posY = entity.worldObj.getTopSolidOrLiquidBlock( chunkcoordinates.posX, chunkcoordinates.posZ); newEntity.setLocationAndAngles( (double) chunkcoordinates.posX, (double) chunkcoordinates.posY, (double) chunkcoordinates.posZ, newEntity.rotationYaw, newEntity.rotationPitch); } worldserver1.spawnEntityInWorld(newEntity); newEntity.setPosition(x + 0.5D, y, z + 0.5D); } entity.isDead = true; entity.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); entity.worldObj.theProfiler.endSection(); } }
public void remove() { entity.isDead = true; }
private static Entity sendEntityToWorld( Entity entity, int newDimension, Vector3 newPos, Facing3 newLook) { MinecraftServer server = MinecraftServer.getServer(); Entity currentEntity = entity; if (entity.dimension != newDimension) { if (entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) entity; ServerConfigurationManager scm = server.getConfigurationManager(); int oldDimension = player.dimension; player.dimension = newDimension; WorldServer oldWorld = server.worldServerForDimension(oldDimension); WorldServer newWorld = server.worldServerForDimension(newDimension); DimensionRegisterMessage packet = new DimensionRegisterMessage( newDimension, DimensionManager.getProviderType(newDimension)); LCRuntime.runtime.network().getPreferredPipe().sendForgeMessageTo(packet, player); player.closeScreen(); player.playerNetServerHandler.sendPacket( new S07PacketRespawn( player.dimension, player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType())); oldWorld.removePlayerEntityDangerously(player); player.isDead = false; player.setLocationAndAngles( newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch); newWorld.spawnEntityInWorld(player); player.setWorld(newWorld); scm.func_72375_a(player, oldWorld); player.playerNetServerHandler.setPlayerLocation( newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch); player.theItemInWorldManager.setWorld(newWorld); scm.updateTimeAndWeatherForPlayer(player, newWorld); scm.syncPlayerInventory(player); Iterator<?> var6 = player.getActivePotionEffects().iterator(); while (var6.hasNext()) player.playerNetServerHandler.sendPacket( new S1DPacketEntityEffect(player.getEntityId(), (PotionEffect) var6.next())); player.playerNetServerHandler.sendPacket( new S1FPacketSetExperience( player.experience, player.experienceTotal, player.experienceLevel)); } else { int oldDimension = entity.dimension; WorldServer oldWorld = server.worldServerForDimension(oldDimension); WorldServer newWorld = server.worldServerForDimension(newDimension); entity.dimension = newDimension; entity.worldObj.removeEntity(entity); entity.isDead = false; server .getConfigurationManager() .transferEntityToWorld(entity, oldDimension, oldWorld, newWorld); currentEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), newWorld); if (currentEntity != null) { currentEntity.copyDataFrom(entity, true); currentEntity.setLocationAndAngles( newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch); newWorld.spawnEntityInWorld(currentEntity); } entity.isDead = true; oldWorld.resetUpdateEntityTick(); newWorld.resetUpdateEntityTick(); } } else { currentEntity.setLocationAndAngles( newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch); if (currentEntity instanceof EntityPlayerMP) { EntityPlayerMP mpEnt = (EntityPlayerMP) currentEntity; mpEnt.rotationYaw = (float) newLook.yaw; mpEnt.setPositionAndUpdate(newPos.x, newPos.y, newPos.z); mpEnt.worldObj.updateEntityWithOptionalForce(entity, false); } } return currentEntity; }