Firebox now accepts lava fluid
This commit is contained in:
parent
b53af54bac
commit
73c82146c4
2 changed files with 91 additions and 30 deletions
|
@ -11,9 +11,13 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.resource.ResourceGenerator;
|
import resonantinduction.core.resource.ResourceGenerator;
|
||||||
import resonantinduction.core.resource.TileMaterial;
|
import resonantinduction.core.resource.TileMaterial;
|
||||||
|
@ -21,6 +25,7 @@ import universalelectricity.api.energy.EnergyStorageHandler;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
import calclavia.lib.network.IPacketSender;
|
import calclavia.lib.network.IPacketSender;
|
||||||
|
import calclavia.lib.network.Synced;
|
||||||
import calclavia.lib.prefab.tile.TileElectricalInventory;
|
import calclavia.lib.prefab.tile.TileElectricalInventory;
|
||||||
import calclavia.lib.thermal.BoilEvent;
|
import calclavia.lib.thermal.BoilEvent;
|
||||||
|
|
||||||
|
@ -32,7 +37,7 @@ import com.google.common.io.ByteArrayDataInput;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileFirebox extends TileElectricalInventory implements IPacketSender, IPacketReceiver
|
public class TileFirebox extends TileElectricalInventory implements IPacketReceiver, IFluidHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* One coal = 4MJ, one coal lasts 80 seconds. Therefore, we are producing 50000 watts.
|
* One coal = 4MJ, one coal lasts 80 seconds. Therefore, we are producing 50000 watts.
|
||||||
|
@ -40,6 +45,8 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
* into fluids to increase their internal energy.
|
* into fluids to increase their internal energy.
|
||||||
*/
|
*/
|
||||||
private final long POWER = 50000;
|
private final long POWER = 50000;
|
||||||
|
|
||||||
|
@Synced
|
||||||
private int burnTime;
|
private int burnTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +64,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
|
|
||||||
public TileFirebox()
|
public TileFirebox()
|
||||||
{
|
{
|
||||||
energy = new EnergyStorageHandler(POWER * 2, POWER / 20);
|
energy = new EnergyStorageHandler(POWER, (POWER * 2) / 20);
|
||||||
setIO(ForgeDirection.UP, 0);
|
setIO(ForgeDirection.UP, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +73,36 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
{
|
{
|
||||||
if (!worldObj.isRemote)
|
if (!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if (energy.checkExtract())
|
/**
|
||||||
|
* Extract fuel source for burn time.
|
||||||
|
*/
|
||||||
|
FluidStack drainFluid = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false);
|
||||||
|
|
||||||
|
if (drainFluid != null && drainFluid.amount == FluidContainerRegistry.BUCKET_VOLUME)
|
||||||
|
{
|
||||||
|
if (burnTime == 0)
|
||||||
|
{
|
||||||
|
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||||
|
burnTime += 20000;
|
||||||
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isElectrical() && energy.checkExtract())
|
||||||
{
|
{
|
||||||
energy.extractEnergy();
|
energy.extractEnergy();
|
||||||
burnTime += 1;
|
|
||||||
|
if (burnTime == 0)
|
||||||
|
{
|
||||||
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
burnTime += 2;
|
||||||
}
|
}
|
||||||
else if (canBurn(this.getStackInSlot(0)))
|
else if (canBurn(this.getStackInSlot(0)))
|
||||||
{
|
{
|
||||||
if (burnTime == 0)
|
if (burnTime == 0)
|
||||||
{
|
{
|
||||||
burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0));
|
burnTime += TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0));
|
||||||
decrStackSize(0, 1);
|
decrStackSize(0, 1);
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +178,14 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Make biome sensitivity.
|
||||||
|
*/
|
||||||
|
public long getRequiredBoilWaterEnergy()
|
||||||
|
{
|
||||||
|
return requiredBoilWaterEnergy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
|
@ -181,34 +216,13 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.getPacketData(0).toArray());
|
return ResonantInduction.PACKET_ANNOTATION.getPacket(this);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1 - Description Packet
|
|
||||||
* 2 - Energy Update
|
|
||||||
* 3 - Tesla Beam
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ArrayList getPacketData(int type)
|
|
||||||
{
|
|
||||||
ArrayList data = new ArrayList();
|
|
||||||
data.add(this.burnTime);
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||||
{
|
{
|
||||||
try
|
this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
{
|
|
||||||
this.burnTime = data.readInt();
|
|
||||||
this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -216,6 +230,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
burnTime = nbt.getInteger("burnTime");
|
burnTime = nbt.getInteger("burnTime");
|
||||||
|
tank.readFromNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -223,5 +238,49 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setInteger("burnTime", burnTime);
|
nbt.setInteger("burnTime", burnTime);
|
||||||
|
tank.writeToNBT(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
|
|
||||||
|
/* IFluidHandler */
|
||||||
|
@Override
|
||||||
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
return tank.fill(resource, doFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||||
|
{
|
||||||
|
if (resource == null || !resource.isFluidEqual(tank.getFluid()))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tank.drain(resource.amount, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||||
|
{
|
||||||
|
return tank.drain(maxDrain, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return fluid == FluidRegistry.LAVA;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return new FluidTankInfo[] { tank.getInfo() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import resonantinduction.core.resource.fluid.TileFluidMixture;
|
||||||
import resonantinduction.core.resource.item.ItemOreResource;
|
import resonantinduction.core.resource.item.ItemOreResource;
|
||||||
import calclavia.components.tool.ToolMode;
|
import calclavia.components.tool.ToolMode;
|
||||||
import calclavia.lib.content.ContentRegistry;
|
import calclavia.lib.content.ContentRegistry;
|
||||||
|
import calclavia.lib.network.PacketAnnotation;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.network.PacketTile;
|
import calclavia.lib.network.PacketTile;
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
import calclavia.lib.utility.LanguageUtility;
|
||||||
|
@ -71,6 +72,7 @@ public class ResonantInduction
|
||||||
/** Packets */
|
/** Packets */
|
||||||
public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
|
public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
|
||||||
public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL);
|
public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL);
|
||||||
|
public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL);
|
||||||
|
|
||||||
/** Blocks and Items */
|
/** Blocks and Items */
|
||||||
public static Block blockOre;
|
public static Block blockOre;
|
||||||
|
@ -115,8 +117,8 @@ public class ResonantInduction
|
||||||
GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName());
|
GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName());
|
GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName());
|
||||||
|
|
||||||
//Already registered wih ContentRegistry
|
// Already registered wih ContentRegistry
|
||||||
//GameRegistry.registerTileEntity(TileMaterial.class, "ri_material");
|
// GameRegistry.registerTileEntity(TileMaterial.class, "ri_material");
|
||||||
GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture");
|
GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture");
|
||||||
Settings.save();
|
Settings.save();
|
||||||
proxy.preInit();
|
proxy.preInit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue