Java 类net.minecraft.world.Teleporter 实例源码

项目:TeleToro    文件:Teletory.java   
private static boolean changePlayerDimension(EntityPlayerMP player, int dimId, TeleportorType type) {
    if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(player, dimId)) {
        return false;
    }

    if (player == null) {
        return false;
    }

    WorldServer world = player.mcServer.getWorld(dimId);

    Teleporter teleporter = getTeleporter(world, type);

    TeleToroUtil.setInvulnerableDimensionChange(player);
    player.timeUntilPortal = 10;
    player.mcServer.getPlayerList().transferPlayerToDimension(player, dimId, teleporter);
    // player.connection.sendPacket(new SPacketEffect(1032, BlockPos.ORIGIN,
    // 0, false));
    TeleToroUtil.resetStatusFields(player);
    return true;
}
项目:Malgra    文件:TeleporterResearch.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime)
{
    if (worldTime % 100L == 0L)
    {
        long i = worldTime - 300L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext())
        {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i)
            {
                objectiterator.remove();
            }
        }
    }
}
项目:geomastery    文件:BlockEvents.java   
/** Makes portals if config. */
@SubscribeEvent
public void rightClick(RightClickBlock event) {

    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    ItemStack stack = event.getItemStack();
    Item item = stack.getItem();
    BlockPos pos = event.getPos();

    if (GeoConfig.compatibility.portals && item == GeoItems.FIREOPAL &&
            world instanceof WorldServer) {

        new Teleporter((WorldServer) world).makePortal(player);
        stack.shrink(1);
    }

    if (GeoConfig.compatibility.portals && item == GeoItems.AMETHYST) {

        Items.ENDER_EYE.onItemUse(player, world, pos,
                event.getHand(), event.getFace(), 0, 0, 0);
    }
}
项目:TFC2    文件:TeleporterPaths.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime)
{
    if (worldTime % 100L == 0L)
    {
        long i = worldTime - 600L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext())
        {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i)
            {
                objectiterator.remove();
            }
        }
    }
}
项目:Kingdom-Keys-Re-Coded    文件:DimensionTeleporter.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime) {
    if (worldTime % 100L == 0L) {
        long i = worldTime - 300L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext()) {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) {
                objectiterator.remove();
            }
        }
    }
}
项目:Kingdom-Keys-Re-Coded    文件:TeleporterOverworld.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime) {
    if (worldTime % 100L == 0L) {
        long i = worldTime - 300L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext()) {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) {
                objectiterator.remove();
            }
        }
    }
}
项目:Kingdom-Keys-Re-Coded    文件:TeleporterDiveToTheHeart.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime) {
    if (worldTime % 100L == 0L) {
        long i = worldTime - 300L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext()) {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) {
                objectiterator.remove();
            }
        }
    }
}
项目:TFC2    文件:TeleporterPaths.java   
/**
 * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
 * WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long worldTime)
{
    if (worldTime % 100L == 0L)
    {
        long i = worldTime - 600L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext())
        {
            Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i)
            {
                objectiterator.remove();
            }
        }
    }
}
项目:ZeroQuest    文件:TeleporterNillax.java   
/**
 * called periodically to remove out-of-date portal locations from the cache
 * list. Argument par1 is a WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long p_85189_1_) {
    if (p_85189_1_ % 100L == 0L) {
        Iterator iterator = this.destinationCoordinateKeys.iterator();
        long j = p_85189_1_ - 600L;

        while (iterator.hasNext()) {
            Long olong = (Long) iterator.next();
            Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition) this.destinationCoordinateCache.getValueByKey(olong.longValue());

            if (portalposition == null || portalposition.lastUpdateTime < j) {
                iterator.remove();
                this.destinationCoordinateCache.remove(olong.longValue());
            }
        }
    }
}
项目:ZeroQuest    文件:TeleporterDarkax.java   
/**
 * called periodically to remove out-of-date portal locations from the cache
 * list. Argument par1 is a WorldServer.getTotalWorldTime() value.
 */
