Fixes #207
This commit is contained in:
parent
dedb00aa7e
commit
50a830a101
4 changed files with 51 additions and 4 deletions
|
@ -1,6 +1,9 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
|
@ -9,6 +12,8 @@ import techreborn.tiles.TileDieselGenerator;
|
|||
public class ContainerDieselGenerator extends TechRebornContainer {
|
||||
public TileDieselGenerator tiledieselGenerator;
|
||||
public EntityPlayer player;
|
||||
public int energy;
|
||||
public int fluid;
|
||||
|
||||
public ContainerDieselGenerator(TileDieselGenerator tiledieselGenerator,
|
||||
EntityPlayer player) {
|
||||
|
@ -42,4 +47,36 @@ public class ContainerDieselGenerator extends TechRebornContainer {
|
|||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.energy != (int) tiledieselGenerator.getEnergy()) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
|
||||
}
|
||||
if (this.fluid != tiledieselGenerator.tank.getFluidAmount()) {
|
||||
icrafting.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.energy = value;
|
||||
}else
|
||||
if (id == 1) {
|
||||
this.fluid = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@ public class GuiDieselGenerator extends GuiContainer {
|
|||
|
||||
TileDieselGenerator tile;
|
||||
|
||||
ContainerDieselGenerator containerDieselGenerator;
|
||||
|
||||
public GuiDieselGenerator(EntityPlayer player, TileDieselGenerator tile) {
|
||||
super(new ContainerDieselGenerator(tile, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.tile = tile;
|
||||
containerDieselGenerator = (ContainerDieselGenerator) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +42,11 @@ public class GuiDieselGenerator extends GuiContainer {
|
|||
I18n.format("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
|
||||
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
|
||||
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10,
|
||||
30, 16448255);
|
||||
|
||||
this.fontRendererObj.drawString("EU Amount", 10, 40, 16448255);
|
||||
this.fontRendererObj.drawString(containerDieselGenerator.energy + "", 10,
|
||||
50, 16448255);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
|
|||
double energyReceived = Math.min(getMaxPower() - energy, Math.min(this.getMaxPower(), energy));
|
||||
|
||||
if (!simulate) {
|
||||
setEnergy(energy + energyReceived);
|
||||
setEnergy(getEnergy() + energyReceived);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
|
|
@ -89,11 +89,13 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
System.out.println("hi");
|
||||
return FluidPowerManager.fluidPowerValues.containsKey(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
System.out.println("hi");
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
|
@ -149,9 +151,10 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
if (!tank.isEmpty()) {
|
||||
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
|
||||
if(getFreeSpace() >= powerIn){
|
||||
addEnergy(powerIn);
|
||||
addEnergy(powerIn, false);
|
||||
tank.drain(1, true);
|
||||
}
|
||||
System.out.println(getEnergy() + ":" + tank.getFluidAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue