Super stock replenisher full stock mode (#442)

Co-authored-by: PLASMAchicken <[email protected]>
Co-authored-by: lc-1337 <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-06-22 22:31:47 +02:00
1 parent f381726ef2
commit e50d549085
7 files changed
+267 -23

No files matched your search

@@ -67,6 +67,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "OPEN_GUI", "YES", "open_gui");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
this.registerApp(26, "stock mode button", "normalMode", "Normal.mode");
this.registerApp(27, "stock mode button", "fullstockMode", "Full-stock.mode");
this.registerApp(30, "MAGNET_CARD", "INV", "magnet_card.inv");
this.registerApp(30, "MAGNET_CARD", "ME", "magnet_card.me");
this.registerApp(30, "MAGNET_CARD", "FILTER", "magnet_card.filter");
@@ -4,6 +4,7 @@ import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
@@ -29,14 +30,18 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
private final DecimalFormat df = new DecimalFormat("#.#");
private Map<Integer, IAEStack<?>> list = new HashMap<>();
private final ContainerSuperStockReplenisher containerSuperStockReplenisher;
private final TileSuperStockReplenisher tileSuperStockReplenisher;
private final VirtualMEPhantomSlotPrecise[] configFluidsSlots = new VirtualMEPhantomSlotPrecise[9];
private final VirtualMEPhantomSlotPrecise[] configItemsSlots = new VirtualMEPhantomSlotPrecise[63];
private GuiFCImgButton StockModeButton;
public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(new ContainerSuperStockReplenisher(ipl, tile));
this.containerSuperStockReplenisher = (ContainerSuperStockReplenisher) inventorySlots;
this.tileSuperStockReplenisher = tile;
this.ySize = 251;
this.xSize = 216;
@@ -45,6 +50,15 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
@Override
public void initGui() {
super.initGui();
this.StockModeButton = new GuiFCImgButton(
guiLeft - 18,
guiTop + 8,
"stock mode button",
this.containerSuperStockReplenisher.isFullStockMode() ? "fullstockMode" : "normalMode",
true);
this.containerSuperStockReplenisher.setModeButton(this.StockModeButton);
buttonList.add(this.StockModeButton);
this.initSlots();
}
@@ -125,6 +139,19 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (actionPerformedCustomButtons(btn)) return;
if (btn == StockModeButton) {
boolean newMode = !containerSuperStockReplenisher.isFullStockMode();
this.containerSuperStockReplenisher.setFullStockMode(newMode);
StockModeButton.set(newMode ? "fullstockMode" : "normalMode");
this.flushPendingSync();
}
super.actionPerformed(btn);
}
public void update(Map<Integer, IAEStack<?>> map) {
this.list = map;
}
@@ -11,6 +11,7 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.gui.GuiType;
@@ -27,10 +28,13 @@ import appeng.container.interfaces.IVirtualSlotSource;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.sync.SyncManager;
import appeng.container.sync.handlers.AEStackInventorySyncHandler;
import appeng.container.sync.handlers.BooleanSyncHandler;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.tile.inventory.IAEStackInventory;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerSuperStockReplenisher extends AEBaseContainer implements IVirtualSlotSource {
@@ -44,6 +48,11 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
private final IAEStackInventory configItems;
public final AEStackInventorySyncHandler configItemsSlots;
public final BooleanSyncHandler fullStockModeSync;
@SideOnly(Side.CLIENT)
private GuiFCImgButton modeButton;
public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(ipl, tile);
this.tile = tile;
@@ -54,6 +63,11 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
final SyncManager sm = this.getSyncManager();
this.configFluidsSlots = sm.root().aeStackInventory("fluidConfig", this.configFluids);
this.configItemsSlots = sm.root().aeStackInventory("itemConfig", this.configItems);
this.fullStockModeSync = sm.root().booleanSync("fullstockMode").onClientChange((oldValue, newValue) -> {
if (this.modeButton != null) {
this.modeButton.set(newValue ? "fullstockMode" : "normalMode");
}
}).onServerChange((oldValue, newValue) -> this.tile.setFullStockMode(newValue));
this.addSlotToContainer(
new SlotRestrictedInput(
@@ -67,6 +81,11 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
bindPlayerInventory(ipl, 0, 251 - 82);
}
@SideOnly(Side.CLIENT)
public void setModeButton(GuiFCImgButton button) {
this.modeButton = button;
}
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) return null;
@@ -95,6 +114,9 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
FluidCraft.proxy.netHandler.sendTo(new SPacketSuperStockReplenisherUpdate(tmp), (EntityPlayerMP) g);
}
}
if (Platform.isServer()) this.setFullStockMode(this.tile.isFullStockMode());
}
this.lastUpdated++;
@@ -158,4 +180,20 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer implements I
}
}
}
public TileSuperStockReplenisher getTile() {
return this.tile;
}
public boolean isFullStockMode() {
return this.fullStockModeSync.get();
}
public void setFullStockMode(final boolean fullStockMode) {
this.fullStockModeSync.set(fullStockMode);
}
public void markDirty() {
this.fullStockModeSync.markDirty();
}
}