From 3fcb2d5b7ba37873c573d57a6233ddbb0ff47401 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Thu, 14 May 2026 13:53:22 +0300 Subject: [PATCH 1/9] renew replenisher --- dependencies.gradle | 2 +- .../client/gui/GuiSuperStockReplenisher.java | 120 ++++++++-------- .../ContainerSuperStockReplenisher.java | 131 +++++++----------- .../tile/TileSuperStockReplenisher.java | 128 +++++++++++------ .../github/inventory/AEFluidInventory.java | 10 +- 5 files changed, 210 insertions(+), 181 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 9ef4bd6fc..ccc38535f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -35,7 +35,7 @@ */ dependencies { api('com.github.GTNewHorizons:NotEnoughItems:2.8.96-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-929-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-936-GTNH:dev') api('com.github.GTNewHorizons:waila:1.19.25:dev') api("com.github.GTNewHorizons:GTNHLib:0.9.62:dev") diff --git a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java index ea86fc091..99cc81c1b 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java @@ -1,101 +1,100 @@ package com.glodblock.github.client.gui; +import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.container.ContainerSuperStockReplenisher; -import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.tile.TileSuperStockReplenisher; import appeng.api.storage.StorageName; -import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; +import appeng.api.storage.data.IAEStackType; import appeng.client.gui.AEBaseGui; -import appeng.container.AEBaseContainer; -import appeng.container.slot.SlotFake; +import appeng.client.gui.slots.VirtualMEPatternSlot; +import appeng.client.gui.slots.VirtualMEPhantomSlot; import appeng.core.localization.GuiText; -import appeng.core.sync.GuiBridge; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketSwitchGuis; -import appeng.core.sync.packets.PacketVirtualSlot; -import appeng.util.item.AEItemStack; +import appeng.tile.inventory.IAEStackInventory; +import appeng.util.item.AEFluidStackType; +import appeng.util.item.AEItemStackType; public class GuiSuperStockReplenisher extends AEBaseGui { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/superStockReplenisher.png"); + private final DecimalFormat df = new DecimalFormat("#.#"); private Map> list = new HashMap<>(); + private final ContainerSuperStockReplenisher containerSuperStockReplenisher; + + private final VirtualMEPatternSlot[] configFluidsSlots = new VirtualMEPatternSlot[9]; + private final VirtualMEPatternSlot[] configItemsSlots = new VirtualMEPatternSlot[63]; public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) { super(new ContainerSuperStockReplenisher(ipl, tile)); + this.containerSuperStockReplenisher = (ContainerSuperStockReplenisher) inventorySlots; this.ySize = 251; this.xSize = 216; } @Override - protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) { - if (mouseButton == 3) { - if (slot instanceof SlotFake) { - if (slot.getHasStack()) { - IAEItemStack stack = AEItemStack.create(slot.getStack()); - ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); - for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) { - if (slot.equals(this.inventorySlots.inventorySlots.get(i))) { - NetworkHandler.instance - .sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_VALUE_AMOUNT)); - NetworkHandler.instance - .sendToServer(new PacketVirtualSlot(StorageName.CRAFTING_INPUT, i, stack)); - } - } - return; - } - } - } - super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); + public void initGui() { + super.initGui(); + this.initSlots(); } - @Override - public void func_146977_a(Slot s) { - if (s instanceof SlotFake) { - this.drawFillStatus(s); + private void initSlots() { + final IAEStackInventory configFluids = this.containerSuperStockReplenisher.getTile().getConfigFluids(); + final IAEStackInventory configItems = this.containerSuperStockReplenisher.getTile().getConfigItems(); + final int xo = 8; + final int yo = 8; + + for (int i = 0; i < 9; i++) { + VirtualMEPatternSlot slot = new VirtualMEPatternSlot(xo + i * 18, yo, configFluids, i, this::acceptType); + this.configFluidsSlots[i] = slot; + this.registerVirtualSlots(slot); + } + + final int iyo = 29; + for (int y = 0; y < 7; y++) { + for (int ix = 0; ix < 9; ix++) { + VirtualMEPatternSlot slot = new VirtualMEPatternSlot( + xo + ix * 18, + iyo + y * 18, + configItems, + y * 9 + ix, + this::acceptType); + this.configItemsSlots[y * 9 + ix] = slot; + this.registerVirtualSlots(slot); + } } - super.func_146977_a(s); } - private void drawFillStatus(Slot slotIn) { - int offsetX = slotIn.xDisplayPosition - 8; - int offsetY = slotIn.yDisplayPosition - 11; - ItemStack itemstack = slotIn.getStack(); - int slotInt = slotIn.slotNumber; - if (itemstack != null) { + private void drawFillStatus(VirtualMEPatternSlot virtualSlot) { + final int offsetX = virtualSlot.getX() - 8; + final int offsetY = virtualSlot.getY() - 12; + final IAEStack aes = virtualSlot.getAEStack(); + final long stackSize = aes != null ? aes.getStackSize() : 0; + final int slotIndex = virtualSlot.getStorageName() == StorageName.NONE ? virtualSlot.getSlotIndex() + : virtualSlot.getSlotIndex() + 100; + + if (stackSize != 0) { String s = "0%"; - if (slotInt > 0 && slotInt < 10) { - IAEStack aeStack = list.get(slotInt - 1); - if (aeStack != null) - s = (int) (((float) aeStack.getStackSize() / ItemFluidPacket.getFluidAmount(itemstack)) * 100) - + "%"; - } else if (slotInt > 9 && slotInt < 73) { - IAEStack aeStack = list.get(slotInt + 90); - if (aeStack != null && itemstack.stackSize > 0) { - long i = aeStack.getStackSize(); - s = (int) (((float) i / itemstack.stackSize) * 100) + "%"; - } - } + IAEStack aeStack = list.get(slotIndex); + + if (aeStack != null) s = df.format((float) aeStack.getStackSize() / stackSize * 100) + "%"; float scale = 0.5f; float shiftX = 2; float shiftY = 1; final float inverseScaleFactor = 1.0f / scale; - final int X = (int) (((float) offsetX - shiftX + 10.0f) * inverseScaleFactor); - final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor); + final int X = (int) (((float) offsetX - shiftX + 10.0f) * inverseScaleFactor) + 1; + final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor) + 2; GL11.glTranslatef(0.0f, 0.0f, 200.0f); GL11.glScaled(scale, scale, scale); this.fontRendererObj.drawStringWithShadow(s, X, Y, 16777215); @@ -104,9 +103,15 @@ private void drawFillStatus(Slot slotIn) { } } + private void drawVirtualSlots() { + for (VirtualMEPatternSlot slot : this.configFluidsSlots) this.drawFillStatus(slot); + for (VirtualMEPatternSlot slot : this.configItemsSlots) this.drawFillStatus(slot); + } + @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040); + this.drawVirtualSlots(); } @Override @@ -118,4 +123,9 @@ public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { public void update(Map> map) { this.list = map; } + + private boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType type, int mouseButton) { + if (slot.getStorageName() == StorageName.NONE) return type == AEFluidStackType.FLUID_STACK_TYPE; + else return type == AEItemStackType.ITEM_STACK_TYPE; + } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java index 095a5d3f6..c6a57c264 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java @@ -1,113 +1,83 @@ package com.glodblock.github.client.gui.container; +import static appeng.util.Platform.isServer; + import java.util.HashMap; import java.util.Map; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import com.glodblock.github.FluidCraft; import com.glodblock.github.common.item.FCBaseItemCell; -import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.tile.TileSuperStockReplenisher; import com.glodblock.github.inventory.gui.GuiType; -import com.glodblock.github.inventory.slot.OptionalFluidSlotFake; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.network.SPacketSuperStockReplenisherUpdate; import com.glodblock.github.util.FluidPrimaryGui; import appeng.api.storage.StorageName; -import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; -import appeng.client.gui.implementations.GuiPatternItemRenamer; -import appeng.client.gui.implementations.GuiPatternValueAmount; import appeng.container.AEBaseContainer; import appeng.container.ContainerOpenContext; import appeng.container.PrimaryGui; import appeng.container.interfaces.IVirtualSlotHolder; import appeng.container.interfaces.IVirtualSlotSource; -import appeng.container.slot.IOptionalSlotHost; -import appeng.container.slot.SlotPatternOutputs; import appeng.container.slot.SlotRestrictedInput; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketVirtualSlot; import appeng.items.storage.ItemBasicStorageCell; +import appeng.tile.inventory.IAEStackInventory; import appeng.util.Platform; import appeng.util.item.AEItemStack; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -public class ContainerSuperStockReplenisher extends AEBaseContainer - implements IOptionalSlotHost, IVirtualSlotHolder, IVirtualSlotSource { +public class ContainerSuperStockReplenisher extends AEBaseContainer implements IVirtualSlotHolder, IVirtualSlotSource { private final TileSuperStockReplenisher tile; - private final IInventory configFluids; - private final IInventory configItems; + + private boolean isFirstUpdate = true; private int lastUpdated = 0; + private final IAEStackInventory configFluids; + private final IAEStack[] configFluidsClientSlots = new IAEStack[9]; + + private final IAEStackInventory configItems; + private final IAEStack[] configItemsClientSlots = new IAEStack[63]; + public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) { super(ipl, tile); this.tile = tile; - configFluids = tile.getConfigFluid(); - configItems = tile.getConfigItems(); + this.configFluids = tile.getConfigFluids(); + this.configItems = tile.getConfigItems(); final IInventory cell = tile.getCell(); - final int x = 8; - final int fy = 8; - this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 173, - fy, + 8, this.getInventoryPlayer())); - for (int i = 0; i < 9; i++) { - addSlotToContainer(new OptionalFluidSlotFake(configFluids, this, i, x, fy, i, 0, 0)); - } - - final int io = 29; - for (int y = 0; y < 7; y++) { - for (int ix = 0; ix < 9; ix++) { - this.addSlotToContainer(new SlotPatternOutputs(configItems, this, y * 9 + ix, x, io, ix, y, y)); - } - } - bindPlayerInventory(ipl, 0, 251 - 82); } @Override public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) { - if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) { - return null; - } + if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) return null; return super.slotClick(slotId, clickedButton, mode, player); } - @Override - public boolean isSlotEnabled(int idx) { - return true; - } - - @Override - public void addCraftingToCrafters(ICrafting p_75132_1_) { - super.addCraftingToCrafters(p_75132_1_); - lastUpdated = 24; - } - @Override public void detectAndSendChanges() { super.detectAndSendChanges(); + if (Platform.isClient()) return; - if (lastUpdated > 20) { + if (this.isFirstUpdate || this.lastUpdated > 20) { lastUpdated = 0; Map> tmp = new HashMap<>(); @@ -126,19 +96,20 @@ public void detectAndSendChanges() { } } lastUpdated++; + + if (this.isFirstUpdate) { + this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); + this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); + this.isFirstUpdate = false; + } } private boolean isConfigurated() { - for (int i = 0; i < configItems.getSizeInventory(); i++) { - if (configItems.getStackInSlot(i) != null) { - return true; - } - } - for (int i = 0; i < configFluids.getSizeInventory(); i++) { - if (configFluids.getStackInSlot(i) != null) { - return true; - } - } + for (int i = 0; i < configItems.getSizeInventory(); i++) + if (configItems.getAEStackInSlot(i) != null) return true; + + for (int i = 0; i < configFluids.getSizeInventory(); i++) + if (configFluids.getAEStackInSlot(i) != null) return true; return false; } @@ -183,38 +154,34 @@ public PrimaryGui createPrimaryGui() { @Override public void receiveSlotStacks(StorageName invName, Int2ObjectMap> slotStacks) { - var entry = slotStacks.int2ObjectEntrySet().iterator().next(); - IAEStack aes = entry.getValue(); - int slotIndex = entry.getIntKey(); - - if (Platform.isServer()) { - for (ICrafting crafter : this.crafters) { - final EntityPlayerMP emp = (EntityPlayerMP) crafter; - NetworkHandler.instance.sendTo(new PacketVirtualSlot(invName, slotIndex, aes), emp); + switch (invName) { + case NONE -> { + for (var entry : slotStacks.int2ObjectEntrySet()) + this.configFluids.putAEStackInSlot(entry.getIntKey(), entry.getValue()); + if (isServer()) + this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); } - } else { - final GuiScreen gs = Minecraft.getMinecraft().currentScreen; - if (gs instanceof GuiPatternValueAmount gpva) { - gpva.update(); - } else if (gs instanceof GuiPatternItemRenamer gpir) { - gpir.update(); + case CONFIG -> { + for (var entry : slotStacks.int2ObjectEntrySet()) + this.configItems.putAEStackInSlot(entry.getIntKey(), entry.getValue()); + if (isServer()) + this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); } } } @Override public void updateVirtualSlot(StorageName invName, int slotId, IAEStack aes) { - if (aes instanceof IAEItemStack ais) { - ItemStack newIs; - if (ais.getItem() instanceof ItemFluidPacket) { - newIs = ais.getItemStack(); - newIs.stackSize = 1; - ItemFluidPacket.setFluidAmount(newIs, aes.getStackSize()); - } else { - newIs = ais.getItemStack(); + if (aes != null && aes.getStackSize() > Integer.MAX_VALUE) aes.setStackSize(Integer.MAX_VALUE); + switch (invName) { + case NONE -> { + this.configFluids.putAEStackInSlot(slotId, aes); + this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); + } + case CONFIG -> { + this.configItems.putAEStackInSlot(slotId, aes); + this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); } - this.inventorySlots.get(slotId).putStack(newIs); } } - } diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index aec6100bd..f72617969 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -15,6 +15,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; +import org.jetbrains.annotations.Nullable; + import com.glodblock.github.common.item.FCBaseItemCell; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.inventory.AEFluidInventory; @@ -36,8 +38,10 @@ import appeng.api.networking.ticking.TickingRequest; import appeng.api.storage.IMEMonitor; import appeng.api.storage.ITerminalHost; +import appeng.api.storage.StorageName; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; import appeng.api.util.AECableType; import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; @@ -47,28 +51,44 @@ import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkInvTile; -import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.BiggerAppEngInventory; +import appeng.tile.inventory.IAEStackInventory; +import appeng.tile.inventory.IIAEStackInventory; import appeng.tile.inventory.InvOperation; -import appeng.util.item.AEFluidStack; import appeng.util.item.AEItemStack; import io.netty.buffer.ByteBuf; -public class TileSuperStockReplenisher extends AENetworkInvTile - implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable, ITerminalHost { +public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFluidInventory, IFluidHandler, + IPowerChannelState, IGridTickable, ITerminalHost, IIAEStackInventory { private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1); private final BiggerAppEngInventory invItems = new BiggerAppEngInventory(this, 63); private final AEFluidInventory invFluids = new AEFluidInventory(this, 9, Integer.MAX_VALUE); - private final AppEngInternalAEInventory configFluids = new AppEngInternalAEInventory(this, 9); - private final AppEngInternalAEInventory configItems = new AppEngInternalAEInventory(this, 63); + private final IAEStackInventory configFluids = new IAEStackInventory(this, 9, StorageName.NONE) { + + @Override + public void readFromNBT(@Nullable NBTTagCompound data, String name) { + super.readFromNBT(data, name); + + for (int i = 0; i < this.getSizeInventory(); i++) { + final IAEStack aes = this.getAEStackInSlot(i); + if (aes instanceof IAEItemStack ais && ais.getItem() instanceof ItemFluidPacket) { + this.putAEStackInSlot(i, ItemFluidPacket.getFluidAEStack(ais)); + } + } + } + }; + private final IAEStackInventory configItems = new IAEStackInventory(this, 63, StorageName.CONFIG); private final BaseActionSource source; private boolean isPowered; private long totalBytes; private long storedFluidCount; private long storedItemCount; + private boolean needReCountStoredFluids = true; + private boolean needReCountStoredItems = true; + public TileSuperStockReplenisher() { super(false); getProxy().setIdlePowerUsage(4D); @@ -78,11 +98,16 @@ public TileSuperStockReplenisher() { } private TickRateModulation doWork() { + this.fletchFluids(); + this.fletchItems(); + return TickRateModulation.SAME; + } + + private void fletchFluids() { for (int i = 0; i < 9; i++) { IAEFluidStack invFluid = invFluids.getFluidInSlot(i); - IAEItemStack configFluid = configFluids.getAEStackInSlot(i); - if (configFluid != null) { - IAEFluidStack fs = AEFluidStack.create(ItemFluidPacket.getFluidStack(configFluid)); + IAEStack configFluid = configFluids.getAEStackInSlot(i); + if (configFluid instanceof IAEFluidStack fs) { if (invFluid == null) requestFluid(fs, i); else if (invFluid.equals(fs)) { long invSize = invFluid.getStackSize(); @@ -101,12 +126,15 @@ else if (invFluid.equals(fs)) { } } + this.needReCountStoredFluids = true; + } + + private void fletchItems() { for (int i = 0; i < 63; i++) { ItemStack invItem = invItems.getStackInSlot(i); - IAEItemStack configItem = configItems.getAEStackInSlot(i); - - if (configItem != null) { - IAEItemStack is = configItem.copy(); + IAEStack configItem = configItems.getAEStackInSlot(i); + if (configItem instanceof IAEItemStack ais) { + IAEItemStack is = ais.copy(); if (invItem == null) requestItem(is, i); else if (is.equals(invItem)) { int confSize = (int) is.getStackSize(); @@ -124,7 +152,29 @@ else if (is.equals(invItem)) { } } - return TickRateModulation.SAME; + this.needReCountStoredItems = true; + } + + private void countFluids() { + if (this.needReCountStoredFluids) { + this.needReCountStoredFluids = false; + this.storedFluidCount = 0; + for (int i = 0; i < this.invFluids.getSlots(); i++) { + final IAEFluidStack fs = this.invFluids.getFluidInSlot(i); + if (fs != null) this.storedFluidCount += fs.getStackSize(); + } + } + } + + private void countItems() { + if (this.needReCountStoredItems) { + this.needReCountStoredItems = false; + this.storedItemCount = 0; + for (int i = 0; i < this.invItems.getSizeInventory(); i++) { + final ItemStack is = this.invItems.getStackInSlot(i); + if (is != null) this.storedItemCount += is.stackSize; + } + } } private void returnFluid(int index, long amount) { @@ -210,12 +260,12 @@ public IInventory getInternalInventory() { return invItems; } - public AppEngInternalAEInventory getConfigFluid() { - return configFluids; + public IAEStackInventory getConfigFluids() { + return this.configFluids; } - public AppEngInternalAEInventory getConfigItems() { - return configItems; + public IAEStackInventory getConfigItems() { + return this.configItems; } public AppEngInternalInventory getCell() { @@ -228,6 +278,7 @@ public long getFreeBytes() { } public long getRemainingFluidCount() { + this.countFluids(); final double remaining = (double) getFreeBytes() * 2048 + this.getUnusedFluidCount(); if (remaining > Long.MAX_VALUE) return Long.MAX_VALUE; return remaining > 0 ? (long) remaining : 0; @@ -242,6 +293,7 @@ public int getUnusedFluidCount() { } public long getRemainingItemCount() { + this.countItems(); final long remaining = getFreeBytes() * 8 + this.getUnusedItemCount(); return remaining > 0 ? remaining : 0; @@ -273,14 +325,6 @@ public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemSta totalBytes = 0; getProxy().setIdlePowerUsage(4d); } - } else if (inv == invItems) { - if (added != null) { - storedItemCount += added.stackSize; - } - - if (removed != null) { - storedItemCount -= removed.stackSize; - } } } case decreaseStackSize -> { @@ -288,10 +332,6 @@ public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemSta totalBytes = 0; getProxy().setIdlePowerUsage(4d); } - - if (inv == invItems) { - storedItemCount -= removed.stackSize; - } } case markDirty -> markDirty(); } @@ -339,16 +379,12 @@ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - FluidStack fs = invFluids.drain(from, resource, doDrain); - if (doDrain && fs != null) storedFluidCount -= fs.amount; - return fs; + return invFluids.drain(from, resource, doDrain); } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - FluidStack fs = invFluids.drain(from, maxDrain, doDrain); - if (doDrain && fs != null) storedFluidCount -= fs.amount; - return fs; + return invFluids.drain(from, maxDrain, doDrain); } @Override @@ -368,7 +404,7 @@ public FluidTankInfo[] getTankInfo(ForgeDirection from) { @Override public void onFluidInventoryChanged(IAEFluidTank inv, int slot) { - saveChanges(); + this.markDirty(); } @Override @@ -396,8 +432,6 @@ public void readFromNBTEvent(NBTTagCompound data) { configFluids.readFromNBT(data, "configFluids"); cell.readFromNBT(data, "cellHolder"); totalBytes = data.getLong("totalBytes"); - storedFluidCount = data.getLong("storedFluidCount"); - storedItemCount = data.getLong("storedItemCount"); getProxy().setIdlePowerUsage(data.getDouble("powerDraw")); } @@ -409,8 +443,6 @@ public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { configFluids.writeToNBT(data, "configFluids"); cell.writeToNBT(data, "cellHolder"); data.setLong("totalBytes", totalBytes); - data.setLong("storedFluidCount", storedFluidCount); - data.setLong("storedItemCount", storedItemCount); data.setDouble("powerDraw", getProxy().getIdlePowerUsage()); return data; } @@ -482,4 +514,18 @@ public IMEMonitor getFluidInventory() { public IConfigManager getConfigManager() { return null; } + + @Override + public void saveAEStackInv() { + this.markDirty(); + } + + @Override + public IAEStackInventory getAEInventoryByName(StorageName name) { + return switch (name) { + case NONE -> this.configFluids; + case CONFIG -> this.configItems; + default -> null; + }; + } } diff --git a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java index a6353df7f..dda92d45b 100644 --- a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java @@ -432,7 +432,10 @@ public int fill(FluidStack resource, boolean doFill) { if (doFill) { if (getFluid() == null) AEFluidInventory.this .setFluidInSlot(this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc))); - else getFluid().amount += acc; + else { + AEFluidInventory.this.onContentChanged(this.slot); + getFluid().amount += acc; + } } return acc; } @@ -446,7 +449,10 @@ public FluidStack drain(int maxDrain, boolean doDrain) { if (doDrain) { if (amt == getFluid().amount) { AEFluidInventory.this.setFluidInSlot(this.slot, null); - } else getFluid().amount -= amt; + } else { + getFluid().amount -= amt; + AEFluidInventory.this.onContentChanged(this.slot); + } } return remove; } From 06e8e3331e470b04e2db3a6c317e96b7d0fdf8f2 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Thu, 21 May 2026 20:28:37 +0300 Subject: [PATCH 2/9] new sync --- .../client/gui/GuiSuperStockReplenisher.java | 26 +++++-- .../ContainerSuperStockReplenisher.java | 69 +++++++------------ 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java index 99cc81c1b..b5971c2a8 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java @@ -19,6 +19,7 @@ import appeng.client.gui.AEBaseGui; import appeng.client.gui.slots.VirtualMEPatternSlot; import appeng.client.gui.slots.VirtualMEPhantomSlot; +import appeng.client.gui.slots.VirtualMESlot; import appeng.core.localization.GuiText; import appeng.tile.inventory.IAEStackInventory; import appeng.util.item.AEFluidStackType; @@ -34,9 +35,16 @@ public class GuiSuperStockReplenisher extends AEBaseGui { private final VirtualMEPatternSlot[] configFluidsSlots = new VirtualMEPatternSlot[9]; private final VirtualMEPatternSlot[] configItemsSlots = new VirtualMEPatternSlot[63]; + private final IAEStackInventory configFluids; + private final IAEStackInventory configItems; + public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) { super(new ContainerSuperStockReplenisher(ipl, tile)); + this.containerSuperStockReplenisher = (ContainerSuperStockReplenisher) inventorySlots; + this.configFluids = this.containerSuperStockReplenisher.getTile().getConfigFluids(); + this.configItems = this.containerSuperStockReplenisher.getTile().getConfigItems(); + this.ySize = 251; this.xSize = 216; } @@ -48,13 +56,17 @@ public void initGui() { } private void initSlots() { - final IAEStackInventory configFluids = this.containerSuperStockReplenisher.getTile().getConfigFluids(); - final IAEStackInventory configItems = this.containerSuperStockReplenisher.getTile().getConfigItems(); + final int xo = 8; final int yo = 8; for (int i = 0; i < 9; i++) { - VirtualMEPatternSlot slot = new VirtualMEPatternSlot(xo + i * 18, yo, configFluids, i, this::acceptType); + VirtualMEPatternSlot slot = new VirtualMEPatternSlot( + xo + i * 18, + yo, + this.configFluids, + i, + this::acceptType); this.configFluidsSlots[i] = slot; this.registerVirtualSlots(slot); } @@ -65,7 +77,7 @@ private void initSlots() { VirtualMEPatternSlot slot = new VirtualMEPatternSlot( xo + ix * 18, iyo + y * 18, - configItems, + this.configItems, y * 9 + ix, this::acceptType); this.configItemsSlots[y * 9 + ix] = slot; @@ -128,4 +140,10 @@ private boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType type, int if (slot.getStorageName() == StorageName.NONE) return type == AEFluidStackType.FLUID_STACK_TYPE; else return type == AEItemStackType.ITEM_STACK_TYPE; } + + @Override + protected boolean handleVirtualSlotClick(VirtualMESlot slot, int mouseButton) { + this.containerSuperStockReplenisher.markDirty(); + return super.handleVirtualSlotClick(slot, mouseButton); + } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java index c6a57c264..1b5b116a9 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java @@ -1,7 +1,5 @@ package com.glodblock.github.client.gui.container; -import static appeng.util.Platform.isServer; - import java.util.HashMap; import java.util.Map; @@ -25,27 +23,26 @@ import appeng.container.AEBaseContainer; import appeng.container.ContainerOpenContext; import appeng.container.PrimaryGui; -import appeng.container.interfaces.IVirtualSlotHolder; import appeng.container.interfaces.IVirtualSlotSource; import appeng.container.slot.SlotRestrictedInput; +import appeng.container.sync.SyncManager; +import appeng.container.sync.handlers.AEStackInventorySyncHandler; import appeng.items.storage.ItemBasicStorageCell; import appeng.tile.inventory.IAEStackInventory; import appeng.util.Platform; import appeng.util.item.AEItemStack; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -public class ContainerSuperStockReplenisher extends AEBaseContainer implements IVirtualSlotHolder, IVirtualSlotSource { +public class ContainerSuperStockReplenisher extends AEBaseContainer implements IVirtualSlotSource { private final TileSuperStockReplenisher tile; - private boolean isFirstUpdate = true; - private int lastUpdated = 0; + private int lastUpdated = 1337; private final IAEStackInventory configFluids; - private final IAEStack[] configFluidsClientSlots = new IAEStack[9]; + public final AEStackInventorySyncHandler configFluidsSlots; private final IAEStackInventory configItems; - private final IAEStack[] configItemsClientSlots = new IAEStack[63]; + public final AEStackInventorySyncHandler configItemsSlots; public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) { super(ipl, tile); @@ -54,6 +51,10 @@ public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockRepleni this.configItems = tile.getConfigItems(); final IInventory cell = tile.getCell(); + final SyncManager sm = this.getSyncManager(); + this.configFluidsSlots = sm.root().aeStackInventory("fluidConfig", this.configFluids); + this.configItemsSlots = sm.root().aeStackInventory("itemConfig", this.configItems); + this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, @@ -77,16 +78,16 @@ public void detectAndSendChanges() { super.detectAndSendChanges(); if (Platform.isClient()) return; - if (this.isFirstUpdate || this.lastUpdated > 20) { - lastUpdated = 0; + if (this.lastUpdated > 20) { + this.lastUpdated = 0; Map> tmp = new HashMap<>(); - for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) { - tmp.put(i, tile.getInternalFluid().getFluidInSlot(i)); + for (int i = 0; i < this.tile.getInternalFluid().getSlots(); i++) { + tmp.put(i, this.tile.getInternalFluid().getFluidInSlot(i)); } - for (int i = 0; i < tile.getInternalInventory().getSizeInventory(); i++) { - tmp.put(i + 100, AEItemStack.create(tile.getInternalInventory().getStackInSlot(i))); + for (int i = 0; i < this.tile.getInternalInventory().getSizeInventory(); i++) { + tmp.put(i + 100, AEItemStack.create(this.tile.getInternalInventory().getStackInSlot(i))); } for (final Object g : this.crafters) { @@ -95,21 +96,16 @@ public void detectAndSendChanges() { } } } - lastUpdated++; - if (this.isFirstUpdate) { - this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); - this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); - this.isFirstUpdate = false; - } + this.lastUpdated++; } private boolean isConfigurated() { - for (int i = 0; i < configItems.getSizeInventory(); i++) - if (configItems.getAEStackInSlot(i) != null) return true; + for (int i = 0; i < this.configItems.getSizeInventory(); i++) + if (this.configItems.getAEStackInSlot(i) != null) return true; - for (int i = 0; i < configFluids.getSizeInventory(); i++) - if (configFluids.getAEStackInSlot(i) != null) return true; + for (int i = 0; i < this.configFluids.getSizeInventory(); i++) + if (this.configFluids.getAEStackInSlot(i) != null) return true; return false; } @@ -152,22 +148,9 @@ public PrimaryGui createPrimaryGui() { context.getSide()); } - @Override - public void receiveSlotStacks(StorageName invName, Int2ObjectMap> slotStacks) { - switch (invName) { - case NONE -> { - for (var entry : slotStacks.int2ObjectEntrySet()) - this.configFluids.putAEStackInSlot(entry.getIntKey(), entry.getValue()); - if (isServer()) - this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); - } - case CONFIG -> { - for (var entry : slotStacks.int2ObjectEntrySet()) - this.configItems.putAEStackInSlot(entry.getIntKey(), entry.getValue()); - if (isServer()) - this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); - } - } + public void markDirty() { + this.configFluidsSlots.markDirty(); + this.configItemsSlots.markDirty(); } @Override @@ -176,11 +159,11 @@ public void updateVirtualSlot(StorageName invName, int slotId, IAEStack aes) switch (invName) { case NONE -> { this.configFluids.putAEStackInSlot(slotId, aes); - this.updateVirtualSlots(StorageName.NONE, this.configFluids, this.configFluidsClientSlots); + this.configFluidsSlots.markDirty(); } case CONFIG -> { this.configItems.putAEStackInSlot(slotId, aes); - this.updateVirtualSlots(StorageName.CONFIG, this.configItems, this.configItemsClientSlots); + this.configItemsSlots.markDirty(); } } } From cf51b1bb303f8b8d49e8586573f1f5d985529fb4 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Fri, 22 May 2026 22:36:00 +0300 Subject: [PATCH 3/9] count when need count --- .../common/tile/TileSuperStockReplenisher.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index f72617969..c11aa02f7 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -108,13 +108,14 @@ private void fletchFluids() { IAEFluidStack invFluid = invFluids.getFluidInSlot(i); IAEStack configFluid = configFluids.getAEStackInSlot(i); if (configFluid instanceof IAEFluidStack fs) { - if (invFluid == null) requestFluid(fs, i); - else if (invFluid.equals(fs)) { + IAEFluidStack ifs = fs.copy(); + if (invFluid == null) requestFluid(ifs, i); + else if (invFluid.equals(ifs)) { long invSize = invFluid.getStackSize(); - long confSize = fs.getStackSize(); + long confSize = ifs.getStackSize(); if (invSize < confSize / 2f) { - fs.setStackSize(confSize - invSize); - requestFluid(fs, i); + ifs.setStackSize(confSize - invSize); + requestFluid(ifs, i); } else if (invSize > confSize) { returnFluid(i, invSize - confSize); } @@ -273,12 +274,14 @@ public AppEngInternalInventory getCell() { } public long getFreeBytes() { + this.countFluids(); + this.countItems(); + return totalBytes - (((storedItemCount + getUnusedItemCount()) / 8) + ((storedFluidCount + getUnusedFluidCount()) / 2048)); } public long getRemainingFluidCount() { - this.countFluids(); final double remaining = (double) getFreeBytes() * 2048 + this.getUnusedFluidCount(); if (remaining > Long.MAX_VALUE) return Long.MAX_VALUE; return remaining > 0 ? (long) remaining : 0; @@ -293,7 +296,6 @@ public int getUnusedFluidCount() { } public long getRemainingItemCount() { - this.countItems(); final long remaining = getFreeBytes() * 8 + this.getUnusedItemCount(); return remaining > 0 ? remaining : 0; From b3ac90c8f9079c84f32757ed2790b7283c0a3767 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Mon, 25 May 2026 16:23:43 +0300 Subject: [PATCH 4/9] new slot --- .../client/gui/GuiSuperStockReplenisher.java | 33 ++++++------------- .../ContainerSuperStockReplenisher.java | 9 ----- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java index b5971c2a8..f48638f34 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiSuperStockReplenisher.java @@ -17,11 +17,9 @@ import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStackType; import appeng.client.gui.AEBaseGui; -import appeng.client.gui.slots.VirtualMEPatternSlot; import appeng.client.gui.slots.VirtualMEPhantomSlot; -import appeng.client.gui.slots.VirtualMESlot; +import appeng.client.gui.slots.VirtualMEPhantomSlotPrecise; import appeng.core.localization.GuiText; -import appeng.tile.inventory.IAEStackInventory; import appeng.util.item.AEFluidStackType; import appeng.util.item.AEItemStackType; @@ -32,18 +30,13 @@ public class GuiSuperStockReplenisher extends AEBaseGui { private Map> list = new HashMap<>(); private final ContainerSuperStockReplenisher containerSuperStockReplenisher; - private final VirtualMEPatternSlot[] configFluidsSlots = new VirtualMEPatternSlot[9]; - private final VirtualMEPatternSlot[] configItemsSlots = new VirtualMEPatternSlot[63]; - - private final IAEStackInventory configFluids; - private final IAEStackInventory configItems; + private final VirtualMEPhantomSlotPrecise[] configFluidsSlots = new VirtualMEPhantomSlotPrecise[9]; + private final VirtualMEPhantomSlotPrecise[] configItemsSlots = new VirtualMEPhantomSlotPrecise[63]; public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) { super(new ContainerSuperStockReplenisher(ipl, tile)); this.containerSuperStockReplenisher = (ContainerSuperStockReplenisher) inventorySlots; - this.configFluids = this.containerSuperStockReplenisher.getTile().getConfigFluids(); - this.configItems = this.containerSuperStockReplenisher.getTile().getConfigItems(); this.ySize = 251; this.xSize = 216; @@ -61,10 +54,10 @@ private void initSlots() { final int yo = 8; for (int i = 0; i < 9; i++) { - VirtualMEPatternSlot slot = new VirtualMEPatternSlot( + VirtualMEPhantomSlotPrecise slot = new VirtualMEPhantomSlotPrecise( xo + i * 18, yo, - this.configFluids, + this.containerSuperStockReplenisher.configFluidsSlots, i, this::acceptType); this.configFluidsSlots[i] = slot; @@ -74,10 +67,10 @@ private void initSlots() { final int iyo = 29; for (int y = 0; y < 7; y++) { for (int ix = 0; ix < 9; ix++) { - VirtualMEPatternSlot slot = new VirtualMEPatternSlot( + VirtualMEPhantomSlotPrecise slot = new VirtualMEPhantomSlotPrecise( xo + ix * 18, iyo + y * 18, - this.configItems, + this.containerSuperStockReplenisher.configItemsSlots, y * 9 + ix, this::acceptType); this.configItemsSlots[y * 9 + ix] = slot; @@ -86,7 +79,7 @@ private void initSlots() { } } - private void drawFillStatus(VirtualMEPatternSlot virtualSlot) { + private void drawFillStatus(VirtualMEPhantomSlotPrecise virtualSlot) { final int offsetX = virtualSlot.getX() - 8; final int offsetY = virtualSlot.getY() - 12; final IAEStack aes = virtualSlot.getAEStack(); @@ -116,8 +109,8 @@ private void drawFillStatus(VirtualMEPatternSlot virtualSlot) { } private void drawVirtualSlots() { - for (VirtualMEPatternSlot slot : this.configFluidsSlots) this.drawFillStatus(slot); - for (VirtualMEPatternSlot slot : this.configItemsSlots) this.drawFillStatus(slot); + for (VirtualMEPhantomSlotPrecise slot : this.configFluidsSlots) this.drawFillStatus(slot); + for (VirtualMEPhantomSlotPrecise slot : this.configItemsSlots) this.drawFillStatus(slot); } @Override @@ -140,10 +133,4 @@ private boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType type, int if (slot.getStorageName() == StorageName.NONE) return type == AEFluidStackType.FLUID_STACK_TYPE; else return type == AEItemStackType.ITEM_STACK_TYPE; } - - @Override - protected boolean handleVirtualSlotClick(VirtualMESlot slot, int mouseButton) { - this.containerSuperStockReplenisher.markDirty(); - return super.handleVirtualSlotClick(slot, mouseButton); - } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java index 1b5b116a9..de7da75f7 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerSuperStockReplenisher.java @@ -134,10 +134,6 @@ public boolean isValidForSlot(Slot s, ItemStack is) { return super.isValidForSlot(s, is); } - public TileSuperStockReplenisher getTile() { - return tile; - } - @Override public PrimaryGui createPrimaryGui() { ContainerOpenContext context = getOpenContext(); @@ -148,11 +144,6 @@ public PrimaryGui createPrimaryGui() { context.getSide()); } - public void markDirty() { - this.configFluidsSlots.markDirty(); - this.configItemsSlots.markDirty(); - } - @Override public void updateVirtualSlot(StorageName invName, int slotId, IAEStack aes) { if (aes != null && aes.getStackSize() > Integer.MAX_VALUE) aes.setStackSize(Integer.MAX_VALUE); From dfe152cf5bfec51ddc0d93774a9b2a4fc437e4b4 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Mon, 25 May 2026 19:27:55 +0300 Subject: [PATCH 5/9] move need recount --- .../github/common/tile/TileSuperStockReplenisher.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index c11aa02f7..6f4efd7d1 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -100,6 +100,10 @@ public TileSuperStockReplenisher() { private TickRateModulation doWork() { this.fletchFluids(); this.fletchItems(); + + this.needReCountStoredFluids = true; + this.needReCountStoredItems = true; + return TickRateModulation.SAME; } @@ -126,8 +130,6 @@ else if (invFluid.equals(ifs)) { returnFluid(i, Long.MAX_VALUE); } } - - this.needReCountStoredFluids = true; } private void fletchItems() { @@ -152,8 +154,6 @@ else if (is.equals(invItem)) { returnItem(i, Integer.MAX_VALUE); } } - - this.needReCountStoredItems = true; } private void countFluids() { From d6426bb41f1338d0f4eb483fdcdcf608b2fa1604 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Mon, 25 May 2026 21:02:31 +0300 Subject: [PATCH 6/9] rew --- .../github/common/tile/TileSuperStockReplenisher.java | 6 ++++-- .../com/glodblock/github/inventory/AEFluidInventory.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index 6f4efd7d1..91f56c5aa 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -212,21 +212,23 @@ private void returnItem(int index, int amount) { is.stackSize = is.stackSize - amount; is = is.copy(); is.stackSize = amount; - storedItemCount -= is.stackSize; } else { invItems.setInventorySlotContents(index, null); } + this.storedItemCount -= is.stackSize; + IAEItemStack notInserted = this.getProxy().getStorage().getItemInventory() .injectItems(AEItemStack.create(is), Actionable.MODULATE, this.source); if (notInserted != null) { ItemStack tempStack = invItems.getStackInSlot(index); if (tempStack != null) { tempStack.stackSize = tempStack.stackSize + (int) notInserted.getStackSize(); - storedItemCount += notInserted.getStackSize(); saveChanges(); } else invItems.setInventorySlotContents(index, notInserted.getItemStack()); + + this.storedItemCount += notInserted.getStackSize(); } } catch (final GridAccessException ignored) {} } diff --git a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java index dda92d45b..82e14cc6e 100644 --- a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java @@ -433,8 +433,8 @@ public int fill(FluidStack resource, boolean doFill) { if (getFluid() == null) AEFluidInventory.this .setFluidInSlot(this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc))); else { - AEFluidInventory.this.onContentChanged(this.slot); getFluid().amount += acc; + AEFluidInventory.this.onContentChanged(this.slot); } } return acc; From 345a544fadbeef108e5e3a2675e730d0bcddb571 Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Mon, 25 May 2026 21:54:40 +0300 Subject: [PATCH 7/9] rew 2 --- .../github/common/tile/TileSuperStockReplenisher.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index 91f56c5aa..610e280cb 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -74,7 +74,9 @@ public void readFromNBT(@Nullable NBTTagCompound data, String name) { for (int i = 0; i < this.getSizeInventory(); i++) { final IAEStack aes = this.getAEStackInSlot(i); if (aes instanceof IAEItemStack ais && ais.getItem() instanceof ItemFluidPacket) { - this.putAEStackInSlot(i, ItemFluidPacket.getFluidAEStack(ais)); + final IAEFluidStack ifs = ItemFluidPacket.getFluidAEStack(ais); + if (ifs != null && ifs.getStackSize() > Integer.MAX_VALUE) ifs.setStackSize(Integer.MAX_VALUE); + this.putAEStackInSlot(i, ifs); } } } @@ -244,10 +246,11 @@ private void requestItem(IAEItemStack is, int index) { ItemStack tempStack = invItems.getStackInSlot(index); if (tempStack != null) { tempStack.stackSize = tempStack.stackSize + (int) extracted.getStackSize(); - storedItemCount += extracted.getStackSize(); saveChanges(); } else invItems.setInventorySlotContents(index, extracted.getItemStack()); + + this.storedItemCount += extracted.getStackSize(); } } catch (final GridAccessException ignored) {} } From 699ad4dd07e2ac846a2c1744a71fcd1cf34e833a Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Tue, 26 May 2026 21:27:16 +0300 Subject: [PATCH 8/9] zero void --- .../block/BlockSuperStockReplenisher.java | 10 -------- .../tile/TileSuperStockReplenisher.java | 24 ++++++++++++++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/glodblock/github/common/block/BlockSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/block/BlockSuperStockReplenisher.java index f0488726f..bd5784d50 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/block/BlockSuperStockReplenisher.java @@ -1,6 +1,5 @@ package com.glodblock.github.common.block; -import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -47,15 +46,6 @@ public boolean onActivated(World world, int x, int y, int z, EntityPlayer player return false; } - @Override - public void breakBlock(World w, int x, int y, int z, Block a, int b) { - final TileSuperStockReplenisher tss = this.getTileEntity(w, x, y, z); - if (tss != null) { - tss.fullRefund(); - } - super.breakBlock(w, x, y, z, a, b); - } - @Override public BlockSuperStockReplenisher register() { GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_SUPER_STOCK_REPLENISHER); diff --git a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java index 610e280cb..bdab9e205 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java +++ b/src/main/java/com/glodblock/github/common/tile/TileSuperStockReplenisher.java @@ -22,7 +22,9 @@ import com.glodblock.github.inventory.AEFluidInventory; import com.glodblock.github.inventory.IAEFluidInventory; import com.glodblock.github.inventory.IAEFluidTank; +import com.gtnewhorizon.gtnhlib.item.ItemStackNBT; +import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.implementations.IPowerChannelState; @@ -56,6 +58,8 @@ import appeng.tile.inventory.IAEStackInventory; import appeng.tile.inventory.IIAEStackInventory; import appeng.tile.inventory.InvOperation; +import appeng.util.Platform; +import appeng.util.item.AEFluidStack; import appeng.util.item.AEItemStack; import io.netty.buffer.ByteBuf; @@ -366,12 +370,26 @@ public void fullRefund() { @Override public void getDrops(World w, int x, int y, int z, List drops) { + this.fullRefund(); + if (cell.getStackInSlot(0) != null) drops.add(cell.getStackInSlot(0)); + final ItemStack container = AEApi.instance().definitions().items().itemMEStackPacket().maybeStack(1).get(); + for (int i = 0; i < 9; i++) { - ItemStack ifp = ItemFluidPacket.newStack(invFluids.getFluidStackInSlot(i)); - if (ifp != null) drops.add(ifp); + final FluidStack fs = this.invFluids.getFluidStackInSlot(i); + if (fs == null) continue; + final ItemStack temp = container.copy(); + Platform.writeStackNBT(AEFluidStack.create(fs), ItemStackNBT.get(temp)); + drops.add(temp); + } + + for (int i = 0; i < 63; i++) { + final ItemStack is = this.invItems.getStackInSlot(i); + if (is == null) continue; + final ItemStack temp = container.copy(); + Platform.writeStackNBT(AEItemStack.create(is), ItemStackNBT.get(temp)); + drops.add(temp); } - super.getDrops(w, x, y, z, drops); } @Override From 4875cfacf5fdeab1b10ff0c3404354a79f3e7abe Mon Sep 17 00:00:00 2001 From: lc-1337 Date: Wed, 27 May 2026 09:11:04 +0300 Subject: [PATCH 9/9] deps --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index da480436d..eeb6cdf55 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -35,7 +35,7 @@ */ dependencies { api('com.github.GTNewHorizons:NotEnoughItems:2.8.98-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-944-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-959-GTNH:dev') api('com.github.GTNewHorizons:waila:1.19.28:dev') api("com.github.GTNewHorizons:GTNHLib:0.10.2:dev")