Skip to content

Commit

Permalink
Use slot.set. Closes #171
Browse files Browse the repository at this point in the history
Signed-off-by: cpw <[email protected]>
  • Loading branch information
cpw committed Jun 17, 2024
1 parent 3856351 commit f375e1b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main/java/cpw/mods/inventorysorter/ScrollWheelHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public enum ScrollWheelHandler implements Consumer<ContainerContext>
{
this.moveAmount = amount;
}
@Nullable

@Override
public void accept(ContainerContext context)
public void accept(@SuppressWarnings("ClassEscapesDefinedScope") ContainerContext context)
{
if (context == null) throw new NullPointerException("WHUT");
// Skip if we can't find ourselves in the mapping table
Expand Down Expand Up @@ -89,7 +89,7 @@ else if (moveAmount > 0)
if (context.player.containerMenu == context.player.inventoryMenu)
{
if (InventoryHandler.preferredOrders.containsKey(context.slotMapping.inv)) {
mappingCandidates.addAll(InventoryHandler.preferredOrders.get(context.slotMapping.inv).stream().map(mapping::get).collect(Collectors.toList()));
mappingCandidates.addAll(InventoryHandler.preferredOrders.get(context.slotMapping.inv).stream().map(mapping::get).toList());
}
Collections.reverse(mappingCandidates);
}
Expand All @@ -110,7 +110,10 @@ else if (moveAmount > 0)
boolean empty = true;
for (ItemStack itemStack : context.player.getInventory().offhand)
{
if (!itemStack.isEmpty()) empty = false;
if (!itemStack.isEmpty()) {
empty = false;
break;
}
}
if (empty) continue;
}
Expand All @@ -135,14 +138,7 @@ else if (ItemStack.isSameItem(itemStack,sourceStack))
if (iscopy.getCount() == 0)
{
sourceStack.grow(-1);
if (sourceStack.getCount() == 0)
{
source.set(ItemStack.EMPTY);
}
else
{
source.setChanged();
}
source.set(sourceStack);
break;
}
}
Expand Down

0 comments on commit f375e1b

Please sign in to comment.