use of com.tntmodders.takumi.world.teleport.TakumiTeleporter in project takumicraft by TNTModders.
the class BlockTakumiPortalFrame method changeDim.
private boolean changeDim(EntityPlayer playerIn) {
MinecraftServer server = playerIn.world.getMinecraftServer();
if (server != null) {
PlayerList playerList = server.getPlayerList();
int i = playerIn.dimension == DimensionType.OVERWORLD.getId() ? TakumiWorldCore.TAKUMI_WORLD.getId() : DimensionType.OVERWORLD.getId();
Teleporter teleporter = new TakumiTeleporter(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;
}
use of com.tntmodders.takumi.world.teleport.TakumiTeleporter in project takumicraft by TNTModders.
the class BlockTakumiPortal method onEntityCollidedWithBlock.
/**
* 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() ? TakumiWorldCore.TAKUMI_WORLD.getId() : DimensionType.OVERWORLD.getId();
TakumiTeleporter teleporter = new TakumiTeleporter(server.getWorld(i));
teleporter.setTakumiPortal(entityIn, pos);
entityIn.timeUntilPortal = entityIn.getPortalCooldown() * 2;
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);
}
}
}
}
Aggregations