Java Code Examples for net.minecraft.server.management.PlayerList#transferEntityToWorld()
The following examples show how to use
net.minecraft.server.management.PlayerList#transferEntityToWorld() .
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: BlockTofuPortal.java From TofuCraftReload with MIT License | 5 votes |
/** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) { MinecraftServer server = worldIn.getMinecraftServer(); if (server != null && entityIn.timeUntilPortal <= 0) { PlayerList playerList = server.getPlayerList(); int i = entityIn.dimension == DimensionType.OVERWORLD.getId() ? TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId(); TofuTeleporter teleporter = new TofuTeleporter(server.getWorld(i)); entityIn.timeUntilPortal = 100; if (entityIn instanceof EntityPlayerMP) { playerList.transferPlayerToDimension((EntityPlayerMP) entityIn, i, teleporter); } else { int origin = entityIn.dimension; entityIn.dimension = i; worldIn.removeEntityDangerously(entityIn); entityIn.isDead = false; playerList.transferEntityToWorld(entityIn, origin, server.getWorld(origin), server.getWorld(i), teleporter); } } else entityIn.timeUntilPortal = Math.max(entityIn.getPortalCooldown(), 100); } }
Example 2
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; }