Search in sources :

Example 1 with WindowScan

use of com.ldtteam.structurize.client.gui.WindowScan in project Structurize by ldtteam.

the class ItemScanTool method onAirRightClick.

@Override
public ActionResultType onAirRightClick(final BlockPos start, final BlockPos end, final World worldIn, final PlayerEntity playerIn, final ItemStack itemStack) {
    Optional<BlockPos> anchorPos = Optional.empty();
    if (itemStack.getOrCreateTag().contains(NBT_ANCHOR_POS)) {
        final BlockPos anchorBlockPos = NBTUtil.readBlockPos(itemStack.getOrCreateTag().getCompound(NBT_ANCHOR_POS));
        if (BlockPosUtil.isInbetween(anchorBlockPos, start, end)) {
            anchorPos = Optional.of(anchorBlockPos);
            if (worldIn.isClientSide) {
                Settings.instance.setAnchorPos(anchorPos);
            }
        } else {
            if (worldIn.isClientSide) {
                playerIn.sendMessage(new TranslationTextComponent("com.ldtteam.structurize.gui.scantool.outsideanchor"), playerIn.getUUID());
            }
        }
    }
    if (!worldIn.isClientSide) {
        if (playerIn.isShiftKeyDown()) {
            saveStructure(worldIn, start, end, playerIn, null, true, anchorPos);
        }
    } else {
        if (!playerIn.isShiftKeyDown()) {
            final WindowScan window = new WindowScan(start, end, anchorPos);
            window.open();
        }
    }
    return ActionResultType.SUCCESS;
}
Also used : WindowScan(com.ldtteam.structurize.client.gui.WindowScan) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

WindowScan (com.ldtteam.structurize.client.gui.WindowScan)1 BlockPos (net.minecraft.util.math.BlockPos)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1