@Override public boolean matches(InventoryCrafting inventory, World world) { ItemStack golden = ItemStack.EMPTY; int enderCount = 0; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if (stack.isEmpty()) continue; Item item = stack.getItem(); if (item instanceof ItemGoldenEye) golden = stack; else if (item instanceof ItemEnderPearl) enderCount++; else return false; } return !golden.isEmpty() && enderCount > 0 && golden.getItemDamage() - enderCount * PEARL_RECHARGE >= 0; }
@Override @Nonnull public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack golden = ItemStack.EMPTY; int enderCount = 0; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if (stack.isEmpty()) continue; Item item = stack.getItem(); if (item instanceof ItemGoldenEye) golden = stack; else if (item instanceof ItemEnderPearl) enderCount++; } if (golden.isEmpty()) return ItemStack.EMPTY; ItemStack result = golden.copy(); result.setItemDamage(golden.getItemDamage() - enderCount * PEARL_RECHARGE); return result; }
public boolean isThrowable() { if (item instanceof ItemBow || item instanceof ItemSnowball || item instanceof ItemEgg || item instanceof ItemEnderPearl || item instanceof ItemSplashPotion || item instanceof ItemLingeringPotion || item instanceof ItemFishingRod) { return true; } return false; }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack itemStack = null; Slot slotObject = (Slot) this.inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); itemStack = stackInSlot.copy(); if (slot <= 0) { if (!this.mergeItemStack(stackInSlot, 1, 37, true)) { return null; } } else { if (stackInSlot != null && stackInSlot.getItem() instanceof ItemEnderPearl) { if (!this.mergeItemStack(stackInSlot, 0, 1, false)) { return null; } } } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == itemStack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return itemStack; }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { ItemStack stack = playerIn.getHeldItem(hand); if (playerIn.isSneaking() && hand == EnumHand.MAIN_HAND) { /* } for (int i = 0; i < 5; ++i) { RayTraceResult rayTrace = playerIn.rayTrace(i, 1.0F); if (rayTrace != null) { BlockPos pos = rayTrace.getBlockPos(); EnumFacing side = rayTrace.sideHit; float hitX = (float) rayTrace.hitVec.xCoord; float hitY = (float) rayTrace.hitVec.yCoord; float hitZ = (float) rayTrace.hitVec.zCoord; IBlockState state = worldIn.getBlockState(pos); Block block = state.getBlock(); boolean flag = block.onBlockActivated(worldIn, pos, state, playerIn, hand, itemStackIn, side, hitX, hitY, hitZ); if (rayTrace.getBlockPos() != null && (flag || block != Blocks.AIR || block instanceof ITileEntityProvider || (!flag && block.hasTileEntity(state)))) { if (rayTrace.getBlockPos() != null && (block != Blocks.AIR || block instanceof ITileEntityProvider || block.hasTileEntity(state))) { return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn); } } } */ ModGuiHandler.launchGui(GUIType.DANKNULL, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); } else { if (!worldIn.isRemote) { InventoryDankNull inventory = new InventoryDankNull(stack); ItemStack selectedStack = DankNullUtils.getSelectedStack(inventory); if ((selectedStack.getItem() instanceof ItemSnowball) || (selectedStack.getItem() instanceof ItemEnderPearl) || (selectedStack.getItem() instanceof ItemEgg)) { //TODO soon! return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); } EntityPFakePlayer fakePlayer = EntityPFakePlayer.getFakePlayerForParent(playerIn); if (fakePlayer.interactionManager.getGameType() != GameType.NOT_SET) { fakePlayer.interactionManager.setGameType(GameType.NOT_SET); } fakePlayer.setHeldItem(EnumHand.MAIN_HAND, selectedStack); fakePlayer.setItemInHand(selectedStack); fakePlayer.posX = playerIn.posX; fakePlayer.posY = playerIn.posY; fakePlayer.posZ = playerIn.posZ; fakePlayer.setRotationYawHead(playerIn.rotationYawHead); fakePlayer.rotationYaw = playerIn.rotationYaw; fakePlayer.rotationPitch = playerIn.rotationPitch; fakePlayer.eyeHeight = playerIn.eyeHeight; if (selectedStack.copy().getItem().onItemRightClick(worldIn, fakePlayer, hand).getType() == EnumActionResult.SUCCESS) { DankNullUtils.decrSelectedStackSize(inventory, 0); } return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
private boolean isThrowable(Item item) { return item instanceof ItemBow || item instanceof ItemSnowball || item instanceof ItemEgg || item instanceof ItemEnderPearl; }
@Override public boolean isItemValidForSlot(int slot, ItemStack item) { return item != null && item.getItem() instanceof ItemEnderPearl; }
private int getPearls() { ItemStack pearls = (ItemStack) this.inventorySlots.getInventory().get(0); return pearls != null && pearls.getItem() instanceof ItemEnderPearl ? pearls.stackSize : 0; }
@Override public boolean isItemValid(ItemStack stack) { return stack != null && stack.getItem() instanceof ItemEnderPearl; }