Merge branch 'master' of https://bitbucket.org/calclavia/resonant-induction
This commit is contained in:
commit
a57c87d757
1 changed files with 46 additions and 9 deletions
|
@ -1,10 +1,10 @@
|
||||||
package resonantinduction.archaic.process;
|
package resonantinduction.archaic.process;
|
||||||
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
|
||||||
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
|
@ -13,22 +13,28 @@ import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
import resonantinduction.core.ResonantInduction;
|
||||||
|
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.prefab.tile.TileExternalInventory;
|
import calclavia.lib.prefab.tile.TileExternalInventory;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns molten fuilds into ingots.
|
* Turns molten fuilds into ingots.
|
||||||
*
|
*
|
||||||
* 1 m^3 of molten fluid = 1 block
|
* 1 m^3 of molten fluid = 1 block
|
||||||
* Approximately 110 L of fluid = 1 ingot.
|
* Approximately 100-110 L of fluid = 1 ingot.
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileCast extends TileExternalInventory implements IFluidHandler
|
public class TileCast extends TileExternalInventory implements IFluidHandler, IPacketReceiver
|
||||||
{
|
{
|
||||||
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
private final int amountPerIngot = 110;
|
private final int amountPerIngot = 100;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUpdate()
|
public boolean canUpdate()
|
||||||
|
@ -36,10 +42,34 @@ public class TileCast extends TileExternalInventory implements IFluidHandler
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
this.writeToNBT(nbt);
|
||||||
|
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInventoryChanged()
|
public void onInventoryChanged()
|
||||||
{
|
{
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
if (worldObj != null)
|
||||||
|
{
|
||||||
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,8 +84,15 @@ public class TileCast extends TileExternalInventory implements IFluidHandler
|
||||||
|
|
||||||
if (block instanceof BlockFluidMaterial)
|
if (block instanceof BlockFluidMaterial)
|
||||||
{
|
{
|
||||||
// TODO: Fix overfill.
|
/**
|
||||||
tank.fill(((BlockFluidMaterial) block).drain(worldObj, checkPos.intX(), checkPos.intY(), checkPos.intZ(), true), true);
|
* Only drain if everything is accepted by the tank.
|
||||||
|
*/
|
||||||
|
FluidStack drainStack = ((BlockFluidMaterial) block).drain(worldObj, checkPos.intX(), checkPos.intY(), checkPos.intZ(), false);
|
||||||
|
|
||||||
|
if (drainStack.amount == tank.fill(drainStack, false))
|
||||||
|
{
|
||||||
|
tank.fill(((BlockFluidMaterial) block).drain(worldObj, checkPos.intX(), checkPos.intY(), checkPos.intZ(), true), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue