finish the fluid interface

This commit is contained in:
GlodBlock committed 2022-06-25 08:30:30 +08:00
1 parent 475842d115
commit 19f9dee682
11 files changed
+347 -33

No files matched your search

@@ -12,6 +12,8 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.IInterfaceHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
@@ -28,9 +30,11 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiTabButton switcher;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
this.host = te;
this.ySize = 211;
}
@@ -41,7 +45,7 @@ public class GuiDualInterface extends GuiUpgradeable {
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
this.buttonList.add( this.priority );
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
@@ -93,12 +97,22 @@ public class GuiDualInterface extends GuiUpgradeable {
if( btn == this.priority )
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
}
else if(host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
}
}
if( btn == this.switcher )
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
else if (host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
}
if( btn == this.interfaceMode )
@@ -12,10 +12,12 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -73,6 +75,11 @@ public class GuiFCPriority extends AEBaseGui
myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE;
}
else if (target instanceof PartFluidInterface)
{
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
}
if( this.OriginalGui != null && myIcon != null )
{
@@ -6,6 +6,7 @@ import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.GuiType;
@@ -41,12 +42,18 @@ public class GuiFluidInterface extends AEBaseGui {
this.ySize = 231;
}
public GuiFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
super.initGui();
this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
}
@@ -56,7 +63,13 @@ public class GuiFluidInterface extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = ((TileFluidInterface) cont.getTile()).getInternalFluid();
IAEFluidTank fluidInv;
if (isPart()) {
fluidInv = ((PartFluidInterface) cont.getTile()).getInternalFluid();
} else {
fluidInv = ((TileFluidInterface) cont.getTile()).getInternalFluid();
}
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 6; i++) {
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
@@ -95,19 +108,31 @@ public class GuiFluidInterface extends AEBaseGui {
{
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
}
}
public void update(int id, IAEFluidStack stack) {
if (id >= 100) {
id -= 100;
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
if (isPart()) {
((PartFluidInterface) cont.getTile()).setConfig(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
}
}
else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
if(isPart()) {
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
}
}
}
private boolean isPart() {
return this.cont.getTile() instanceof PartFluidInterface;
}
}
@@ -6,6 +6,7 @@ import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
@@ -33,6 +34,18 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
bindPlayerInventory(ipl, 0, 149);
}
public ContainerFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
public Object getTile() {
return tile;
}
@@ -46,12 +59,23 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
if (tile instanceof TileFluidInterface) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i ))));
else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((PartFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)