add portable fluid cell

This commit is contained in:
GlodBlock committed 2023-01-28 23:15:33 +08:00
1 parent fc9893ac32
commit 80340dbd75
29 files changed
+523 -98

No files matched your search

@@ -125,19 +125,11 @@ public class GuiDualInterface extends GuiUpgradeable {
return;
}
if (btn == this.priority) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_TILE));
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
}
if (btn == this.switcher) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
if (btn == this.interfaceMode) {
@@ -9,9 +9,8 @@ import appeng.helpers.IPriorityHost;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import java.io.IOException;
@@ -59,12 +58,9 @@ public class GuiFCPriority extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof TileFluidInterface) {
if (target instanceof IDualHost) {
this.myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE;
} else if (target instanceof PartFluidInterface) {
this.myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE_PART;
} else if (target instanceof PartFluidStorageBus) {
this.myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.originalGui = GuiType.FLUID_STORAGE_BUS;
@@ -117,8 +117,7 @@ public class GuiFluidInterface extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
}
}
@@ -0,0 +1,23 @@
package com.glodblock.github.client.gui;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.client.gui.container.ContainerFluidPortableCell;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidPortableCell extends GuiFluidTerminal {
public GuiFluidPortableCell(final InventoryPlayer inventoryPlayer, final IFluidPortableCell te) {
super(inventoryPlayer, te, new ContainerFluidPortableCell(inventoryPlayer, te));
}
@Override
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected int getMaxRows() {
return 3;
}
}
@@ -80,7 +80,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
@@ -39,6 +39,14 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
this.showViewBtn = false;
}
public GuiFluidTerminal(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.container = c;
this.player = inventoryPlayer.player;
this.showViewBtn = false;
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
@@ -25,6 +25,7 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
@@ -58,7 +59,9 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
if (monitorable instanceof IPortableCell) {
if (monitorable instanceof IFluidPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
@@ -0,0 +1,68 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class ContainerFluidPortableCell extends ContainerFluidMonitor {
private double powerMultiplier = 0.5;
private final IFluidPortableCell civ;
private int ticks = 0;
private final int slot;
public ContainerFluidPortableCell(final InventoryPlayer ip, final IFluidPortableCell monitorable) {
super(ip, monitorable, false);
if (monitorable != null) {
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.civ = monitorable;
this.bindPlayerInventory(ip, 0, 0);
}
@Override
public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0
? this.getPlayerInv().getCurrentItem()
: this.getPlayerInv().getStackInSlot(this.slot);
if (this.civ != null) {
if (currentItem != this.civ.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(this.civ.getItemStack(), currentItem)) {
this.getPlayerInv()
.setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
}
}
} else {
this.setValidContainer(false);
}
this.ticks++;
if (this.ticks > 10 && this.civ != null) {
this.civ.extractAEPower(
this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
super.detectAndSendChanges();
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
}