use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PorterProperties method tickTeleport.
public void tickTeleport() {
if (teleportTimeout < 0) {
return;
}
teleportTimeout--;
if (teleportTimeout <= 0) {
EntityPlayer player = (EntityPlayer) entity;
TeleportDestinations destinations = TeleportDestinations.getDestinations(entity.worldObj);
GlobalCoordinate coordinate = destinations.getCoordinateForId(target);
if (coordinate == null) {
Logging.message(player, EnumChatFormatting.RED + "Something went wrong! The target has disappeared!");
TeleportationTools.applyEffectForSeverity(player, 3, false);
return;
}
TeleportDestination destination = destinations.getDestination(coordinate);
TeleportationTools.performTeleport((EntityPlayer) entity, destination, 0, 10, false);
teleportTimeout = -1;
target = -1;
}
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class ShapeCardItem method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) {
if (!world.isRemote) {
int mode = getMode(stack);
if (mode == MODE_NONE) {
if (player.isSneaking()) {
if (world.getTileEntity(x, y, z) instanceof BuilderTileEntity) {
setCurrentBlock(stack, new GlobalCoordinate(new Coordinate(x, y, z), world.provider.dimensionId));
Logging.message(player, EnumChatFormatting.GREEN + "Now select the first corner");
setMode(stack, MODE_CORNER1);
setCorner1(stack, null);
} else {
Logging.message(player, EnumChatFormatting.RED + "You can only do this on a builder!");
}
} else {
return false;
}
} else if (mode == MODE_CORNER1) {
GlobalCoordinate currentBlock = getCurrentBlock(stack);
if (currentBlock.getDimension() != world.provider.dimensionId) {
Logging.message(player, EnumChatFormatting.RED + "The Builder is in another dimension!");
} else if (currentBlock.getCoordinate().equals(new Coordinate(x, y, z))) {
Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
setMode(stack, MODE_NONE);
} else {
Logging.message(player, EnumChatFormatting.GREEN + "Now select the second corner");
setMode(stack, MODE_CORNER2);
setCorner1(stack, new Coordinate(x, y, z));
}
} else {
GlobalCoordinate currentBlock = getCurrentBlock(stack);
if (currentBlock.getDimension() != world.provider.dimensionId) {
Logging.message(player, EnumChatFormatting.RED + "The Builder is in another dimension!");
} else if (currentBlock.getCoordinate().equals(new Coordinate(x, y, z))) {
Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
setMode(stack, MODE_NONE);
} else {
NBTTagCompound tag = stack.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
Coordinate c1 = getCorner1(stack);
if (c1 == null) {
Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
setMode(stack, MODE_NONE);
} else {
Logging.message(player, EnumChatFormatting.GREEN + "New settings copied to the shape card!");
System.out.println("currentBlock = " + currentBlock.getCoordinate());
System.out.println("corner1 = " + c1);
System.out.println("corner2 = " + x + ", " + y + ", " + z);
// Coordinate center = new Coordinate((int) ((c1.getX() + x) / 2.0f + .55f), (int) ((c1.getY() + y) / 2.0f + .55f), (int) ((c1.getZ() + z) / 2.0f + .55f));
Coordinate center = new Coordinate((int) Math.ceil((c1.getX() + x) / 2.0f), (int) Math.ceil((c1.getY() + y) / 2.0f), (int) Math.ceil((c1.getZ() + z) / 2.0f));
System.out.println("center = " + center);
tag.setInteger("dimX", Math.abs(c1.getX() - x) + 1);
tag.setInteger("dimY", Math.abs(c1.getY() - y) + 1);
tag.setInteger("dimZ", Math.abs(c1.getZ() - z) + 1);
tag.setInteger("offsetX", center.getX() - currentBlock.getCoordinate().getX());
tag.setInteger("offsetY", center.getY() - currentBlock.getCoordinate().getY());
tag.setInteger("offsetZ", center.getZ() - currentBlock.getCoordinate().getZ());
setMode(stack, MODE_NONE);
setCorner1(stack, null);
}
}
}
}
return true;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class ForgeEventHandlers method onBlockBreakEvent.
@SubscribeEvent
public void onBlockBreakEvent(BlockEvent.BreakEvent event) {
int x = event.x;
int y = event.y;
int z = event.z;
World world = event.world;
Collection<GlobalCoordinate> protectors = getProtectors(world, x, y, z);
checkHarvestProtection(event, x, y, z, world, protectors);
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class ForgeEventHandlers method onEntitySpawnEvent.
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
World world = event.world;
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (DimletConfiguration.preventSpawnUnpowered) {
if (dimensionInformation != null) {
// RFTools dimension.
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
int energy = storage.getEnergyLevel(id);
if (energy <= 0) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Dimension power low: Prevented a spawn of " + event.entity.getClass().getName());
}
}
}
if (dimensionInformation != null) {
if (dimensionInformation.hasEffectType(EffectType.EFFECT_STRONGMOBS) || dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
if (event.entity instanceof EntityLivingBase) {
EntityLivingBase entityLivingBase = (EntityLivingBase) event.entity;
IAttributeInstance entityAttribute = entityLivingBase.getEntityAttribute(SharedMonsterAttributes.maxHealth);
double newMax;
if (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
newMax = entityAttribute.getBaseValue() * DimletConfiguration.brutalMobsFactor;
} else {
newMax = entityAttribute.getBaseValue() * DimletConfiguration.strongMobsFactor;
}
entityAttribute.setBaseValue(newMax);
entityLivingBase.setHealth((float) newMax);
}
}
}
if (event.entity instanceof IMob) {
Coordinate coordinate = new Coordinate((int) event.entity.posX, (int) event.entity.posY, (int) event.entity.posZ);
if (PeacefulAreaManager.isPeaceful(new GlobalCoordinate(coordinate, id))) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful manager: Prevented a spawn of " + event.entity.getClass().getName());
} else if (dimensionInformation != null && dimensionInformation.isPeaceful()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful dimension: Prevented a spawn of " + event.entity.getClass().getName());
}
} else if (event.entity instanceof IAnimals) {
if (dimensionInformation != null && dimensionInformation.isNoanimals()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.entity.getClass().getName());
}
}
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class MatterReceiverBlock method onBlockPlaced.
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float sx, float sy, float sz, int meta) {
int rc = super.onBlockPlaced(world, x, y, z, side, sx, sy, sz, meta);
if (world.isRemote) {
return rc;
}
TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(x, y, z), world.provider.dimensionId);
destinations.getNewId(gc);
destinations.addDestination(gc);
destinations.save(world);
return rc;
}
Aggregations