mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 09:34:42 +00:00
Fix LevelTerminal data recursion and few in fixes gui
This commit is contained in:
1 parent
cbc113d160
commit
be752e8aee
7 files changed
+75
-30
No files matched your search
@@ -218,7 +218,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
protected void repositionSlots() {
|
||||
for (final Object obj : this.inventorySlots.inventorySlots) {
|
||||
if (obj instanceof final AppEngSlot slot) {
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.FCGuiColors;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
@@ -46,7 +45,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
@@ -64,7 +62,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final ContainerLevelMaintainer cont;
|
||||
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private FCGuiTextField input;
|
||||
private int lastWorkingTick;
|
||||
private int refreshTick;
|
||||
@@ -219,7 +216,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
public boolean drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotFake) {
|
||||
IAEItemStack stack = ((SlotFluidConvertingFake) slot).getAeStack();
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
super.func_146977_a(new SlotSingleItem(slot));
|
||||
if (stack == null) return true;
|
||||
IAEItemStack fake = stack.copy();
|
||||
@@ -228,16 +224,17 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
} else {
|
||||
fake.setStackSize(0);
|
||||
}
|
||||
float lastZLevel = this.zLevel;
|
||||
this.zLevel = 0f;
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
stackSizeRenderer.setAeStack(fake);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
fake.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
this.zLevel = lastZLevel;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -51,7 +51,6 @@ import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands.Action;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.FCGuiColors;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -69,7 +68,6 @@ import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.client.render.BlockPosHighlighter;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
@@ -95,7 +93,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_terminal.png");
|
||||
protected int offsetY;
|
||||
private static final int offsetX = 21;
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
protected static String searchFieldOutputsText = "";
|
||||
protected static String searchFieldNamesText = "";
|
||||
protected static String currentMode = "OFF";
|
||||
@@ -497,6 +494,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
int relY = 0;
|
||||
final int slotLeftMargin = (VIEW_WIDTH - entry.rowSize * 18);
|
||||
float lastZLevel = aeRenderItem.zLevel;
|
||||
|
||||
entry.dispY = viewY;
|
||||
/* PASS 1: BG */
|
||||
@@ -572,6 +570,9 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
if (stack != null) {
|
||||
|
||||
NBTTagCompound data = stack.getTagCompound();
|
||||
ItemStack itemStack = data.hasKey(TLMTags.Stack.tagName)
|
||||
? ItemStack.loadItemStackFromNBT(data.getCompoundTag(TLMTags.Stack.tagName))
|
||||
: stack.copy();
|
||||
long quantity = data.getLong(TLMTags.Quantity.tagName);
|
||||
long batch = data.getLong(TLMTags.Batch.tagName);
|
||||
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
|
||||
@@ -581,16 +582,16 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
stackSizeRenderer.zLevel = 3.0f - 50.0f;
|
||||
stackSizeRenderer.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), stack, 0, 0);
|
||||
stackSizeRenderer.zLevel = 0.0f;
|
||||
aeRenderItem.zLevel = 3.0f - 50.0f;
|
||||
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
|
||||
aeRenderItem.zLevel = 0.0f;
|
||||
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
|
||||
stack.stackSize = (int) quantity;
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack, 0, 0);
|
||||
itemStack.stackSize = (int) quantity;
|
||||
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
|
||||
if (batch > 0) {
|
||||
stack.stackSize = (int) batch;
|
||||
stackSizeRenderer
|
||||
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack, 0, -11);
|
||||
itemStack.stackSize = (int) batch;
|
||||
aeRenderItem
|
||||
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11);
|
||||
}
|
||||
int color = switch (state) {
|
||||
case Idle -> FCGuiColors.StateIdle.getColor();
|
||||
@@ -635,6 +636,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
}
|
||||
}
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
aeRenderItem.zLevel = lastZLevel;
|
||||
return relY + 1;
|
||||
}
|
||||
|
||||
|
||||
+15
-6
@@ -126,12 +126,21 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
|
||||
public static ItemStack createLevelValues(ItemStack itemStack) {
|
||||
var data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
|
||||
var itemStackTag = new NBTTagCompound();
|
||||
itemStack.writeToNBT(itemStackTag);
|
||||
data.setTag(TLMTags.Stack.tagName, itemStackTag);
|
||||
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
|
||||
data.setLong(TLMTags.Batch.tagName, 0);
|
||||
data.setBoolean(TLMTags.Enable.tagName, false);
|
||||
if (!data.hasKey(TLMTags.Stack.tagName)) {
|
||||
var itemStackTag = new NBTTagCompound();
|
||||
itemStack.copy().writeToNBT(itemStackTag);
|
||||
data.setTag(TLMTags.Stack.tagName, itemStackTag);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Quantity.tagName)) {
|
||||
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Batch.tagName)) {
|
||||
data.setLong(TLMTags.Batch.tagName, 0);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Enable.tagName)) {
|
||||
data.setBoolean(TLMTags.Enable.tagName, false);
|
||||
}
|
||||
|
||||
data.setInteger(TLMTags.State.tagName, State.None.ordinal());
|
||||
itemStack.setTagCompound(data);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
}
|
||||
valid.add(i);
|
||||
}
|
||||
if (valid.size() > 0) {
|
||||
if (!valid.isEmpty()) {
|
||||
int[] validIndices = Ints.toArray(valid);
|
||||
NBTTagList tag = new NBTTagList();
|
||||
for (int i = 0; i < valid.size(); ++i) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
@@ -49,6 +51,7 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@@ -296,6 +299,27 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public void readFromNBTEvent(NBTTagCompound data) {
|
||||
if (data.hasKey(TLMTags.RequestStacks.tagName)) {
|
||||
requests.requestStacks.readFromNbt(data, TLMTags.RequestStacks.tagName);
|
||||
if (Platform.isServer()) {
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
if (requests.requestStacks.getStack(i) != null) {
|
||||
ItemStack storageStack = requests.requestStacks.getStack(i).getItemStack();
|
||||
ItemStack itemStack = loadItemStackFromTag(storageStack);
|
||||
ItemStack craftStack = removeRecursion(storageStack);
|
||||
if (!ItemStack.areItemStacksEqual(itemStack, craftStack)) {
|
||||
requests.updateStack(i, craftStack);
|
||||
AELog.info(
|
||||
"[TileLevelMaintainer] Replace craft stack from: " + itemStack.toString()
|
||||
+ ":"
|
||||
+ (itemStack.hasTagCompound() ? itemStack.getTagCompound() : "{no tags}")
|
||||
+ "; with: "
|
||||
+ craftStack
|
||||
+ ":"
|
||||
+ (craftStack.hasTagCompound() ? craftStack.getTagCompound()
|
||||
: "{no tags}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Migration from old data storage
|
||||
long[] batches = new long[REQ_COUNT];
|
||||
@@ -323,6 +347,18 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack removeRecursion(ItemStack itemStack) {
|
||||
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
|
||||
return removeRecursion(loadItemStackFromTag(itemStack));
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack loadItemStackFromTag(ItemStack itemStack) {
|
||||
return ItemStack.loadItemStackFromNBT(itemStack.getTagCompound().getCompoundTag(TLMTags.Stack.tagName));
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream(final ByteBuf data) {
|
||||
final boolean oldPower = isPowered;
|
||||
@@ -571,8 +607,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public IAEItemStack getCraftItem(int idx) {
|
||||
IAEItemStack is = requestStacks.getStack(idx);
|
||||
if (is == null) return null;
|
||||
ItemStack qis = ItemStack
|
||||
.loadItemStackFromNBT(is.getItemStack().getTagCompound().getCompoundTag(TLMTags.Stack.tagName));
|
||||
ItemStack qis = loadItemStackFromTag(is.getItemStack());
|
||||
IAEItemStack qais = AEItemStack.create(qis);
|
||||
qais.setStackSize(getBatchSize(idx));
|
||||
|
||||
|
||||
+5
-3
@@ -33,11 +33,13 @@ public class PartLevelEmitterAdapter implements ILevelViewable, ILevelViewableAd
|
||||
};
|
||||
|
||||
@NotNull
|
||||
static public IInventory getPatchedInventory(IInventory inventory, long value, State state) {
|
||||
static public IInventory getPatchedInventory(IInventory inventory, long quantity, State state) {
|
||||
ItemStack itemStack = inventory.getStackInSlot(SLOT_IN).copy();
|
||||
NBTTagCompound data = !itemStack.hasTagCompound() ? new NBTTagCompound() : itemStack.getTagCompound();
|
||||
data.setLong(TLMTags.Quantity.tagName, value);
|
||||
data.setInteger(TLMTags.State.tagName, state.ordinal());
|
||||
if (!data.hasKey(TLMTags.Quantity.tagName) || data.getLong(TLMTags.Quantity.tagName) != quantity)
|
||||
data.setLong(TLMTags.Quantity.tagName, quantity);
|
||||
if (!data.hasKey(TLMTags.State.tagName) || data.getInteger(TLMTags.State.tagName) != state.ordinal())
|
||||
data.setInteger(TLMTags.State.tagName, state.ordinal());
|
||||
itemStack.setTagCompound(data);
|
||||
inventory.setInventorySlotContents(SLOT_IN, itemStack);
|
||||
|
||||
|
||||
Reference in new issue
Block a user