@Override
public void removeStalePortalLocations(long p_85189_1_) {
    if (p_85189_1_ % 100L == 0L) {
        Iterator iterator = this.destinationCoordinateKeys.iterator();
        long j = p_85189_1_ - 600L;

        while (iterator.hasNext()) {
            Long olong = (Long) iterator.next();
            Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition) this.destinationCoordinateCache.getValueByKey(olong.longValue());

            if (portalposition == null || portalposition.lastUpdateTime < j) {
                iterator.remove();
                this.destinationCoordinateCache.remove(olong.longValue());
            }
        }
    }
}
项目:AbyssalCraft    文件:TeleporterAC.java   
@SuppressWarnings("rawtypes")
@Override
public void removeStalePortalLocations(long worldTime)
{
    if (worldTime % 100L == 0L)
    {
        long i = worldTime - 300L;
        ObjectIterator<Teleporter.PortalPosition> objectiterator = destinationCoordinateCache.values().iterator();

        while (objectiterator.hasNext())
        {
            Teleporter.PortalPosition teleporter$portalposition = objectiterator.next();

            if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i)
                objectiterator.remove();
        }
    }
}
项目:Cauldron    文件:ServerConfigurationManager.java   
public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, Teleporter teleporter)
{
    int j = p_72356_1_.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(p_72356_1_.dimension);
    p_72356_1_.dimension = p_72356_2_;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(p_72356_1_.dimension);
    p_72356_1_.playerNetServerHandler.sendPacket(new S07PacketRespawn(p_72356_1_.dimension, p_72356_1_.worldObj.difficultySetting, p_72356_1_.worldObj.getWorldInfo().getTerrainType(), p_72356_1_.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(p_72356_1_);
    p_72356_1_.isDead = false;
    this.transferEntityToWorld(p_72356_1_, j, worldserver, worldserver1, teleporter);
    this.func_72375_a(p_72356_1_, worldserver);
    p_72356_1_.playerNetServerHandler.setPlayerLocation(p_72356_1_.posX, p_72356_1_.posY, p_72356_1_.posZ, p_72356_1_.rotationYaw, p_72356_1_.rotationPitch);
    p_72356_1_.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(p_72356_1_, worldserver1);
    this.syncPlayerInventory(p_72356_1_);
    Iterator iterator = p_72356_1_.getActivePotionEffects().iterator();

    while (iterator.hasNext())
    {
        PotionEffect potioneffect = (PotionEffect)iterator.next();
        p_72356_1_.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(p_72356_1_.getEntityId(), potioneffect));
    }
    FMLCommonHandler.instance().firePlayerChangedDimensionEvent(p_72356_1_, j, p_72356_2_);
}
项目:RuneCraftery    文件:ServerConfigurationManager.java   
public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2, Teleporter teleporter)
{
    int j = par1EntityPlayerMP.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.dimension = par2;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(par1EntityPlayerMP.dimension, (byte)par1EntityPlayerMP.worldObj.difficultySetting, worldserver1.getWorldInfo().getTerrainType(), worldserver1.getHeight(), par1EntityPlayerMP.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(par1EntityPlayerMP);
    par1EntityPlayerMP.isDead = false;
    this.transferEntityToWorld(par1EntityPlayerMP, j, worldserver, worldserver1, teleporter);
    this.func_72375_a(par1EntityPlayerMP, worldserver);
    par1EntityPlayerMP.playerNetServerHandler.setPlayerLocation(par1EntityPlayerMP.posX, par1EntityPlayerMP.posY, par1EntityPlayerMP.posZ, par1EntityPlayerMP.rotationYaw, par1EntityPlayerMP.rotationPitch);
    par1EntityPlayerMP.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, worldserver1);
    this.syncPlayerInventory(par1EntityPlayerMP);
    Iterator iterator = par1EntityPlayerMP.getActivePotionEffects().iterator();

    while (iterator.hasNext())
    {
        PotionEffect potioneffect = (PotionEffect)iterator.next();
        par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(par1EntityPlayerMP.entityId, potioneffect));
    }

    GameRegistry.onPlayerChangedDimension(par1EntityPlayerMP);
}
项目:BetterNutritionMod    文件:ServerConfigurationManager.java   
public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2, Teleporter teleporter)
{
    int j = par1EntityPlayerMP.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.dimension = par2;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(par1EntityPlayerMP.dimension, (byte)par1EntityPlayerMP.worldObj.difficultySetting, worldserver1.getWorldInfo().getTerrainType(), worldserver1.getHeight(), par1EntityPlayerMP.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(par1EntityPlayerMP);
    par1EntityPlayerMP.isDead = false;
    this.transferEntityToWorld(par1EntityPlayerMP, j, worldserver, worldserver1, teleporter);
    this.func_72375_a(par1EntityPlayerMP, worldserver);
    par1EntityPlayerMP.playerNetServerHandler.setPlayerLocation(par1EntityPlayerMP.posX, par1EntityPlayerMP.posY, par1EntityPlayerMP.posZ, par1EntityPlayerMP.rotationYaw, par1EntityPlayerMP.rotationPitch);
    par1EntityPlayerMP.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, worldserver1);
    this.syncPlayerInventory(par1EntityPlayerMP);
    Iterator iterator = par1EntityPlayerMP.getActivePotionEffects().iterator();

    while (iterator.hasNext())
    {
        PotionEffect potioneffect = (PotionEffect)iterator.next();
        par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(par1EntityPlayerMP.entityId, potioneffect));
    }

    GameRegistry.onPlayerChangedDimension(par1EntityPlayerMP);
}
项目:Xth-uoth    文件:EntityRift.java   
@Override
   public void onCollideWithPlayer(EntityPlayer player) {
       if (player.ridingEntity == null && player.riddenByEntity == null && player.timeUntilPortal == 0) {
           if (player instanceof EntityPlayerMP) { // && !this.worldObj.isRemote) {
               //200 tick duration is ten seconds. There are 20 ticks a second
               PotionEffect effect = new PotionEffect(Potion.confusion.id, 200);
               player.addPotionEffect(effect);

               EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
               mpPlayer.timeUntilPortal = 200;
               int targetDimension = 0; // 0 = Overworld dimension ID
               if (mpPlayer.dimension != ConfigHandler.DIM_ID) {
                   targetDimension = ConfigHandler.DIM_ID;
               }
               Teleporter tele = new TeleporterXthuoth(mpPlayer.mcServer.worldServerForDimension(targetDimension));
               mpPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(mpPlayer, targetDimension, tele);
           }
       }
}
项目:Xth-uoth    文件:TeleporterXthuoth.java   
public void removeStalePortalLocations(long par1) {
    if (par1 % 100L == 0L) {
        Iterator<Long> iterator = this.destinationCoordinateKeys.iterator();
        long j = par1 - 600L;

        while (iterator.hasNext()) {
            Long olong = (Long)iterator.next();
            Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue());

            if (portalposition == null || portalposition.lastUpdateTime < j) {
                iterator.remove();
                this.destinationCoordinateCache.remove(olong.longValue());
            }
        }
    }
}
项目:Xth-uoth    文件:EntityRift.java   
@Override
   public void onCollideWithPlayer(EntityPlayer player) {
       if (player.ridingEntity == null && player.riddenByEntity == null && player.timeUntilPortal == 0) {
           if (player instanceof EntityPlayerMP) { // && !this.worldObj.isRemote) {
               //200 tick duration is ten seconds. There are 20 ticks a second
               PotionEffect effect = new PotionEffect(Potion.confusion.id, 200);
               player.addPotionEffect(effect);

               EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
               mpPlayer.timeUntilPortal = 200;
               int targetDimension = 0; // 0 = Overworld dimension ID
               if (mpPlayer.dimension != ConfigHandler.DIM_ID) {
                   targetDimension = ConfigHandler.DIM_ID;
               }
               Teleporter tele = new TeleporterXthuoth(mpPlayer.mcServer.worldServerForDimension(targetDimension));
               mpPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(mpPlayer, targetDimension, tele);
           }
       }
}
项目:UniversalRemote    文件:WorldServerProxy.java   
@Override
public Teleporter getDefaultTeleporter() {
    if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
        return m_proxyWorld.getDefaultTeleporter();
    } else if (m_realWorld != null) {
        return m_realWorld.getDefaultTeleporter();
    } else {
        return super.getDefaultTeleporter();
    }
}
项目:UniversalRemote    文件:HookedIntegratedPlayerList.java   
@Override
public void transferPlayerToDimension(EntityPlayerMP player, int dimensionIn, Teleporter teleporter) {
    if (player instanceof EntityPlayerMPProxy)
    {
        player = ((EntityPlayerMPProxy)player).getRealPlayer();
    }
    super.transferPlayerToDimension(player, dimensionIn, teleporter);
}
项目:UniversalRemote    文件:HookedDedicatedPlayerList.java   
@Override
public void transferPlayerToDimension(EntityPlayerMP player, int dimensionIn, Teleporter teleporter) {
    if (player instanceof EntityPlayerMPProxy)
    {
        player = ((EntityPlayerMPProxy)player).getRealPlayer();
    }
    super.transferPlayerToDimension(player, dimensionIn, teleporter);
}
项目:ExtraUtilities    文件:BlockPortal.java   
public boolean transferPlayer(final World world, final int x, final int y, final int z, final Entity entity) {
    if (entity.ridingEntity == null && entity.riddenByEntity == null && entity instanceof EntityPlayerMP) {
        final EntityPlayerMP thePlayer = (EntityPlayerMP)entity;
        if (XUHelper.isPlayerFake(thePlayer)) {
            return false;
        }
        final int type = world.getBlockMetadata(x, y, z) >> 1;
        if (type == 0) {
            if (ExtraUtils.underdarkDimID == 0) {
                return false;
            }
            if (thePlayer.dimension != ExtraUtils.underdarkDimID) {
                thePlayer.setLocationAndAngles(x + 0.5, thePlayer.posY, z + 0.5, thePlayer.rotationYaw, thePlayer.rotationPitch);
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, ExtraUtils.underdarkDimID, (Teleporter)new TeleporterUnderdark(thePlayer.mcServer.worldServerForDimension(ExtraUtils.underdarkDimID)));
            }
            else {
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, (Teleporter)new TeleporterUnderdark(thePlayer.mcServer.worldServerForDimension(0)));
            }
            return true;
        }
        else if (type == 1) {
            if (ExtraUtils.endoftimeDimID == 0) {
                return false;
            }
            if (thePlayer.dimension != ExtraUtils.endoftimeDimID) {
                thePlayer.setLocationAndAngles(x + 0.5, thePlayer.posY, z + 0.5, thePlayer.rotationYaw, thePlayer.rotationPitch);
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, ExtraUtils.endoftimeDimID, (Teleporter)new TeleporterEndOfTime(thePlayer.mcServer.worldServerForDimension(ExtraUtils.endoftimeDimID)));
            }
            else {
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, (Teleporter)new TeleporterEndOfTime(thePlayer.mcServer.worldServerForDimension(0)));
            }
            return true;
        }
    }
    return false;
}
项目:MidgarCrusade    文件:ServerPlayerBaseMagic.java   
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to, Dungeon true or false if the player was or not in a dungeon
*/
   public void travelToDimension(int to_dim, int from_dim)
   {
        EntityPlayerMP  thePlayer;
    Teleporter      teleporter;
    PlayerData      data;

    thePlayer = (EntityPlayerMP)player;
    if ((from_dim == Main.DIM_ID && to_dim == 0) || (from_dim == 0 && to_dim == Main.DIM_ID))
        teleporter = new TeleporterDim(thePlayer.mcServer.worldServerForDimension(to_dim));
    else
        teleporter = new TeleportDungeon(to_dim, from_dim, this);


    data = new PlayerData(this);
    ServerPlayerBaseMagic.PLAYER_DATA.put(this.getPlayer().getCommandSenderName(), data);

    if ((player.ridingEntity == null) && (player.riddenByEntity == null) && ((player instanceof EntityPlayerMP)))
    {
        if (thePlayer.timeUntilPortal > 0)
            thePlayer.timeUntilPortal = 10;
        else 
        {
            thePlayer.timeUntilPortal = 10;
            thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, to_dim, teleporter);
        }
        this.onRespawn();
    }
   }
