level terminal

This commit is contained in:
lc_1337 committed 2025-10-23 15:08:43 +03:00
1 parent 461d574a54
commit b9860934ee
13 files changed
+111 -236

No files matched your search

@@ -2,103 +2,47 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.util.Util;
import appeng.api.util.DimensionalCoord;
import appeng.client.gui.IGuiSub;
import appeng.client.gui.implementations.GuiLevelEmitter;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.parts.automation.PartLevelEmitter;
import appeng.container.IContainerSubGui;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.ILevelEmitter;
public class GuiLevelEmitterProxy extends GuiLevelEmitter {
public class GuiLevelEmitterProxy extends GuiLevelEmitter implements IGuiSub {
protected GuiType originalGui;
protected Util.DimensionalCoordSide originalBlockPos;
protected ItemStack originalGuiIcon;
protected GuiTabButton originalGuiBtn;
protected final IContainerSubGui container;
protected GuiTabButton originalGuiBtn;;
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final PartLevelEmitter te) {
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final ILevelEmitter te) {
super(inventoryPlayer, te);
if (inventoryPlayer.player.openContainer instanceof AEBaseContainer container) {
var target = container.getTarget();
if (target instanceof PartLevelTerminal terminal) {
originalGuiIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
originalBlockPos = new Util.DimensionalCoordSide(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
terminal.getSide(),
"");
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
originalGuiIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
inventoryPlayer.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
originalGuiIcon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
inventoryPlayer.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
}
}
this.container = (IContainerSubGui) inventorySlots;
this.container.setGuiLink(this);
}
@Override
public void initGui() {
super.initGui();
if (container.getPrimaryGuiIcon() != null) initPrimaryGuiButton();
}
if (this.originalGuiIcon != null) {
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.originalGuiIcon,
this.originalGuiIcon.getDisplayName(),
itemRender);
this.originalGuiBtn.setHideEdge(13);
this.buttonList.add(originalGuiBtn);
}
public void initPrimaryGuiButton() {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + this.xSize - 57,
this.guiTop,
container.getPrimaryGuiIcon(),
container.getPrimaryGuiIcon().getDisplayName(),
itemRender));
}
@Override
protected void actionPerformed(GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
CPacketLevelTerminalCommands.Action.BACK,
originalBlockPos.x,
originalBlockPos.y,
originalBlockPos.z,
originalBlockPos.getDimension(),
originalBlockPos.getSide());
message.setOriginalGui(originalGui.ordinal());
FluidCraft.proxy.netHandler.sendToServer(message);
} else {
super.actionPerformed(btn);
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
}
}
}
@@ -52,6 +52,7 @@ import appeng.api.config.TerminalFontSize;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEStack;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
@@ -74,7 +75,6 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.Loader;
public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextField, IGuiTooltipHandler {
@@ -544,7 +544,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
&& relMouseY >= Math.max(viewY + rowYTop, LevelTerminalSection.TITLE_HEIGHT)
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (info != null) {
ItemStack itemStack = info.stack;
IAEStack<?> aes = info.stack;
long quantity = info.quantity;
long batch = info.batchSize;
LevelState state = info.state;
@@ -553,10 +553,10 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemStack.stackSize = 0;
aes.setStackSize(1);
renderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
renderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
renderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aes.drawInGui(mc, 0, 0);
aes.drawOverlayInGui(mc, 0, 0, false, false, false, false);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
int color = switch (state) {
case Idle -> FCGuiColors.StateIdle.getColor();
@@ -584,7 +584,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
}
} else {
tooltipStack = itemStack;
tooltipStack = Platform.stackConvert(aes).getItemStack();
}
GL11.glPopMatrix();
} else if (entry.filteredRecipes[slotIdx]) {
@@ -1105,7 +1105,9 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
continue;
}
if (itemStackMatchesSearchTerm(entry.infoList[i].stack, output)) {
if (itemStackMatchesSearchTerm(
Platform.stackConvert(entry.infoList[i].stack).getItemStack(),
output)) {
shouldAdd = true;
entry.filteredRecipes[i] = false;
} else {
@@ -1234,10 +1236,15 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
blockPos.getDimension(),
blockPos.getSide()));
} else if (isShiftKeyDown()) {
/*
* FluidCraft.proxy.netHandler.sendToServer( new CPacketRenamer( blockPos.x, blockPos.y, blockPos.z,
* blockPos.getDimension(), blockPos.getSide()));
*/
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelTerminalCommands(
Action.RENAME,
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
blockPos.getSide()));
} else {
BlockPosHighlighter.highlightBlocks(
mc.thePlayer,
@@ -1274,7 +1281,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
};
if (action != null && this.infoList[slotIdx] != null) {
AEItemStack aeStack = AEItemStack.create(this.infoList[slotIdx].stack);
IAEStack<?> aeStack = this.infoList[slotIdx].stack;
((AEBaseContainer) inventorySlots).setTargetStack(aeStack);
// FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, slotIdx, 0,
// aeStack));
@@ -15,7 +15,7 @@ import com.glodblock.github.util.NameConst;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiSub;
import appeng.client.gui.GuiSub;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.MEGuiTextField;
@@ -9,7 +9,6 @@ import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
@@ -155,7 +154,7 @@ public class ContainerLevelTerminal extends FCBaseContainer {
knownTracker.infoList[i] = null;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, null);
} else if (!ItemStack.areItemStacksEqual(prev[i].stack, curr[i].stack)
} else if (!Platform.isStacksIdentical(prev[i].stack, curr[i].stack)
|| prev[i].quantity == curr[i].quantity
|| prev[i].batchSize == curr[i].batchSize
|| prev[i].state == curr[i].state) {