diff options
Diffstat (limited to 'ihl/processing')
6 files changed, 425 insertions, 4 deletions
diff --git a/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/ihl/processing/chemistry/ChemicalReactorTileEntity.java index 2dfe31e..2630ed2 100644 --- a/ihl/processing/chemistry/ChemicalReactorTileEntity.java +++ b/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -122,7 +122,7 @@ public class ChemicalReactorTileEntity extends BasicElectricMotorTileEntity impl @Override
public boolean canFill(ForgeDirection direction, Fluid arg1) {
- return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite());
+ return true;
}
@Override
diff --git a/ihl/processing/chemistry/DosingPumpContainer.java b/ihl/processing/chemistry/DosingPumpContainer.java new file mode 100644 index 0000000..5a4cb21 --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpContainer.java @@ -0,0 +1,95 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraftforge.fluids.FluidStack;
+
+public class DosingPumpContainer extends ContainerBase<DosingPumpTileEntity> {
+
+ protected DosingPumpTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public int lastFluidAmountSetpoint = -1;
+ public short lastEnergy = -1;
+ private final static int height = 166;
+ public List<FluidStack> fluidTankFluidList;
+
+ public DosingPumpContainer(EntityPlayer entityPlayer, DosingPumpTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = tileEntity.getFluidTank().getFluidList();
+ int col;
+ for (col = 0; col < 3; ++col) {
+ for (int col1 = 0; col1 < 9; ++col1) {
+ this.addSlotToContainer(
+ new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18));
+ }
+ }
+ for (col = 0; col < 9; ++col) {
+ this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24));
+ }
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 44, 50));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 44, 14));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 8, 32));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); ++i) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+
+ if (this.tileEntity.getTankAmount() != this.lastFluidAmount
+ || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+
+ if (this.tileEntity.fluidAmountSetpoint != this.lastFluidAmountSetpoint) {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.fluidAmountSetpoint);
+ }
+
+ if ((short) this.tileEntity.energy != this.lastEnergy) {
+ icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy);
+ }
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ this.lastProgress = this.tileEntity.progress;
+ this.lastFluidAmountSetpoint = this.tileEntity.fluidAmountSetpoint;
+ this.lastEnergy = (short) this.tileEntity.energy;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value) {
+ super.updateProgressBar(index, value);
+ switch (index) {
+ case 0:
+ this.tileEntity.progress = (short) value;
+ break;
+ case 1:
+ this.tileEntity.fluidAmountSetpoint = (short) value;
+ break;
+ case 2:
+ this.tileEntity.energy = value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/ihl/processing/chemistry/DosingPumpGui.java b/ihl/processing/chemistry/DosingPumpGui.java new file mode 100644 index 0000000..090bdec --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpGui.java @@ -0,0 +1,101 @@ +package ihl.processing.chemistry;
+
+import cpw.mods.fml.relauncher.Side;
+
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.IC2;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import java.awt.event.KeyEvent;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.ClientProxy;
+import ihl.IHLMod;
+import ihl.utils.IHLRenderUtils;
+import ihl.utils.IHLUtils;
+
+@SideOnly(Side.CLIENT)
+public class DosingPumpGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDosingPump.png");
+ private DosingPumpContainer container;
+ private GuiTextField setpointTextField;
+ private final static int TANK_HEIGHT = 58;
+
+ public DosingPumpGui(DosingPumpContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ setpointTextField = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 106, 34, 62, 16);
+ setpointTextField.setText(Integer.toString(this.container.tileEntity.fluidAmountSetpoint));
+ setpointTextField.setFocused(true);
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ int xOffset = (this.width - xSize) / 2;
+ int yOffset = (this.height - ySize) / 2;
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D) {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12), 12);
+ this.drawTexturedModalRect(12, 15 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ i1 = TANK_HEIGHT - this.container.tileEntity.fluidAmountSetpoint * TANK_HEIGHT
+ / this.container.tileEntity.getFluidTank().getCapacity();
+ this.drawTexturedModalRect(78, 6 + i1, 176, 14, 25, 7);
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 82, 10, 94,
+ 67, zLevel, par1, par2, xOffset, yOffset);
+ }
+ setpointTextField.drawTextBox();
+ IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.dosingPump.tip"));
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
+ // draw your Gui here, only thing you need to change is the path
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+
+ @Override
+ protected void keyTyped(char characterTyped, int keyIndex) {
+ super.keyTyped(characterTyped, keyIndex);
+ this.setpointTextField.textboxKeyTyped(characterTyped, keyIndex);
+ // 28 - enter; 156 - numpad enter
+ if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) {
+ int fluidAmountSetpoint = (short) Math.max(1,
+ Math.min(this.container.tileEntity.getFluidTank().getCapacity(),
+ IHLUtils.parseIntSafe(this.setpointTextField.getText(), 100)));
+ this.setpointTextField.setText(Integer.toString(fluidAmountSetpoint));
+ this.setpointTextField.setFocused(false);
+ ((ClientProxy)IHLMod.proxy).sendIntegerFieldValueFromClientToServer(fluidAmountSetpoint, "fluidAmountSetpoint", this.container.tileEntity);
+ }
+ }
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ if (mouseX >= x + setpointTextField.xPosition &&
+ mouseX <= x + setpointTextField.xPosition + setpointTextField.width &&
+ mouseY >= y + setpointTextField.yPosition &&
+ mouseY <= y + setpointTextField.yPosition + setpointTextField.height) {
+ setpointTextField.setFocused(true);
+ }
+ }
+
+
+}
\ No newline at end of file diff --git a/ihl/processing/chemistry/DosingPumpTileEntity.java b/ihl/processing/chemistry/DosingPumpTileEntity.java new file mode 100644 index 0000000..d676bf9 --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpTileEntity.java @@ -0,0 +1,226 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+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;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+
+public class DosingPumpTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler {
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public int fluidAmountSetpoint = 8000;
+ private boolean prevIsPowered = false;
+ private boolean tickFree=false;
+
+ public DosingPumpTileEntity() {
+ super();
+ this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain);
+ this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ this.fluidAmountSetpoint = nbttagcompound.getInteger("fluidAmountSetpoint");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ nbttagcompound.setInteger("fluidAmountSetpoint", this.fluidAmountSetpoint);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("dosingPump");
+ }
+
+ @Override
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer() {
+ super.updateEntityServer();
+ this.tickFree = true;
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) {
+ switch (from) {
+ case UP:
+ return this.fluidTank.drainLightest(amount, doDrain);
+ case NORTH:
+ return this.fluidTank.drainLightest(amount, doDrain);
+ case SOUTH:
+ return this.fluidTank.drainLightest(amount, doDrain);
+ case WEST:
+ return this.fluidTank.drainLightest(amount, doDrain);
+ case EAST:
+ return this.fluidTank.drainLightest(amount, doDrain);
+ case DOWN:
+ return this.fluidTank.drain(amount, doDrain);
+ default:
+ return this.fluidTank.drain(amount, doDrain);
+ }
+ }
+
+ // 1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return !direction.equals(ForgeDirection.getOrientation(this.getFacing()));
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "dosingPump";
+ }
+
+ public float getRenderLiquidLevel() {
+ return (float) this.fluidTank.getFluidAmount() / (float) this.fluidTank.getCapacity();
+ }
+
+ @Override
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new DosingPumpGui(new DosingPumpContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ this.fluidTank.sortFluidsByDensity();
+ return new DosingPumpContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {
+ }
+
+ @Override
+ public boolean canOperate() {
+ return false;
+ }
+
+ @Override
+ public void operate() {
+ int fluidAmountToDrain = fluidAmountSetpoint;
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IFluidHandler) {
+ IFluidHandler fhte = (IFluidHandler) te;
+ for (int i = 0; i < this.fluidTank.getNumberOfFluids(); i++) {
+ FluidStack drained = this.fluidTank.drain(fluidAmountToDrain, true);
+ fluidAmountToDrain -= drained.amount;
+ if (fhte.canFill(dir, drained.getFluid())) {
+ fhte.fill(dir, drained, true);
+ }
+ if (fluidAmountToDrain <= 0) {
+ break;
+ }
+ }
+ }
+ this.energy-=this.energyConsume/10;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) {
+ if (fluidTank.getFluid() != null && fluidTank.getFluid().containsFluid(fluidStack)) {
+ return this.fluidTank.drain(fluidStack, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return this.fluidTank.fill(arg1, arg2);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[] { this.fluidTank.getInfo() };
+ }
+
+ public boolean needsFluid() {
+ return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity();
+ }
+
+ public FluidStack getFluidStackfromTank() {
+ return this.fluidTank.getFluid();
+ }
+
+ public int getTankAmount() {
+ return this.fluidTank.getFluidAmount();
+ }
+
+ public int gaugeLiquidScaled(int i, int index) {
+ return this.fluidTank.getFluidAmount() <= 0 ? 0
+ : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity();
+ }
+
+ public int getNumberOfFluidsInTank() {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public IHLFluidTank getFluidTank() {
+ return this.fluidTank;
+ }
+
+ @Override
+ public List<?>[] getInput() {
+ return null;
+ }
+
+ public void setPowered(boolean isPowered) {
+ if (isPowered && !prevIsPowered && this.energy > 0 && this.tickFree) {
+ this.operate();
+ }
+ prevIsPowered = isPowered;
+ this.tickFree = false; // Only one operation per tick max
+ }
+
+}
\ No newline at end of file diff --git a/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java index 2d8c288..bb6cf1e 100644 --- a/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java +++ b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -116,7 +116,7 @@ public class FluidizedBedReactorTileEntity extends BasicElectricMotorTileEntity @Override
public boolean canFill(ForgeDirection direction, Fluid arg1) {
- return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite());
+ return true;
}
@Override
diff --git a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java index 7f82532..125b6be 100644 --- a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java +++ b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java @@ -70,7 +70,6 @@ public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBa @SuppressWarnings("unchecked")
@Override
public void setFacing(short facing1) {
- short facing2 = (short) Math.max(facing1, 2);
double d = 0.3D;
double f = -0.1D;
if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
@@ -81,7 +80,7 @@ public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBa AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX - range, connectionY - range,
connectionZ - range, connectionX + range, connectionY + range, connectionZ + range);
List<NodeEntity> nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea);
- super.setFacing(facing2);
+ super.setFacing(facing1);
switch (getFacing()) {
case 4:
setConnectionX(this.xCoord + 0.5D);
|
