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

Fix cast #52

Merged
merged 2 commits into from
Jan 17, 2025
Merged
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
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