Fix crash when trying to open wireless magnet filter when terminal in baubles (#404)

This commit is contained in:
lc-1337 authored and GitHub committed 2026-02-16 13:49:02 +01:00
1 parent 59e596b0ba
commit 62117facd5
6 files changed
+16 -53

No files matched your search

@@ -73,17 +73,15 @@ public final class Util {
public static int drainItemPower(AEBaseContainer c, InventoryPlayer ip, int slot, int ticks, double pm,
IFluidPortableCell wt) {
if (slot != -1) {
final ItemStack currentItem = getWirelessTerminal(ip.player, slot);
final ItemStack currentItem = Platform.getItemFromPlayerInventoryBySlotIndex(ip.player, slot);
if (wt != null) {
if (currentItem != wt.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
if (GuiHelper.decodeInvType(slot).getLeft() == GuiHelper.InvType.PLAYER_INV) {
if (slot <= Platform.baublesSlotsOffset) {
ip.setInventorySlotContents(slot, wt.getItemStack());
} else {
BaublesApi.getBaubles(ip.player).setInventorySlotContents(
GuiHelper.decodeInvType(slot).getRight(),
wt.getItemStack());
BaublesApi.getBaubles(ip.player).setInventorySlotContents(slot, wt.getItemStack());
}
} else {
c.setValidContainer(false);
@@ -193,15 +191,6 @@ public final class Util {
return new NullInventory<>();
}
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
ImmutablePair<GuiHelper.InvType, Integer> result = GuiHelper.decodeInvType(x);
if (result.getLeft() == GuiHelper.InvType.PLAYER_INV) {
return player.inventory.getStackInSlot(result.getRight());
} else {
return BaublesApi.getBaubles(player).getStackInSlot(result.getRight());
}
}
public static ImmutablePair<Integer, ItemStack> getUltraWirelessTerm(EntityPlayer player) {
int invSize = player.inventory.getSizeInventory();
@@ -222,7 +211,7 @@ public final class Util {
for (int i = 0; i < invSize; ++i) {
ItemStack is = handler.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
return new ImmutablePair<>(GuiHelper.encodeType(i, GuiHelper.InvType.PLAYER_BAUBLES), is);
return new ImmutablePair<>(i + Platform.baublesSlotsOffset, is);
}
}
}
@@ -470,13 +459,6 @@ public final class Util {
return value | (type.ordinal() << 29) | y;
}
public static int encodeType(int x, InvType type) {
if (Math.abs(x) > (1 << 28)) {
throw new IllegalArgumentException("out of range");
}
return value | (type.ordinal() << 29) | x;
}
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
if (Math.abs(y) > (1 << 28)) {
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
@@ -484,14 +466,6 @@ public final class Util {
return new ImmutablePair<>(GuiType.TILE, y);
}
}
public static ImmutablePair<InvType, Integer> decodeInvType(int x) {
if (Math.abs(x) > (1 << 28)) {
return new ImmutablePair<>(InvType.values()[x >> 29 & 1], x - (3 << 29 & x));
} else {
return new ImmutablePair<>(InvType.PLAYER_INV, x);
}
}
}
public static int clamp(int value, int min, int max) {