项目:TeleToro    文件:Teletory.java   
private static Class<? extends Teleporter> getTeleporterClass(TeleportorType type) {
    switch (type) {
    case FALL:
        return FallFromTeletoryTeleporter.class;

    case PORTAL:
        return TeletoryTeleporter.class;

    case PEARL:
        return TeletoryPearlTeleporter.class;

    default:
        throw new UnsupportedOperationException("unknown teleporter [" + type + "]");
    }
}
项目:TeleToro    文件:Teletory.java   
private static Teleporter getNewTeleporterInstance(WorldServer world, TeleportorType type) {
    switch (type) {
    case FALL:
        return new FallFromTeletoryTeleporter(world);

    case PORTAL:
        return new TeletoryTeleporter(world);

    case PEARL:
        return new TeletoryPearlTeleporter(world);

    default:
        throw new UnsupportedOperationException("unknown teleporter [" + type + "]");
    }
}
项目:TeleToro    文件:TeletoryTeleporter.java   
private void readCachedPortal(PortalSearchState search) {
    Teleporter.PortalPosition portalposition = destinationCoordinateCache.get(search.longXZPair);
    search.distance = 0.0D;
    search.portalPos = portalposition;
    portalposition.lastUpdateTime = world.getTotalWorldTime();
    search.notCached = false;
}
项目:Alchemy    文件:DimensionTheForgottenTimeCourtyard.java   
@Hook("net.minecraft.world.Teleporter#func_180266_a")
public static Hook.Result placeInPortal(Teleporter teleporter, Entity entity, float rotationYaw) {
    if (teleporter.world.provider.getDimensionType() == type) {
        entity.setLocationAndAngles(0, 255, 0, entity.rotationYaw, 0.0F);
           entity.motionX = 0.0D;
           entity.motionY = 2.0D;
           entity.motionZ = 0.0D;
           return Hook.Result.NULL;
    }
    return Hook.Result.VOID;
}
项目:morecommands    文件:PatchEntityPlayerMP.java   
private static void transferPlayerToDimension(PlayerList playerList, net.minecraft.entity.player.EntityPlayerMP player, int dimension, Teleporter teleporter) {
    int i = player.dimension;
    WorldServer worldserver = playerList.getServerInstance().getWorld(player.dimension);
    player.dimension = dimension;
    WorldServer worldserver1 = playerList.getServerInstance().getWorld(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));

    //MoreCommands Bug fix: client world has wrong spawn position, because WorldClient is recreated after receiving S07PacketRespawn
    //with default spawn coordinates 8, 64, 8. This causes e.g. the compass to point to a wrong direction. A possible solution is sending a S05PacketSpawnPosition.
    //Fixes https://bugs.mojang.com/browse/MC-679
    player.connection.sendPacket(new SPacketSpawnPosition(new BlockPos(worldserver1.getWorldInfo().getSpawnX(), worldserver1.getWorldInfo().getSpawnY(), worldserver1.getWorldInfo().getSpawnZ())));

    playerList.updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    playerList.transferEntityToWorld(player, i, worldserver, worldserver1, teleporter);
    playerList.preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    playerList.updateTimeAndWeatherForPlayer(player, worldserver1);
    playerList.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimension);
}
项目:morecommands    文件:CommandSpawnportal.java   
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
    Entity entity = getSenderAsEntity(sender.getMinecraftISender(), Entity.class);

    if (params.length > 0) {
        if (params[0].equalsIgnoreCase("end"))
            new WorldGenEndPodium(true).generate(sender.getWorld(), new Random(), new BlockPos(entity));
        else if (params[0].equalsIgnoreCase("nether"))
            new Teleporter((WorldServer) entity.world).makePortal(entity);
        else throw new CommandException("command.spawnportal.unknownPortal", sender);
    }
    else throw new CommandException("command.spawnportal.noArgs", sender);

    return null;
}
项目:ImagineMod    文件:PlayerEventHandler.java   
@SubscribeEvent
public void doMovement(TickEvent.PlayerTickEvent e) {
    Iterator<Relocation> it = relocateQueue.iterator();
    while (it.hasNext()) {
        Relocation entry = it.next();
        if (entry.getPlayer().equals(e.player) && e.player instanceof EntityPlayerMP){
            FMLLog.info("Moving player: " + e.player.getDisplayName() + " to dim: " + entry.getDimension() + " @ " + entry.getCoords().toString());
            WorldServer worldserver = MinecraftServer.getServer().worldServerForDimension(entry.getDimension());
            IChunkProvider ichunkprovider = worldserver.getChunkProvider();
            ichunkprovider.loadChunk(entry.getCoords().posX - 3 >> 4, entry.getCoords().posZ - 3 >> 4);
            ichunkprovider.loadChunk(entry.getCoords().posX + 3 >> 4, entry.getCoords().posZ - 3 >> 4);
            ichunkprovider.loadChunk(entry.getCoords().posX - 3 >> 4, entry.getCoords().posZ + 3 >> 4);
            ichunkprovider.loadChunk(entry.getCoords().posX + 3 >> 4, entry.getCoords().posZ + 3 >> 4);

            for (int y = entry.getCoords().posY; y <= worldserver.getHeight(); y++) {
                Material material = worldserver.getBlock(entry.getCoords().posX, y, entry.getCoords().posZ).getMaterial();
                Material material1 = worldserver.getBlock(entry.getCoords().posX, y + 1, entry.getCoords().posZ).getMaterial();
                boolean flag1 = !material.isSolid() && !material.isLiquid();
                boolean flag2 = !material1.isSolid() && !material1.isLiquid();
                if (flag1 && flag2) {
                    entry.getCoords().posY = y;
                    break;
                }
            }
            ((EntityPlayerMP) e.player).mcServer.getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) e.player, entry.getDimension(), new Teleporter(worldserver));
            e.player.setPositionAndUpdate(entry.getCoords().posX, entry.getCoords().posY, entry.getCoords().posZ);
            it.remove();
         }
     }
}
项目:Cauldron    文件:Entity.java   
public void travelToDimension(int p_71027_1_)
{
    if (!this.worldObj.isRemote && !this.isDead)
    {
        this.worldObj.theProfiler.startSection("changeDimension");
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        // CraftBukkit start - Move logic into new function "teleportToLocation"
        // int j = this.dimension;
        // Cauldron start - Allow Forge hotloading on teleport
        WorldServer exitWorld = minecraftserver.worldServerForDimension(p_71027_1_);

        Location enter = this.getBukkitEntity().getLocation();
        Location exit = exitWorld != null ? minecraftserver.getConfigurationManager().calculateTarget(enter, minecraftserver.worldServerForDimension(p_71027_1_)) : null;
        boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
        // Cauldron start - check if teleporter is instance of TravelAgent before attempting to cast to it
        Teleporter teleporter = exit != null ? ((CraftWorld) exit.getWorld()).getHandle().getDefaultTeleporter() : null;
        TravelAgent agent = (teleporter != null && teleporter instanceof TravelAgent) ? (TravelAgent)teleporter : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT;  // return arbitrary TA to compensate for implementation dependent plugins
        // Cauldron end
        EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
        event.useTravelAgent(useTravelAgent);
        event.getEntity().getServer().getPluginManager().callEvent(event);

        if (event.isCancelled() || event.getTo() == null || !this.isEntityAlive())
        {
            return;
        }

        exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
        this.teleportTo(exit, true);
    }
}
项目:AgeCraft-Old    文件:AgeTeleporterOld.java   
@Override
public void removeStalePortalLocations(long totalWorldTime) {
    if(totalWorldTime % 100L == 0L) {
        Iterator iterator = destinationCoordinateKeys.iterator();
        long j = totalWorldTime - 600L;
        while(iterator.hasNext()) {
            Long olong = (Long) iterator.next();
            Teleporter.PortalPosition position = (Teleporter.PortalPosition) destinationCoordinateCache.getValueByKey(olong.longValue());
            if(position == null || position.lastUpdateTime < j) {
                iterator.remove();
                destinationCoordinateCache.remove(olong.longValue());
            }
        }
    }
}
项目:TeleToro    文件:Teletory.java   
private static Teleporter getTeleporter(WorldServer world, TeleportorType type) {
    return getCachedTeleporter(world, type);
}
项目:TeleToro    文件:TeletoryTeleporter.java   
private void cachePortalLocation(PortalSearchState search) {
    if (search.notCached) {
        destinationCoordinateCache.put(search.longXZPair, new Teleporter.PortalPosition(search.portalPos, world.getTotalWorldTime()));
    }
}
项目:TFC2    文件:TeleporterPaths.java   
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
    boolean flag = true;
    int playerX = MathHelper.floor(entityIn.posX);
    int playerZ = MathHelper.floor(entityIn.posZ);
    boolean shouldAddPortalPosition = true;
    boolean foundPortal = false;
    BlockPos object = new BlockPos(entityIn);
    long k = ChunkPos.asLong(playerX, playerZ);

    IslandMap islandMap = Core.getMapForWorld(worldServerInstance, entityIn.getPosition());
    Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096));
    //Check if we already have a portal position cached here
    if (this.destinationCoordinateCache.containsKey(k))
    {
        Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.get(k);
        object = portalposition;
        portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
        shouldAddPortalPosition = false;
    }
    else //If not then we do a simple search for the closest portal block
    {
        object = this.findPortal(new BlockPos(entityIn));
    }

    //If we found a portal location then we need to move the player to it
    if (object != null)
    {
        if (shouldAddPortalPosition)
        {
            this.destinationCoordinateCache.put(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime()));
            //this.destinationCoordinateKeys.add(Long.valueOf(k));
        }

        EnumFacing enumfacing = null;
        BlockPos pos = object;
        PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal);

        if(this.checkRoomForPlayer(pos.north()))
            pos = pos.north();
        else if(this.checkRoomForPlayer(pos.south()))
            pos = pos.south();
        else if(this.checkRoomForPlayer(pos.east()))
            pos = pos.east();
        else if(this.checkRoomForPlayer(pos.west()))
            pos = pos.west();

        entityIn.setLocationAndAngles(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, rotationYaw, entityIn.rotationPitch);
        return true;
    }
    else
    {
        return false;
    }
}
项目:morecommands    文件:PatchEntityPlayerMP.java   
@Override
public void transferPlayerToDimension(net.minecraft.entity.player.EntityPlayerMP player, int dimension, Teleporter teleporter) {
    PatchEntityPlayerMP.transferPlayerToDimension(this, player, dimension, teleporter);
}
项目:morecommands    文件:PatchEntityPlayerMP.java   
@Override
public void transferPlayerToDimension(net.minecraft.entity.player.EntityPlayerMP player, int dimension, Teleporter teleporter) {
    PatchEntityPlayerMP.transferPlayerToDimension(this, player, dimension, teleporter);
}
项目:Jiffy    文件:WorldServer.java   
/**
 * Runs a single tick for the world
 */
