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));
}
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;
}
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);
}
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);
}
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);
}
Aggregations