Search in sources :

Example 6 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class PeacefulEModule method tick.

@Override
public void tick(World world, BlockPos pos, int radius, int miny, int maxy, EnvironmentalControllerTileEntity controllerTileEntity) {
    if (!isActive()) {
        return;
    }
    super.tick(world, pos, radius, miny, maxy, controllerTileEntity);
    PeacefulAreaManager.markArea(new GlobalCoordinate(pos, world.provider.getDimension()), radius, miny, maxy);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 7 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class ShieldBlock 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 8 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class PowerCellTileEntity method dumpNetwork.

public static void dumpNetwork(EntityPlayer player, PowerCellTileEntity powerCellTileEntity) {
    PowerCellNetwork.Network network = powerCellTileEntity.getNetwork();
    Set<GlobalCoordinate> blocks = network.getBlocks();
    // System.out.println("blocks.size() = " + blocks.size());
    blocks.forEach(b -> {
        String msg;
        World w = mcjty.lib.varia.TeleportationTools.getWorldForDimension(b.getDimension());
        if (w == null) {
            msg = "dimension missing!";
        } else {
            Block block = w.getBlockState(b.getCoordinate()).getBlock();
            if (block == PowerCellSetup.powerCellBlock) {
                msg = "normal";
            } else if (block == PowerCellSetup.advancedPowerCellBlock) {
                msg = "advanced";
            } else if (block == PowerCellSetup.creativePowerCellBlock) {
                msg = "creative";
            } else {
                msg = "not a powercell!";
            }
            TileEntity te = w.getTileEntity(b.getCoordinate());
            if (te instanceof PowerCellTileEntity) {
                PowerCellTileEntity power = (PowerCellTileEntity) te;
                msg += " (+:" + power.getTotalInserted() + ", -:" + power.getTotalExtracted() + ")";
            }
        }
        Logging.message(player, "Block: " + BlockPosTools.toString(b.getCoordinate()) + " (" + b.getDimension() + "): " + msg);
    });
}
Also used : SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World)

Example 9 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class SmartWrenchItem method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        if (player.isSneaking()) {
            // Make sure the block get activated if it is a GenericBlock
            IBlockState state = world.getBlockState(pos);
            Block block = state.getBlock();
            if (block instanceof GenericBlock) {
                if (DimensionalShardBlock.activateBlock(block, world, pos, state, player, hand, facing, hitX, hitY, hitZ)) {
                    return EnumActionResult.SUCCESS;
                }
            }
        }
        SmartWrenchMode mode = getCurrentMode(stack);
        if (mode == SmartWrenchMode.MODE_SELECT) {
            GlobalCoordinate b = getCurrentBlock(stack);
            if (b != null) {
                if (b.getDimension() != world.provider.getDimension()) {
                    Logging.message(player, TextFormatting.RED + "The selected block is in another dimension!");
                    return EnumActionResult.FAIL;
                }
                TileEntity te = world.getTileEntity(b.getCoordinate());
                if (te instanceof SmartWrenchSelector) {
                    SmartWrenchSelector smartWrenchSelector = (SmartWrenchSelector) te;
                    smartWrenchSelector.selectBlock(player, pos);
                }
            }
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : GenericBlock(mcjty.lib.container.GenericBlock) SmartWrenchMode(mcjty.lib.api.smartwrench.SmartWrenchMode) TileEntity(net.minecraft.tileentity.TileEntity) SmartWrenchSelector(mcjty.lib.api.smartwrench.SmartWrenchSelector) IBlockState(net.minecraft.block.state.IBlockState) DimensionalShardBlock(mcjty.rftools.blocks.ores.DimensionalShardBlock) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack)

Example 10 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class SmartWrenchItem method addInformation.

// @Override
// public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) {
// return true;
// }
// 
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    GlobalCoordinate b = getCurrentBlock(itemStack);
    if (b != null) {
        list.add(TextFormatting.GREEN + "Block: " + BlockPosTools.toString(b.getCoordinate()) + " at dimension " + b.getDimension());
    }
    SmartWrenchMode mode = getCurrentMode(itemStack);
    list.add(TextFormatting.WHITE + "Right-click on air to change mode.");
    list.add(TextFormatting.GREEN + "Mode: " + mode.getName());
    if (mode == SmartWrenchMode.MODE_WRENCH) {
        list.add(TextFormatting.WHITE + "Use as a normal wrench:");
        list.add(TextFormatting.WHITE + "    Sneak-right-click to pick up machines.");
        list.add(TextFormatting.WHITE + "    Right-click to rotate machines.");
    } else if (mode == SmartWrenchMode.MODE_SELECT) {
        list.add(TextFormatting.WHITE + "Use as a block selector:");
        list.add(TextFormatting.WHITE + "    Sneak-right-click select master block.");
        list.add(TextFormatting.WHITE + "    Right-click to associate blocks with master.");
    }
}
Also used : SmartWrenchMode(mcjty.lib.api.smartwrench.SmartWrenchMode) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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