Search in sources :

Example 6 with PlayerInventoryHolder

use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.

the class MonitorPluginBaseBehavior method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        if (hand != EnumHand.MAIN_HAND)
            return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
        ItemStack itemStack = player.getHeldItem(hand);
        MonitorPluginBaseBehavior behavior = getBehavior(itemStack);
        if (behavior != null && behavior.hasUI()) {
            PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
            holder.openUI();
            return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
        }
    }
    return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
Also used : PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) ItemStack(net.minecraft.item.ItemStack)

Example 7 with PlayerInventoryHolder

use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.

the class TerminalBehaviour method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (player.isSneaking()) {
        ItemStack itemStack = player.getHeldItem(hand);
        itemStack.getOrCreateSubCompound("terminal").removeTag("_click");
        if (pos != null) {
            itemStack.getOrCreateSubCompound("terminal").setTag("_click", NBTUtil.createPosTag(pos));
            if (!world.isRemote) {
                PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
                holder.openUI();
            }
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.PASS;
}
Also used : PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) ItemStack(net.minecraft.item.ItemStack)

Example 8 with PlayerInventoryHolder

use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.

the class ProspectorScannerBehavior method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, EnumHand hand) {
    ItemStack heldItem = player.getHeldItem(hand);
    if (!world.isRemote) {
        if (player.isSneaking()) {
            ItemStack stack = player.getHeldItem(hand);
            int mode = getMode(stack);
            int nextMode = getNextMode(mode);
            if (nextMode == WidgetProspectingMap.FLUID_PROSPECTING_MODE) {
                if (tier >= FLUID_PROSPECTION_THRESHOLD) {
                    setMode(stack, nextMode);
                    player.sendStatusMessage(new TextComponentTranslation("metaitem.prospector.mode.fluid"), true);
                }
            } else {
                setMode(stack, nextMode);
                player.sendStatusMessage(new TextComponentTranslation("metaitem.prospector.mode.ores"), true);
            }
        } else if (checkCanUseScanner(heldItem, player, true)) {
            new PlayerInventoryHolder(player, hand).openUI();
        } else {
            player.sendMessage(new TextComponentTranslation("behavior.prospector.not_enough_energy"));
        }
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, heldItem);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) ItemStack(net.minecraft.item.ItemStack)

Example 9 with PlayerInventoryHolder

use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.

the class TerminalBehaviour method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    itemStack.getOrCreateSubCompound("terminal").removeTag("_click");
    if (!world.isRemote) {
        PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
        holder.openUI();
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
}
Also used : PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) ItemStack(net.minecraft.item.ItemStack)

Example 10 with PlayerInventoryHolder

use of gregtech.api.items.gui.PlayerInventoryHolder in project GregTech by GregTechCEu.

the class ClipboardBehavior method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack heldItem = player.getHeldItem(hand);
    if (!world.isRemote && RayTracer.retrace(player).typeOfHit != RayTraceResult.Type.BLOCK) {
        // So that the player doesn't place a clipboard before suddenly getting the GUI
        PlayerInventoryHolder holder = new PlayerInventoryHolder(player, hand);
        holder.openUI();
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, heldItem);
}
Also used : PlayerInventoryHolder(gregtech.api.items.gui.PlayerInventoryHolder) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PlayerInventoryHolder (gregtech.api.items.gui.PlayerInventoryHolder)10 ItemStack (net.minecraft.item.ItemStack)10 RayTracer (codechicken.lib.raytracer.RayTracer)3 ModularUI (gregtech.api.gui.ModularUI)3 IItemBehaviour (gregtech.api.items.metaitem.stats.IItemBehaviour)3 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Block (net.minecraft.block.Block)3 IBlockState (net.minecraft.block.state.IBlockState)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 EnumFacing (net.minecraft.util.EnumFacing)3 EnumHand (net.minecraft.util.EnumHand)3 BlockPos (net.minecraft.util.math.BlockPos)3 World (net.minecraft.world.World)3 GuiTextures (gregtech.api.gui.GuiTextures)2 ClickButtonWidget (gregtech.api.gui.widgets.ClickButtonWidget)2 ImageCycleButtonWidget (gregtech.api.gui.widgets.ImageCycleButtonWidget)2 SimpleTextWidget (gregtech.api.gui.widgets.SimpleTextWidget)2