Search in sources :

Example 1 with BuilderTileEntity

use of mcjty.rftools.blocks.builder.BuilderTileEntity in project RFTools by McJty.

the class ShapeCardItem 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) {
        int mode = getMode(stack);
        if (mode == MODE_NONE) {
            if (player.isSneaking()) {
                if (world.getTileEntity(pos) instanceof BuilderTileEntity) {
                    setCurrentBlock(stack, new GlobalCoordinate(pos, world.provider.getDimension()));
                    Logging.message(player, TextFormatting.GREEN + "Now select the first corner");
                    setMode(stack, MODE_CORNER1);
                    setCorner1(stack, null);
                } else {
                    Logging.message(player, TextFormatting.RED + "You can only do this on a builder!");
                }
            } else {
                return EnumActionResult.SUCCESS;
            }
        } else if (mode == MODE_CORNER1) {
            GlobalCoordinate currentBlock = getCurrentBlock(stack);
            if (currentBlock.getDimension() != world.provider.getDimension()) {
                Logging.message(player, TextFormatting.RED + "The Builder is in another dimension!");
            } else if (currentBlock.getCoordinate().equals(pos)) {
                Logging.message(player, TextFormatting.RED + "Cleared area selection mode!");
                setMode(stack, MODE_NONE);
            } else {
                Logging.message(player, TextFormatting.GREEN + "Now select the second corner");
                setMode(stack, MODE_CORNER2);
                setCorner1(stack, pos);
            }
        } else {
            GlobalCoordinate currentBlock = getCurrentBlock(stack);
            if (currentBlock.getDimension() != world.provider.getDimension()) {
                Logging.message(player, TextFormatting.RED + "The Builder is in another dimension!");
            } else if (currentBlock.getCoordinate().equals(pos)) {
                Logging.message(player, TextFormatting.RED + "Cleared area selection mode!");
                setMode(stack, MODE_NONE);
            } else {
                NBTTagCompound tag = getCompound(stack);
                BlockPos c1 = getCorner1(stack);
                if (c1 == null) {
                    Logging.message(player, TextFormatting.RED + "Cleared area selection mode!");
                    setMode(stack, MODE_NONE);
                } else {
                    Logging.message(player, TextFormatting.GREEN + "New settings copied to the shape card!");
                    BlockPos center = new BlockPos((int) Math.ceil((c1.getX() + pos.getX()) / 2.0f), (int) Math.ceil((c1.getY() + pos.getY()) / 2.0f), (int) Math.ceil((c1.getZ() + pos.getZ()) / 2.0f));
                    setDimension(stack, Math.abs(c1.getX() - pos.getX()) + 1, Math.abs(c1.getY() - pos.getY()) + 1, Math.abs(c1.getZ() - pos.getZ()) + 1);
                    setOffset(stack, center.getX() - currentBlock.getCoordinate().getX(), center.getY() - currentBlock.getCoordinate().getY(), center.getZ() - currentBlock.getCoordinate().getZ());
                    setMode(stack, MODE_NONE);
                    setCorner1(stack, null);
                    setShape(stack, Shape.SHAPE_BOX, true);
                }
            }
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) BuilderTileEntity(mcjty.rftools.blocks.builder.BuilderTileEntity)

Example 2 with BuilderTileEntity

use of mcjty.rftools.blocks.builder.BuilderTileEntity in project RFTools by McJty.

the class ClientCommandHandler method registerCommands.

public static void registerCommands() {
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_DESTINATION_INFO, (player, arguments) -> {
        MatterTransmitterBlock.setDestinationInfo(arguments.getInt(), arguments.getString());
        return true;
    });
    if (SecurityConfiguration.enabled) {
        McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_SECURITY_NAME, (player, arguments) -> {
            SecurityCardItem.channelNameFromServer = arguments.getString();
            return true;
        });
    }
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_SCAN_DIRTY, (player, arguments) -> {
        ScanDataManagerClient.getScansClient().getOrCreateScan(arguments.getInt()).setDirtyCounter(arguments.getInt());
        return true;
    });
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_ENERGY_CONSUMPTION, (player, arguments) -> {
        GuiLocator.energyConsumption = arguments.getInt();
        return true;
    });
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_STORAGE_INFO, (player, arguments) -> {
        ModularStorageBlock.cntReceived = arguments.getInt();
        ModularStorageBlock.nameModuleReceived = arguments.getString();
        return true;
    });
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_FLASH_ENDERGENIC, (player, arguments) -> {
        BlockPos pos = arguments.getBlockPos();
        TileEntity te = RFTools.proxy.getClientWorld().getTileEntity(pos);
        if (te instanceof EndergenicTileEntity) {
            EndergenicTileEntity tileEntity = (EndergenicTileEntity) te;
            tileEntity.syncCountersFromServer(arguments.getInt(), arguments.getInt());
        }
        return true;
    });
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_POSITION_TO_CLIENT, (player, arguments) -> {
        BlockPos tePos = arguments.getBlockPos();
        BlockPos scanPos = arguments.getBlockPos();
        TileEntity te = RFTools.proxy.getClientWorld().getTileEntity(tePos);
        if (te instanceof BuilderTileEntity) {
            BuilderTileEntity.setScanLocationClient(tePos, scanPos);
        }
        return true;
    });
    McJtyLib.registerClientCommand(RFTools.MODID, CMD_RETURN_COUNTER_INFO, (player, arguments) -> {
        CounterBlock.cntReceived = arguments.getInt();
        return true;
    });
}
Also used : BuilderTileEntity(mcjty.rftools.blocks.builder.BuilderTileEntity) EndergenicTileEntity(mcjty.rftools.blocks.endergen.EndergenicTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) EndergenicTileEntity(mcjty.rftools.blocks.endergen.EndergenicTileEntity) BuilderTileEntity(mcjty.rftools.blocks.builder.BuilderTileEntity)

Aggregations

BuilderTileEntity (mcjty.rftools.blocks.builder.BuilderTileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 EndergenicTileEntity (mcjty.rftools.blocks.endergen.EndergenicTileEntity)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1