Search in sources :

Example 11 with GlobalCoordinate

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);
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 12 with GlobalCoordinate

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);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 13 with GlobalCoordinate

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;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 14 with GlobalCoordinate

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 15 with GlobalCoordinate

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);
    }
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)78 Coordinate (mcjty.lib.varia.Coordinate)33 TileEntity (net.minecraft.tileentity.TileEntity)15 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 World (net.minecraft.world.World)13 NBTTagList (net.minecraft.nbt.NBTTagList)7 ItemStack (net.minecraft.item.ItemStack)6 BlockPos (net.minecraft.util.math.BlockPos)6 ArrayList (java.util.ArrayList)5 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)4 MovingSound (net.minecraft.client.audio.MovingSound)4 BlockProtectorTileEntity (mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity)3 PlayerExtendedProperties (mcjty.rftools.playerprops.PlayerExtendedProperties)3 IBlockState (net.minecraft.block.state.IBlockState)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 WorldServer (net.minecraft.world.WorldServer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3