public ItemStack func_174894_a(ItemStack p_174894_1_) { ItemStack itemstack1 = p_174894_1_.copy(); for (int i = 0; i < this.slotsCount; ++i) { ItemStack itemstack2 = this.getStackInSlot(i); if (itemstack2 == null) { this.setInventorySlotContents(i, itemstack1); this.markDirty(); return null; } if (ItemStack.areItemsEqual(itemstack2, itemstack1)) { int j = Math.min(this.getInventoryStackLimit(), itemstack2.getMaxStackSize()); int k = Math.min(itemstack1.stackSize, j - itemstack2.stackSize); if (k > 0) { itemstack2.stackSize += k; itemstack1.stackSize -= k; if (itemstack1.stackSize <= 0) { this.markDirty(); return null; } } } } if (itemstack1.stackSize != p_174894_1_.stackSize) { this.markDirty(); } return itemstack1; }
public ItemStack func_174894_a(ItemStack p_174894_1_) { ItemStack var2 = p_174894_1_.copy(); for (int var3 = 0; var3 < this.slotsCount; ++var3) { ItemStack var4 = this.getStackInSlot(var3); if (var4 == null) { this.setInventorySlotContents(var3, var2); this.markDirty(); return null; } if (ItemStack.areItemsEqual(var4, var2)) { int var5 = Math.min(this.getInventoryStackLimit(), var4.getMaxStackSize()); int var6 = Math.min(var2.stackSize, var5 - var4.stackSize); if (var6 > 0) { var4.stackSize += var6; var2.stackSize -= var6; if (var2.stackSize <= 0) { this.markDirty(); return null; } } } } if (var2.stackSize != p_174894_1_.stackSize) { this.markDirty(); } return var2; }
@SubscribeEvent public void onInteract(PlayerInteractEvent.RightClickBlock event) { // does the player clicks on an echanting table with moss with 5 levels? if (ItemStack.areItemsEqual(event.getItemStack(), TinkerCommons.matMoss)) { if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.BOOKSHELF) { if (event.getEntityPlayer().experienceLevel >= ModMendingMoss.MENDING_MOSS_LEVELS) { // convert moss to mending moss EntityPlayer player = event.getEntityPlayer(); player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f); if (!event.getWorld().isRemote) { event.getItemStack().stackSize--; player.removeExperienceLevel(ModMendingMoss.MENDING_MOSS_LEVELS); ItemHandlerHelper.giveItemToPlayer(player, TinkerCommons.matMendingMoss.copy()); event.setUseBlock(Event.Result.DENY); event.setUseItem(Event.Result.DENY); event.setCanceled(true); } } } } }