Skip to content

Commit

Permalink
Fix crash extracting items in certain scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
jaquadro committed Jul 10, 2017
1 parent 2f3342f commit 7fd506b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G

minecraft_base_version=1.12
minecraft_version=1.12
mod_version=5.2.6
mod_version=5.2.7
chameleon_version=4.1.0
chameleon_max_version=5.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,28 +746,30 @@ public ItemStack extractItem (@Nonnull ItemStack stack, int amount, boolean simu
Set<Integer> checkedSlots = (simulate) ? new HashSet<>() : null;

int remaining = amount;
for (SlotRecord record : primaryRecords) {
IDrawerGroup candidateGroup = getGroupForSlotRecord(record);
if (candidateGroup == null)
continue;
if (primaryRecords != null) {
for (SlotRecord record : primaryRecords) {
IDrawerGroup candidateGroup = getGroupForSlotRecord(record);
if (candidateGroup == null)
continue;

IDrawer drawer = candidateGroup.getDrawer(record.slot);
if (!drawer.isEnabled())
continue;
if (!testPredicateExtract(drawer, stack, predicate))
continue;
if (!hasAccess(candidateGroup, drawer))
continue;
IDrawer drawer = candidateGroup.getDrawer(record.slot);
if (!drawer.isEnabled())
continue;
if (!testPredicateExtract(drawer, stack, predicate))
continue;
if (!hasAccess(candidateGroup, drawer))
continue;

remaining = (simulate)
? Math.max(remaining - drawer.getStoredItemCount(), 0)
: drawer.adjustStoredItemCount(-remaining);
remaining = (simulate)
? Math.max(remaining - drawer.getStoredItemCount(), 0)
: drawer.adjustStoredItemCount(-remaining);

if (remaining == 0)
return stackResult(stack, amount);
if (remaining == 0)
return stackResult(stack, amount);

if (simulate)
checkedSlots.add(record.index);
if (simulate)
checkedSlots.add(record.index);
}
}

for (int slot : drawerSlots) {
Expand Down

0 comments on commit 7fd506b

Please sign in to comment.