This commit is contained in:
lc-1337 committed 2026-02-11 20:15:18 +02:00
1 parent 38f3042711
commit 377c048ef8
3 files changed
+8 -37

No files matched your search

@@ -9,6 +9,7 @@ import com.glodblock.github.util.Util;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.util.Platform;
public abstract class FCBaseContainer extends AEBaseContainer {
@@ -37,7 +38,7 @@ public abstract class FCBaseContainer extends AEBaseContainer {
if (isWirelessTerminal()) {
if (this.host instanceof IFluidPortableCell) {
final int slotIndex = ((IFluidPortableCell) this.host).getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
if (slotIndex <= Platform.baublesSlotsOffset) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
@@ -2,7 +2,6 @@ package com.glodblock.github.common.item;
import static appeng.util.Platform.baublesSlotsOffset;
import static appeng.util.Platform.nextEnum;
import static com.glodblock.github.util.Util.GuiHelper.decodeInvType;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.Arrays;
@@ -138,8 +137,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
private void openGui(final ItemStack is, final World w, final EntityPlayer player, final Object mode,
final int slotIndex) {
final GuiBridge aeGui;
final int slot = slotIndex == Integer.MIN_VALUE ? player.inventory.currentItem : slotIndex;
final ImmutablePair<Util.GuiHelper.InvType, Integer> invSlotPair = decodeInvType(slotIndex);
final int slot = slotIndex == Integer.MIN_VALUE ? player.inventory.currentItem : slotIndex;;
switch (mode instanceof UltraTerminalModes utm ? utm : getMode(is)) {
case CRAFTING -> aeGui = GuiBridge.GUI_CRAFTING_TERMINAL;
@@ -161,13 +159,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
default -> aeGui = GuiBridge.GUI_ME;
}
Platform.openGUI(
player,
null,
null,
aeGui,
invSlotPair.getLeft() == Util.GuiHelper.InvType.PLAYER_INV ? slotIndex
: invSlotPair.getRight() + baublesSlotsOffset);
Platform.openGUI(player, null, null, aeGui, slotIndex);
}
@Override
@@ -191,12 +183,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
if (handler != null) {
for (int i = 0; i < handler.getSizeInventory(); ++i) {
if (handler.getStackInSlot(i) == itemStack) {
onUpdate(
itemStack,
null,
player,
Util.GuiHelper.encodeType(i, Util.GuiHelper.InvType.PLAYER_BAUBLES),
false);
onUpdate(itemStack, null, player, i + baublesSlotsOffset, false);
}
}
}
@@ -78,12 +78,10 @@ public final class Util {
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);
@@ -213,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);
}
}
}
@@ -461,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));
@@ -475,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) {