@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { EntityPlayerMP player = (EntityPlayerMP) sender; if (player.openContainer != player.inventoryContainer) { player.closeScreen(); } player.incrementWindowID(); VirtualChest chest = new VirtualChest(player); player.playerNetServerHandler.sendPacketToPlayer( new Packet100OpenWindow(player.currentWindowId, 0, name, size, true)); player.openContainer = new ContainerChest(player.inventory, chest); player.openContainer.windowId = player.currentWindowId; player.openContainer.addCraftingToCrafters(player); }
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; }