use of net.tslat.aoa3.library.misc.PortalCoordinatesContainer in project Advent-Of-Ascension by Tslat.
the class AncientCavernTeleporter method findExistingPortal.
@Override
public BlockPos findExistingPortal(World world, Entity entity) {
if (world.provider.getDimension() == ConfigurationUtil.MainConfig.dimensionIds.ancientCavern) {
if (entity.hasCapability(AdventPlayerProvider.ADVENT_PLAYER, null)) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer((EntityPlayer) entity);
PortalCoordinatesContainer portalLoc = new PortalCoordinatesContainer(world.provider.getDimension(), entity.posX, entity.posY, entity.posZ);
plData.setPortalReturnLocation(entity.world.provider.getDimension(), portalLoc);
}
return new BlockPos(0, 18, 0);
}
return super.findExistingPortal(world, entity);
}
use of net.tslat.aoa3.library.misc.PortalCoordinatesContainer in project Advent-Of-Ascension by Tslat.
the class PlayerDataManager method loadFromNBT.
public void loadFromNBT(NBTTagCompound baseTag) {
stats.loadFromNBT(baseTag);
if (baseTag.hasKey("PortalMap")) {
NBTTagCompound portalMapTag = baseTag.getCompoundTag("PortalMap");
for (String s : portalMapTag.getKeySet()) {
NBTTagCompound portalReturnTag = portalMapTag.getCompoundTag(s);
int fromDim = portalReturnTag.getInteger("FromDim");
double x = portalReturnTag.getDouble("PosX");
double y = portalReturnTag.getDouble("PosY");
double z = portalReturnTag.getDouble("PosZ");
try {
portalCoordinatesMap.put(Integer.valueOf(s), new PortalCoordinatesContainer(fromDim, x, y, z));
} catch (NumberFormatException e) {
AdventOfAscension.logMessage(Level.WARN, "Found invalid portal map data, has someone been tampering with files? Data: " + s);
}
}
}
checkAndUpdateLegitimacy();
}
use of net.tslat.aoa3.library.misc.PortalCoordinatesContainer in project Advent-Of-Ascension by Tslat.
the class PortalBlock method onEntityCollision.
@Override
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity) {
WorldProvider provider;
ITeleporter teleporter;
if (!world.isRemote && !entity.isRiding() && !entity.isBeingRidden()) {
if (!ConfigurationUtil.MainConfig.allowNonPlayerPortalTravel & !(entity instanceof EntityPlayer))
return;
if (entity.timeUntilPortal > 0) {
entity.timeUntilPortal = 30;
return;
}
provider = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimId).provider;
teleporter = provider instanceof AoAWorldProvider ? ((AoAWorldProvider) provider).getTeleporter((WorldServer) world) : dimId == -1 ? new NetherTeleporter((WorldServer) world) : ((WorldServer) world).getDefaultTeleporter();
PortalCoordinatesContainer portalLoc = null;
if (entity instanceof EntityPlayer) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer((EntityPlayerMP) entity);
portalLoc = plData.getPortalReturnLocation(world.provider.getDimension());
((EntityPlayerMP) entity).connection.setPlayerLocation(pos.getX(), pos.getY(), pos.getZ(), entity.rotationYaw, entity.rotationPitch);
} else {
entity.setPositionAndUpdate(pos.getX(), pos.getY(), pos.getZ());
}
if (portalLoc == null) {
if (world.provider.getDimension() == dimId) {
entity = entity.changeDimension(0, teleporter);
} else {
entity = entity.changeDimension(dimId, teleporter);
}
} else if (world.provider.getDimension() != dimId) {
entity = entity.changeDimension(dimId, teleporter);
} else {
entity = entity.changeDimension(portalLoc.fromDim, teleporter);
}
if (entity != null)
entity.timeUntilPortal = 100;
}
}
use of net.tslat.aoa3.library.misc.PortalCoordinatesContainer in project Advent-Of-Ascension by Tslat.
the class AoATeleporter method placeEntity.
@Override
public void placeEntity(World world, Entity entity, float yaw) {
PlayerDataManager plData = null;
if (entity.hasCapability(AdventPlayerProvider.ADVENT_PLAYER, null)) {
entity.setNoGravity(false);
PortalCoordinatesContainer loc = (plData = PlayerUtil.getAdventPlayer((EntityPlayer) entity)).getPortalReturnLocation(world.provider.getDimension());
BlockPos locPos;
if (loc != null) {
Block locationBlock = world.getBlockState(locPos = loc.asBlockPos()).getBlock();
if (locationBlock == getPortalBlock()) {
placeInPortal(world, entity, locPos);
return;
} else if (!(locationBlock instanceof PortalBlock)) {
plData.removePortalReturnLocation(world.provider.getDimension());
}
}
}
double movementFactor = world.provider.getMovementFactor() / fromWorld.provider.getMovementFactor();
if (movementFactor != 1)
entity.setPositionAndUpdate(entity.posX * movementFactor, entity.posY, entity.posZ * movementFactor);
if (fromWorld.getBlockState(entity.getPosition()).getBlock() == getPortalBlock()) {
ChunkPos chunkPos = fromWorld.getChunk(entity.getPosition()).getPos();
getCachedPortalMap().put(ChunkPos.asLong(chunkPos.x, chunkPos.z), entity.getPosition());
}
BlockPos pos = findExistingPortal(world, entity);
if (pos == null) {
pos = findSuitablePortalLocation(world, entity);
pos = makePortal(world, entity, pos);
}
placeInPortal(world, entity, pos);
ChunkPos chunkPos = world.getChunk(pos).getPos();
getCachedPortalMap().put(ChunkPos.asLong(chunkPos.x, chunkPos.z), pos);
if (plData != null) {
PortalCoordinatesContainer portalLoc = plData.getPortalReturnLocation(world.provider.getDimension());
if (portalLoc != null) {
PortalCoordinatesContainer returnPortalLoc = plData.getPortalReturnLocation(entity.world.provider.getDimension());
if (returnPortalLoc != null && returnPortalLoc.fromDim == world.provider.getDimension())
return;
}
if (portalLoc == null || entity.world.provider.getDimension() == portalLoc.fromDim || entity.getDistanceSq(portalLoc.asBlockPos()) > ConfigurationUtil.MainConfig.portalSearchRadius)
plData.setPortalReturnLocation(world.provider.getDimension(), new PortalCoordinatesContainer(entity.world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ()));
}
}
use of net.tslat.aoa3.library.misc.PortalCoordinatesContainer in project Advent-Of-Ascension by Tslat.
the class ImmortallisTeleporter method findExistingPortal.
@Override
public BlockPos findExistingPortal(World world, Entity entity) {
if (world.provider.getDimension() == ConfigurationUtil.MainConfig.dimensionIds.immortallis) {
if (entity.hasCapability(AdventPlayerProvider.ADVENT_PLAYER, null)) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer((EntityPlayer) entity);
PortalCoordinatesContainer portalLoc = new PortalCoordinatesContainer(world.provider.getDimension(), entity.posX, entity.posY, entity.posZ);
plData.setPortalReturnLocation(entity.world.provider.getDimension(), portalLoc);
}
return new BlockPos(-5, 20, 3);
}
return super.findExistingPortal(world, entity);
}
Aggregations