net.minecraft.world.Teleporter Java Examples
The following examples show how to use
net.minecraft.world.Teleporter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TeleporterPaths.java From TFC2 with GNU General Public License v3.0 | 6 votes |
/** * 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(); } } } }
Example #2
Source File: CraftTravelAgent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Location findPortal(Location location) { Teleporter pta = ((CraftWorld) location.getWorld()).getHandle().getDefaultTeleporter(); BlockPos found = pta.findPortal(location.getX(), location.getY(), location.getZ(), this.getSearchRadius()); return found != null ? new Location(location.getWorld(), found.getX(), found.getY(), found.getZ(), location.getYaw(), location.getPitch()) : null; }
Example #3
Source File: CraftTravelAgent.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public boolean createPortal(Location location) { Teleporter pta = ((CraftWorld) location.getWorld()).getHandle().getDefaultTeleporter(); return pta.createPortal(location.getX(), location.getY(), location.getZ(), this.getCreationRadius()); }
Example #4
Source File: EntityElevatorCapsule.java From AdvancedRocketry with MIT License | 4 votes |
@Nullable public Entity changeDimension(int dimensionIn, double posX, double y, double posZ) { if (!this.world.isRemote && !this.isDead) { List<Entity> passengers = getPassengers(); if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, dimensionIn)) return null; this.world.profiler.startSection("changeDimension"); MinecraftServer minecraftserver = this.getServer(); int i = this.dimension; WorldServer worldserver = minecraftserver.getWorld(i); WorldServer worldserver1 = minecraftserver.getWorld(dimensionIn); this.dimension = dimensionIn; if (i == 1 && dimensionIn == 1) { worldserver1 = minecraftserver.getWorld(0); this.dimension = 0; } this.world.removeEntity(this); this.isDead = false; this.world.profiler.startSection("reposition"); BlockPos blockpos; double d0 = this.posX; double d1 = this.posZ; double d2 = 8.0D; d0 = MathHelper.clamp(d0 * 8.0D, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D); d1 = MathHelper.clamp(d1 * 8.0D, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D); d0 = (double)MathHelper.clamp((int)d0, -29999872, 29999872); d1 = (double)MathHelper.clamp((int)d1, -29999872, 29999872); float f = this.rotationYaw; this.setLocationAndAngles(d0, this.posY, d1, 90.0F, 0.0F); Teleporter teleporter = new TeleporterNoPortal(worldserver1); teleporter.placeInExistingPortal(this, f); worldserver.updateEntityWithOptionalForce(this, false); this.world.profiler.endStartSection("reloading"); Entity entity = EntityList.newEntity(this.getClass(), worldserver1); if (entity != null) { this.moveToBlockPosAndAngles(new BlockPos(posX, y, posZ), entity.rotationYaw, entity.rotationPitch); ((EntityElevatorCapsule)entity).copyDataFromOld(this); entity.forceSpawn = true; worldserver1.spawnEntity(entity); worldserver1.updateEntityWithOptionalForce(entity, true); int timeOffset = 1; for(Entity e : passengers) { //Fix that darn random crash? worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); //Transfer the player if applicable //Need to handle our own removal to avoid race condition where player is mounted on client on the old entity but is already mounted to the new one on server //PacketHandler.sendToPlayer(new PacketEntity(this, (byte)PacketType.DISMOUNTCLIENT.ordinal()), (EntityPlayer) e); PlanetEventHandler.addDelayedTransition(worldserver.getTotalWorldTime(), new TransitionEntity(worldserver.getTotalWorldTime(), e, dimensionIn, new BlockPos(posX + 16, y, posZ), entity)); //minecraftserver.getPlayerList().transferPlayerToDimension((EntityPlayerMP)e, dimensionIn, teleporter); //e.setLocationAndAngles(posX, Configuration.orbit, posZ, this.rotationYaw, this.rotationPitch); //e.startRiding(entity); //e.playerNetServerHandler.sendPacket(new SPacketRespawn(e.dimension, e.world.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), ((EntityPlayerMP)e).interactionManager.getGameType())); //((WorldServer)startWorld).getPlayerManager().removePlayer(player); } } this.isDead = true; this.world.profiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); this.world.profiler.endSection(); return entity; } else { return null; } }
Example #5
Source File: TeleporterPaths.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@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; } }
Example #6
Source File: BlockTofuPortal.java From TofuCraftReload with MIT License | 2 votes |
@SuppressWarnings("unused") private boolean changeDim(EntityPlayer playerIn) { MinecraftServer server = playerIn.world.getMinecraftServer(); if (server != null) { PlayerList playerList = server.getPlayerList(); int i = playerIn.dimension == DimensionType.OVERWORLD.getId() ? TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId(); Teleporter teleporter = new TofuTeleporter(server.getWorld(i)); if (playerIn instanceof EntityPlayerMP) { playerList.transferPlayerToDimension((EntityPlayerMP) playerIn, i, teleporter); } else { int origin = playerIn.dimension; playerIn.dimension = i; playerIn.world.removeEntityDangerously(playerIn); playerIn.isDead = false; playerList.transferEntityToWorld(playerIn, origin, server.getWorld(origin), server.getWorld(i), teleporter); } } return true; }