public void tick() {
    super.tick();

    if (this.getWorldInfo().isHardcoreModeEnabled() && this.difficultySetting != EnumDifficulty.HARD) {
        this.difficultySetting = EnumDifficulty.HARD;
    }

    this.provider.worldChunkMgr.cleanupCache();

    if (this.areAllPlayersAsleep()) {
        if (this.rules.getGameRuleBooleanValue("doDaylightCycle")) {
            long i = this.worldInfo.getWorldTime() + 24000L;
            this.worldInfo.setWorldTime(i - i % 24000L);
        }

        this.wakeAllPlayers();
    }

    // mobSpawner was here! Move after unloadChunks.

    this.theProfiler.startSection("chunkSource");
    this.chunkProvider.unloadQueuedChunks();
    int j = this.calculateSkylightSubtracted(1.0F);

    if (j != this.skylightSubtracted) {
        this.skylightSubtracted = j;
    }

    this.worldInfo.incrementTotalWorldTime(this.worldInfo.getWorldTotalTime() + 1L);

    if (this.rules.getGameRuleBooleanValue("doDaylightCycle")) {
        this.worldInfo.setWorldTime(this.worldInfo.getWorldTime() + 1L);
    }

    // START mobSpawner
    this.theProfiler.endStartSection("mobSpawner");

    if (this.rules.getGameRuleBooleanValue("doMobSpawning")) {
        this.animalSpawner.findChunksForSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs,
                this.worldInfo.getWorldTotalTime() % 400L == 0L);
    }
    // END

    this.theProfiler.endStartSection("tickPending");
    this.tickUpdates(false);
    this.theProfiler.endStartSection("tickBlocks");
    this.func_147456_g();
    this.theProfiler.endStartSection("chunkMap");
    this.thePlayerManager.updatePlayerInstances();
    this.theProfiler.endStartSection("village");
    this.villageCollectionObj.tick();
    this.villageSiegeObj.tick();
    this.theProfiler.endStartSection("portalForcer");
    this.worldTeleporter.removeStalePortalLocations(this.getTotalWorldTime());
    for (Teleporter tele : customTeleporters) {
        tele.removeStalePortalLocations(getTotalWorldTime());
    }
    this.theProfiler.endSection();
    this.func_147488_Z();
}
项目:Jiffy    文件:WorldServer.java   
public Teleporter getDefaultTeleporter() {
    return this.worldTeleporter;
}
项目:TFC2    文件:TeleporterPaths.java   
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
    boolean flag = true;
    int playerX = MathHelper.floor(entityIn.posX);
    int playerZ = MathHelper.floor(entityIn.posZ);
    boolean shouldAddPortalPosition = true;
    boolean foundPortal = false;
    BlockPos object = new BlockPos(entityIn);
    long k = ChunkPos.asLong(playerX, playerZ);

    IslandMap islandMap = Core.getMapForWorld(worldServerInstance, entityIn.getPosition());
    Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096));
    //Check if we already have a portal position cached here
    if (this.destinationCoordinateCache.containsKey(k))
    {
        Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.get(k);
        object = portalposition;
        portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
        shouldAddPortalPosition = false;
    }
    else //If not then we do a simple search for the closest portal block
    {
        object = this.findPortal(new BlockPos(entityIn));
    }

    //If we found a portal location then we need to move the player to it
    if (object != null)
    {
        if (shouldAddPortalPosition)
        {
            this.destinationCoordinateCache.put(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime()));
            //this.destinationCoordinateKeys.add(Long.valueOf(k));
        }

        EnumFacing enumfacing = null;
        BlockPos pos = object;
        PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal);

        if(this.checkRoomForPlayer(pos.north()))
            pos = pos.north();
        else if(this.checkRoomForPlayer(pos.south()))
            pos = pos.south();
        else if(this.checkRoomForPlayer(pos.east()))
            pos = pos.east();
        else if(this.checkRoomForPlayer(pos.west()))
            pos = pos.west();

        entityIn.setLocationAndAngles(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, rotationYaw, entityIn.rotationPitch);
        return true;
    }
    else
    {
        return false;
    }
}
项目:Dimensional-Pockets    文件:PocketTeleporter.java   
public static void transferPlayerToDimension(EntityPlayerMP player, int dimID, Teleporter teleporter) {
    MinecraftServer.getServer().getConfigurationManager().transferPlayerToDimension(player, dimID, teleporter);
}