Fixed fluid syncing issues, fixed liquid item dropping when block broken

This commit is contained in:
modmuss50 2015-06-14 11:58:56 +01:00
parent f5bd04db3c
commit 755c64369a
7 changed files with 30 additions and 8 deletions

View file

@ -2,13 +2,13 @@ package techreborn.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -131,6 +131,11 @@ public class BlockMachineBase extends BlockContainer {
if (itemStack != null && itemStack.stackSize > 0)
{
if(itemStack.getItem() instanceof ItemBlock){
if(((ItemBlock) itemStack.getItem()).field_150939_a instanceof BlockLiquid || ((ItemBlock) itemStack.getItem()).field_150939_a instanceof BlockStaticLiquid || ((ItemBlock) itemStack.getItem()).field_150939_a instanceof BlockDynamicLiquid){
return;
}
}
Random rand = new Random();
float dX = rand.nextFloat() * 0.8F + 0.1F;

View file

@ -21,6 +21,7 @@ public class ContainerAesu extends TechRebornContainer {
public int euOut;
public int storedEu;
public int euChange;
public ContainerAesu(TileAesu tileaesu,
EntityPlayer player)
@ -61,6 +62,9 @@ public class ContainerAesu extends TechRebornContainer {
if(this.storedEu != tile.energy){
icrafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
}
if(this.euChange != tile.getEuChange()){
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
}
}
}
@ -69,6 +73,7 @@ public class ContainerAesu extends TechRebornContainer {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.output);
crafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
crafting.sendProgressBarUpdate(this, 2 , (int) tile.getEuChange());
}
@SideOnly(Side.CLIENT)
@ -78,7 +83,9 @@ public class ContainerAesu extends TechRebornContainer {
this.euOut = value;
} else if(id == 1){
this.storedEu = value;
}
} else if(id == 2){
this.euChange = value;
}
}
}

View file

@ -57,9 +57,10 @@ public class GuiAesu extends GuiContainer {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString(StatCollector.translateToLocal("tile.techreborn.aesu.name"), 40, 6, Color.WHITE.getRGB());
this.fontRendererObj.drawString(StatCollector.translateToLocal("tile.techreborn.aesu.name"), 40, 10, Color.WHITE.getRGB());
this.fontRendererObj.drawString(containerAesu.euOut + " eu/tick", 10, 20, Color.WHITE.getRGB());
this.fontRendererObj.drawString(containerAesu.storedEu + " eu", 10, 30, Color.WHITE.getRGB());
this.fontRendererObj.drawString(containerAesu.euChange + " eu change", 10, 40, Color.WHITE.getRGB());
}
@Override

View file

@ -16,6 +16,7 @@ public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
public static final int MAX_STORAGE = 1000000000; //One billion!
public Inventory inventory = new Inventory(2, "TileAesu", 64);
private int OUTPUT = 64; //The current output
private double euLastTick = 0;
public TileAesu()
{
@ -26,7 +27,7 @@ public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
public void updateEntity()
{
super.updateEntity();
euLastTick = energy;
}
@Override
@ -115,4 +116,9 @@ public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
LogHelper.debug("Set output to " + getOutput());
}
public double getEuChange(){
return energy - euLastTick;
}
}

View file

@ -157,7 +157,8 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
public void updateEntity()
{
super.updateEntity();
FluidUtils.drainContainers(this, inventory, 0, 1);
if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick)

View file

@ -180,7 +180,8 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
public void updateEntity()
{
super.updateEntity();
FluidUtils.drainContainers(this, inventory, 0, 1);
if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick)

View file

@ -163,7 +163,8 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
public void updateEntity()
{
super.updateEntity();
FluidUtils.drainContainers(this, inventory, 0, 1);
if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick)