Skip to content

Commit

Permalink
Fix cast (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
0hwx authored Jan 17, 2025
1 parent 79fc1e0 commit e8018dc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/com/cleanroommc/bogosorter/BogoSortAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.cleanroommc.bogosorter.common.sort.NbtSortRule;
import com.cleanroommc.bogosorter.compat.loader.Mods;
import com.cleanroommc.modularui.factory.ClientGUI;
import com.cleanroommc.modularui.utils.item.IItemHandler;
import com.cleanroommc.modularui.utils.item.PlayerInvWrapper;
import com.cleanroommc.modularui.utils.item.PlayerMainInvWrapper;
import com.cleanroommc.modularui.utils.item.SlotItemHandler;
Expand Down Expand Up @@ -290,19 +291,21 @@ public static boolean isPlayerSlot(Slot slot) {
public static boolean isPlayerSlot(ISlot slot) {
if (slot == null) return false;
if (slot.bogo$getInventory() instanceof InventoryPlayer
|| (slot instanceof SlotItemHandler
&& isPlayerInventory((IInventory) ((SlotItemHandler) slot).getItemHandler()))
|| (Mods.Ae2.isLoaded() && slot instanceof AppEngSlot
&& isPlayerInventory(((AppEngSlot) slot).inventory))) {
|| (slot instanceof SlotItemHandler handler && isPlayerInventory(handler.getItemHandler()))
|| (Mods.Ae2.isLoaded() && slot instanceof AppEngSlot AppEng && isPlayerInventory(AppEng.inventory))) {
return slot.bogo$getSlotIndex() >= 0 && slot.bogo$getSlotIndex() < 36;
}
return false;
}

public static boolean isPlayerInventory(IInventory itemHandler) {
public static boolean isPlayerInventory(IItemHandler itemHandler) {
return itemHandler instanceof PlayerMainInvWrapper || itemHandler instanceof PlayerInvWrapper;
}

public static boolean isPlayerInventory(IInventory itemHandler) {
return itemHandler instanceof InventoryPlayer;
}

public static final Hash.Strategy<ItemStack> ITEM_META_NBT_HASH_STRATEGY = new Hash.Strategy<ItemStack>() {

@Override
Expand Down

0 comments on commit e8018dc

Please sign in to comment.