Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.