Skip to content

Commit

Permalink
Fix #2017 Exploit when transferring recipes in containers with locked…
Browse files Browse the repository at this point in the history
… slots
  • Loading branch information
mezz committed Aug 23, 2020
1 parent fc4ea2d commit ed871e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -8,4 +8,4 @@ curse_project_id=238222

version_major=7
version_minor=1
version_patch=1
version_patch=2
Expand Up @@ -40,7 +40,7 @@ public static void setItems(PlayerEntity player, Map<Integer, Integer> slotIdMap
// and a max-transfer operation has been requested by the player.
boolean transferAsCompleteSets = requireCompleteSets || !maxTransfer;

Map<Integer, ItemStack> toTransfer = removeItemsFromInventory(container, slotMap, craftingSlots, inventorySlots, transferAsCompleteSets, maxTransfer);
Map<Integer, ItemStack> toTransfer = removeItemsFromInventory(player, container, slotMap, craftingSlots, inventorySlots, transferAsCompleteSets, maxTransfer);

if (toTransfer.isEmpty()) {
return;
Expand Down Expand Up @@ -98,6 +98,7 @@ public static void setItems(PlayerEntity player, Map<Integer, Integer> slotIdMap

@Nonnull
private static Map<Integer, ItemStack> removeItemsFromInventory(
PlayerEntity player,
Container container,
Map<Integer, ItemStack> required,
List<Integer> craftingSlots,
Expand Down Expand Up @@ -137,7 +138,7 @@ private static Map<Integer, ItemStack> removeItemsFromInventory(
// Locate a slot that has what we need.
final Slot slot = getSlotWithStack(container, requiredStack, craftingSlots, inventorySlots);

boolean itemFound = (slot != null) && !slot.getStack().isEmpty();
boolean itemFound = (slot != null) && !slot.getStack().isEmpty() && slot.canTakeStack(player);
ItemStack resultItemStack = result.get(entry.getKey());
boolean resultItemStackLimitReached = (resultItemStack != null) && (resultItemStack.getCount() == resultItemStack.getMaxStackSize());

Expand Down

0 comments on commit ed871e2

Please sign in to comment.