Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VanqarTeleporter extends Teleporter
- {
- public VanqarTeleporter(WorldServer worldIn)
- {
- super(worldIn);
- }
- @Override
- public void placeInPortal(Entity entityIn, float rotationYaw)
- {
- if(world.provider.getDimensionType() == Dimensions.vanqarDimension)
- {
- this.placeInExistingPortal(entityIn, rotationYaw);
- this.makePortal(entityIn);
- }
- }
- @Override
- public boolean makePortal(Entity entityIn)
- {
- int posX = MathHelper.floor(entityIn.posX);
- int posY = MathHelper.floor(entityIn.posY);
- int posZ = MathHelper.floor(entityIn.posZ);
- BlockPos entityPos = new BlockPos(posX, posY, posZ);
- for (int y = 64; y < posY + 16; ++y)
- {
- for(int x = posX - 16; x <= posX + 16; ++x)
- {
- for(int z = posZ; z <= posZ + 16; ++z)
- {
- BlockPos placePos = new BlockPos(x, y, z);
- if (entityPos.equals(placePos))
- {
- world.setBlockState(placePos, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER));
- } else if (placePos.equals(entityPos.up()))
- {
- world.setBlockState(placePos, Blocks.OAK_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER));
- } else if (z == posZ)
- {
- world.setBlockState(placePos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.GRAY));
- System.out.println(world.provider);
- }
- else
- {
- world.setBlockToAir(placePos);
- }
- }
- }
- }
- return true;
- }
- @Override
- public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
- {
- int posX = MathHelper.floor(entityIn.posX);
- int posZ = MathHelper.floor(entityIn.posZ);
- long chunkPos = ChunkPos.asLong(posX, posZ);
- BlockPos teleportPos;
- if(this.destinationCoordinateCache.containsValue(chunkPos))
- {
- PortalPosition portalPosition = destinationCoordinateCache.get(chunkPos);
- portalPosition.lastUpdateTime = world.getTotalWorldTime();
- teleportPos = new BlockPos(posX, 64, posZ);
- }
- else
- {
- teleportPos = findPortal(posX, posZ);
- if(teleportPos == null)
- {
- teleportPos = new BlockPos(posX, 64, posZ);
- }
- destinationCoordinateCache.put(chunkPos, new PortalPosition(teleportPos, world.getTotalWorldTime()));
- }
- if(entityIn instanceof EntityPlayerMP)
- ((EntityPlayerMP) entityIn).connection.setPlayerLocation(teleportPos.getX(), teleportPos.getY(), teleportPos.getZ(), rotationYaw, entityIn.rotationPitch);
- else
- entityIn.setPositionAndRotation(teleportPos.getX(), teleportPos.getY(), teleportPos.getZ(), rotationYaw, entityIn.rotationPitch);
- return true;
- }
- @Nullable
- private BlockPos findPortal(int posX, int posZ)
- {
- for(int x = posX - 128; x < posX + 128; ++x)
- {
- for(int z = posZ - 128; z < posZ + 128; ++z)
- {
- BlockPos blockPos = new BlockPos(x, 64, z);
- if(world.getBlockState(blockPos).getBlock() == SCPBlocks.door860)
- return blockPos;
- }
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement