mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 00:07:29 +00:00
finish the fluid interface
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+28
-4
@@ -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)
|
||||
|
||||
@@ -2,32 +2,60 @@ package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IFluidHandler {
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final AEFluidInventory invFluids = new AEFluidInventory(this, 6, 16000);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 6 );
|
||||
|
||||
private final boolean[] tickState = new boolean[]{true, true, true, true, true, true};
|
||||
private final int[] tickCount = new int[]{0, 0, 0, 0, 0, 0};
|
||||
|
||||
public PartFluidInterface(ItemStack is) {
|
||||
super(is);
|
||||
@@ -72,6 +100,79 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
public AEFluidInventory getInternalFluid() {
|
||||
return invFluids;
|
||||
}
|
||||
|
||||
public AppEngInternalAEInventory getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream(ByteBuf data) throws IOException {
|
||||
super.writeToStream( data );
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if (invFluids.getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException {
|
||||
super.readFromStream(data);
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
ItemStack stack = ByteBufUtils.readItemStack(data);
|
||||
if (!ItemStack.areItemStacksEqual(stack, config.getStackInSlot(i))) {
|
||||
config.setInventorySlotContents(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
invFluids.setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (invFluids.getFluidInSlot(i) != null) {
|
||||
invFluids.setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra ) {
|
||||
super.readFromNBT( extra );
|
||||
config.readFromNBT(extra, "ConfigInv");
|
||||
invFluids.readFromNBT(extra, "FluidInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra ) {
|
||||
super.writeToNBT(extra);
|
||||
config.writeToNBT(extra, "ConfigInv");
|
||||
invFluids.writeToNBT(extra, "FluidInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
@@ -112,12 +213,12 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return null;
|
||||
return invFluids.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
return invFluids.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,11 +228,118 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[]{new FluidTankInfo(null, 0)};
|
||||
return invFluids.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.DUAL_INTERFACE_PART);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
|
||||
saveChanges();
|
||||
getTileEntity().markDirty();
|
||||
}
|
||||
|
||||
public void setConfig(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setFluidInv(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
invFluids.setFluidInSlot(id, fluid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.Interface.getMin(), TickRates.Interface.getMax(), false, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
//Very Hacky thing.
|
||||
if (!isActive()) {
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
for (int i = 0; i < 6; i ++) {
|
||||
|
||||
FluidStack configFluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
|
||||
FluidStack storedFluid = invFluids.getFluidInSlot(i) == null ? null : invFluids.getFluidInSlot(i).getFluidStack();
|
||||
|
||||
if (!Util.areFluidsEqual(configFluid, storedFluid)) {
|
||||
if (storedFluid != null) {
|
||||
int ori = storedFluid.amount;
|
||||
int filled = fill(ForgeDirection.UNKNOWN, storedFluid, false);
|
||||
if (ori == filled) {
|
||||
fill(ForgeDirection.UNKNOWN, storedFluid, true);
|
||||
invFluids.setFluidInSlot(i, null);
|
||||
}
|
||||
else {
|
||||
tickState[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configFluid != null) {
|
||||
if (tickState[i]) {
|
||||
if (getFluidGrid() != null) {
|
||||
FluidStack configCopy = configFluid.copy();
|
||||
configCopy.amount = Math.min(8000, getLeftSpace(storedFluid, configCopy));
|
||||
IAEFluidStack fluidDrain = getFluidGrid().extractItems(AEFluidStack.create(configCopy), Actionable.MODULATE, ownActionSource);
|
||||
if (fluidDrain != null && fluidDrain.getStackSize() != 0) {
|
||||
invFluids.fill(i, fluidDrain.getFluidStack(), true);
|
||||
} else {
|
||||
tickState[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tickCount[i] % 40 == 0) {
|
||||
if (getFluidGrid() != null) {
|
||||
FluidStack configCopy = configFluid.copy();
|
||||
configCopy.amount = Math.min(8000, getLeftSpace(storedFluid, configCopy));
|
||||
IAEFluidStack fluidDrain = getFluidGrid().extractItems(AEFluidStack.create(configCopy), Actionable.MODULATE, ownActionSource);
|
||||
if (fluidDrain != null && fluidDrain.getStackSize() != 0) {
|
||||
invFluids.fill(i, fluidDrain.getFluidStack(), true);
|
||||
tickState[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tickCount[i] ++;
|
||||
if (tickCount[i] > 500) {
|
||||
tickCount[i] = 1;
|
||||
}
|
||||
}
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
private int getLeftSpace(FluidStack stored, FluidStack req) {
|
||||
if (stored == null) {
|
||||
return 16000;
|
||||
}
|
||||
if (!Util.areFluidsEqual(stored, req)) {
|
||||
return 0;
|
||||
}
|
||||
return 16000 - stored.amount;
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,10 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
|
||||
{
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO);
|
||||
|
||||
@@ -163,12 +163,12 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return null;
|
||||
return invFluids.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
return invFluids.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,12 +178,12 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[]{new FluidTankInfo(null, 0)};
|
||||
return invFluids.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -149,6 +149,6 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return invFluids.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
return invFluids.getTankInfo(from);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
private final IAEFluidStack[] fluids;
|
||||
private final IAEFluidInventory handler;
|
||||
private final int capacity;
|
||||
private FluidTankInfo[] props = null;
|
||||
|
||||
public AEFluidInventory( final IAEFluidInventory handler, final int slots, final int capcity )
|
||||
{
|
||||
@@ -92,16 +91,12 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
if( this.props == null )
|
||||
FluidTankInfo[] props = new FluidTankInfo[this.getSlots()];
|
||||
for( int i = 0; i < this.getSlots(); ++i )
|
||||
{
|
||||
this.props = new FluidTankInfo[this.getSlots()];
|
||||
for( int i = 0; i < this.getSlots(); ++i )
|
||||
{
|
||||
this.props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i ));
|
||||
}
|
||||
|
||||
props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i ));
|
||||
}
|
||||
return this.props;
|
||||
return props;
|
||||
}
|
||||
|
||||
public int fill( final int slot, final FluidStack resource, final boolean doFill )
|
||||
|
||||
@@ -9,6 +9,7 @@ import appeng.helpers.IPriorityHost;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.*;
|
||||
import com.glodblock.github.common.parts.FCBasePart;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
@@ -22,6 +23,30 @@ import java.util.List;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
DUAL_INTERFACE_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
|
||||
return new ContainerInterface(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
|
||||
return new GuiDualInterface(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_FLUID_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
|
||||
return new ContainerFluidInterface(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
|
||||
return new GuiFluidInterface(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
|
||||
@@ -46,6 +71,18 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_PRIORITY_PART(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new ContainerPriority(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new GuiFCPriority(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_PRIORITY(new TileGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
|
||||
|
||||
Reference in new issue
Block a user