Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add craft all functionality #8112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/appeng/client/gui/AEBaseScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ && getEmptyingAction(slot, menu.getCarried()) != null) {
InventoryAction action;
if (hasShiftDown()) {
action = InventoryAction.CRAFT_SHIFT;
} else if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_SPACE)) {
action = InventoryAction.CRAFT_ALL;
} else {
// Craft stack on right-click, craft single on left-click
action = mouseButton == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/helpers/InventoryAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum InventoryAction {
PICKUP_OR_SET_DOWN, SPLIT_OR_PLACE_SINGLE, CREATIVE_DUPLICATE, SHIFT_CLICK,

// crafting term
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT, CRAFT_ALL,

// fluid term
FILL_ITEM, FILL_ITEM_MOVE_TO_PLAYER, FILL_ENTIRE_ITEM, FILL_ENTIRE_ITEM_MOVE_TO_PLAYER, EMPTY_ITEM,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/appeng/menu/AEBaseMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ public void doAction(ServerPlayer player, InventoryAction action, int slot, long
if (s instanceof CraftingTermSlot) {
switch (action) {
case CRAFT_SHIFT:
case CRAFT_ALL:
case CRAFT_ITEM:
case CRAFT_STACK:
((CraftingTermSlot) s).doClick(action, player);
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/appeng/menu/slot/CraftingTermSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingInput;
Expand Down Expand Up @@ -97,10 +98,17 @@ public void doClick(InventoryAction action, Player who) {

int maxTimesToCraft;
InternalInventory target;
if (action == InventoryAction.CRAFT_SHIFT) // craft into player inventory...
if (action == InventoryAction.CRAFT_SHIFT || action == InventoryAction.CRAFT_ALL) // craft into player
// inventory...
{
target = new PlayerInternalInventory(who.getInventory());
maxTimesToCraft = (int) Math.floor((double) this.getItem().getMaxStackSize() / (double) howManyPerCraft);
if (action == InventoryAction.CRAFT_SHIFT) {
maxTimesToCraft = (int) Math
.floor((double) this.getItem().getMaxStackSize() / (double) howManyPerCraft);
} else {
maxTimesToCraft = (int) Math.floor((double) this.getItem().getMaxStackSize() / (double) howManyPerCraft
* Inventory.INVENTORY_SIZE);
}
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack
{
target = new CarriedItemInventory(getMenu());
Expand Down