use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class ChargedPorterItem method onUpdate.
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (!worldIn.isRemote) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
return;
}
if (!tagCompound.hasKey("tpTimer")) {
return;
}
if (!(entityIn instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) entityIn;
int timer = tagCompound.getInteger("tpTimer");
timer--;
if (timer <= 0) {
tagCompound.removeTag("tpTimer");
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldIn);
int target = tagCompound.getInteger("target");
GlobalCoordinate coordinate = destinations.getCoordinateForId(target);
if (coordinate == null) {
Logging.message(player, TextFormatting.RED + "Something went wrong! The target has disappeared!");
TeleportationTools.applyEffectForSeverity(player, 3, false);
return;
}
TeleportDestination destination = destinations.getDestination(coordinate);
ForgeEventHandlers.addPlayerToTeleportHere(destination, player);
// TeleportationTools.performTeleport(player, destination, 0, 10, false);
} else {
tagCompound.setInteger("tpTimer", timer);
}
}
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class BlockProtectorTileEntity method selectBlock.
@Override
public void selectBlock(EntityPlayer player, BlockPos pos) {
// This is always called server side.
int xCoord = getPos().getX();
int yCoord = getPos().getY();
int zCoord = getPos().getZ();
if (Math.abs(pos.getX() - xCoord) > BlockProtectorConfiguration.maxProtectDistance || Math.abs(pos.getY() - yCoord) > BlockProtectorConfiguration.maxProtectDistance || Math.abs(pos.getZ() - zCoord) > BlockProtectorConfiguration.maxProtectDistance) {
Logging.message(player, TextFormatting.RED + "Block out of range of the block protector!");
return;
}
GlobalCoordinate gc = new GlobalCoordinate(pos, getWorld().provider.getDimension());
toggleCoordinate(gc);
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class BlockProtectorBlock method wrenchSneakSelect.
@Override
protected boolean wrenchSneakSelect(World world, BlockPos pos, EntityPlayer player) {
if (!world.isRemote) {
GlobalCoordinate currentBlock = SmartWrenchItem.getCurrentBlock(player.getHeldItem(EnumHand.MAIN_HAND));
if (currentBlock == null) {
SmartWrenchItem.setCurrentBlock(player.getHeldItem(EnumHand.MAIN_HAND), new GlobalCoordinate(pos, world.provider.getDimension()));
Logging.message(player, TextFormatting.YELLOW + "Selected block");
} else {
SmartWrenchItem.setCurrentBlock(player.getHeldItem(EnumHand.MAIN_HAND), null);
Logging.message(player, TextFormatting.YELLOW + "Cleared selected block");
}
}
return true;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class BlockProtectorBlock method getStateForPlacement.
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
IBlockState rc = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer);
if (world.isRemote) {
return rc;
}
BlockProtectors protectors = BlockProtectors.getProtectors(world);
GlobalCoordinate gc = new GlobalCoordinate(pos, world.provider.getDimension());
protectors.getNewId(gc);
protectors.save(world);
return rc;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class BlockProtectorEventHandlers method onBlockBreakEvent.
@SubscribeEvent
public static void onBlockBreakEvent(BlockEvent.BreakEvent event) {
int x = event.getPos().getX();
int y = event.getPos().getY();
int z = event.getPos().getZ();
World world = event.getWorld();
Collection<GlobalCoordinate> protectors = BlockProtectors.getProtectors(world, x, y, z);
if (BlockProtectors.checkHarvestProtection(x, y, z, world, protectors)) {
event.setCanceled(true);
}
}
Aggregations