storage bus

This commit is contained in:
lc_1337 committed 2025-10-24 12:47:09 +03:00
1 parent edb027424d
commit 24d30ef078
7 files changed
+18 -844

No files matched your search

@@ -1,103 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
public class GuiFluidStorageBus extends GuiUpgradeable {
private GuiImgButton rwMode;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
public GuiFluidStorageBus(InventoryPlayer inventoryPlayer, PartFluidStorageBus te) {
super(new ContainerFluidStorageBus(inventoryPlayer, te));
this.ySize = 251;
}
@Override
protected void addButtons() {
this.clear = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE);
this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH);
this.rwMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 48,
Settings.ACCESS,
AccessRestriction.READ_WRITE);
this.priority = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
2 + 4 * 16,
GuiText.Priority.getLocal(),
itemRender);
this.buttonList.add(this.priority);
this.buttonList.add(this.rwMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_STORAGE_BUS)),
8,
6,
GuiColors.StorageBusTitle.getColor());
this.fontRendererObj.drawString(
GuiText.inventory.getLocal(),
8,
this.ySize - 96 + 3,
GuiColors.StorageBusInventory.getColor());
if (this.rwMode != null) {
this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode());
}
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.partition) {
// FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action",
// "Partition"));
} else if (btn == this.clear) {
// FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
}
public void update(int id, IAEFluidStack stack) {
((ContainerFluidStorageBus) this.cvb).bus.setFluidInSlot(id, stack);
}
}
@@ -1,207 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPrimaryGui;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.Upgrades;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerOpenContext;
import appeng.container.PrimaryGui;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.IterationCounter;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
public final PartFluidStorageBus bus;
@GuiSync(3)
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
public ContainerFluidStorageBus(InventoryPlayer ip, PartFluidStorageBus te) {
super(ip, te);
this.bus = te;
}
@Override
protected int getHeight() {
return 251;
}
@Override
protected void setupConfig() {
final int xo = 8;
final int yo = 23 + 6;
final IInventory upgrades = getUpgradeable().getInventoryByName("upgrades");
final IInventory config = getUpgradeable().getInventoryByName("config");
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
new OptionalFluidSlotFakeTypeOnly(config, null, this, y * 9 + x, xo, yo, x, y, y));
}
}
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
0,
187,
8,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
1,
187,
8 + 18,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
2,
187,
8 + 18 * 2,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
3,
187,
8 + 18 * 3,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
4,
187,
8 + 18 * 4,
this.getInventoryPlayer())).setNotDraggable());
}
@Override
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
final int y = slot / 9;
return y < upgrades + 2;
}
return true;
}
@Override
protected boolean supportCapacity() {
return true;
}
@Override
public int availableUpgrades() {
return 5;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (Platform.isServer()) {
this.setReadWriteMode((AccessRestriction) getUpgradeable().getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter(
(StorageFilter) getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER));
}
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled(final int idx) {
if (getUpgradeable().getInstalledUpgrades(Upgrades.ORE_FILTER) > 0) return false;
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
return upgrades > (idx - 2);
}
public void clear() {
AppEngInternalAEInventory h = this.bus.getConfig();
for (int i = 0; i < h.getSizeInventory(); ++i) {
h.setInventorySlotContents(i, null);
}
this.detectAndSendChanges();
}
public void partition() {
AppEngInternalAEInventory h = this.bus.getConfig();
final IMEInventory<IAEFluidStack> cellInv = this.bus.getInternalHandler();
Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv
.getAvailableItems(AEApi.instance().storage().createFluidList(), IterationCounter.fetchNewId());
i = list.iterator();
}
for (int x = 0; x < h.getSizeInventory(); x++) {
if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) {
h.setInventorySlotContents(x, ItemFluidPacket.newStack(i.next()));
} else {
h.setInventorySlotContents(x, null);
}
}
this.detectAndSendChanges();
}
public AccessRestriction getReadWriteMode() {
return this.rwMode;
}
public StorageFilter getStorageFilter() {
return this.storageFilter;
}
@Override
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
private void setReadWriteMode(final AccessRestriction rwMode) {
this.rwMode = rwMode;
}
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}
@Override
public PrimaryGui getPrimaryGui() {
ContainerOpenContext context = getOpenContext();
return new FluidPrimaryGui(
GuiType.FLUID_STORAGE_BUS,
ItemAndBlockHolder.FLUID_STORAGE_BUS.stack(),
context.getTile(),
context.getSide());
}
}