Posted August 14, 20214 yr I've looked at plenty of other people's code as well as the Minecraft code for containers like this and I can't figure this out. When I shift+click the iron ore in my inventory, it fills up the slot in my furnace, but the stack size in my inventory stays what it was if the entire stack couldn't be moved to the furnace. My slots are set up like this: 0-26 is the inner inventory, 27-35 is the hotbar, 36 is the furnace input and 37 is the output. @Override public ItemStack quickMoveStack(PlayerEntity player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.slots.get(index); if(slot != null && slot.hasItem()) { ItemStack stack = slot.getItem(); itemstack = stack.copy(); if(index == 36) { if(!this.moveItemStackTo(stack, 0, 36, true)) { return ItemStack.EMPTY; } slot.onQuickCraft(stack, itemstack); } else { RecipeManager recipeManager = player.level.getRecipeManager(); Inventory input = new Inventory(stack); Optional<FurnaceRecipe> matchingRecipe = recipeManager.getRecipeFor(IRecipeType.SMELTING, input, player.level); if(index == 37) { if(!this.moveItemStackTo(stack, 27, 35, false)) { if(!this.moveItemStackTo(stack, 0, 26, false)) { return ItemStack.EMPTY; } } } else if(matchingRecipe.isPresent()) { if(!this.moveItemStackTo(stack, 36, 37, true)) { if(!this.moveItemStackTo(stack, index, index, false)) { if(!this.moveItemStackTo(stack, 27, 35, false)) { if(!this.moveItemStackTo(stack, 0, 26, false)) { return ItemStack.EMPTY; } } } } } else if(index < 27) { if(!this.moveItemStackTo(stack, 27, 35, false)) { return ItemStack.EMPTY; } } else if(index < 36 && !this.moveItemStackTo(stack, 0, 26, false)) { return ItemStack.EMPTY; } } if(stack.isEmpty()) { slot.set(ItemStack.EMPTY); } else { slot.setChanged(); } if(stack.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, stack); } return itemstack; }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.