Save and write to NBT fro Copper Tank.You can right click Copper Tank with containers to put fluid in them.
(Buckets are not fluid containers...)dev
parent
8b5605da5c
commit
0ddf83421c
|
@ -40,7 +40,7 @@ public class BlockCopperTankRenderer implements ISimpleBlockRenderingHandler
|
|||
te.blockType = block;
|
||||
te.blockMetadata = metadata;
|
||||
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(te, 1.0D, 1.0D, 1.0D, 0.0F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(te, -0.5D, -0.5D, -0.5D, 0.0F);
|
||||
GL11.glEnable(32826);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,12 @@
|
|||
package steamcraft.common.blocks.machines;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import steamcraft.client.lib.RenderIDs;
|
||||
import steamcraft.common.tiles.TileCopperTank;
|
||||
|
||||
|
@ -58,7 +62,6 @@ public class BlockCopperTank extends BaseContainerBlock
|
|||
return RenderIDs.blockCopperTankRI;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int sideIThink, float posXClickedIThink,
|
||||
float p_149727_8_, float posZClickedIThink)
|
||||
|
@ -66,25 +69,23 @@ public class BlockCopperTank extends BaseContainerBlock
|
|||
if (!world.isRemote)
|
||||
{
|
||||
TileCopperTank tank = (TileCopperTank) world.getTileEntity(x, y, z);
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if((player.getHeldItem() != null) && (player.getHeldItem().getItem() instanceof ItemFluidContainer))
|
||||
if(stack != null && stack.getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
ItemFluidContainer container = (ItemFluidContainer) player.getHeldItem().getItem();
|
||||
|
||||
if(tank.tank.getFluid() != null)
|
||||
return true;
|
||||
else if((container.getFluid(player.getHeldItem()) != null) && (TileCopperTank.capacity - tank.tank.getFluidAmount()
|
||||
<= container.getFluid(player.getHeldItem()).amount))
|
||||
IFluidContainerItem container = (IFluidContainerItem) stack.getItem();
|
||||
|
||||
int amount = 0;
|
||||
if((amount = tank.fill(ForgeDirection.getOrientation(sideIThink), container.getFluid(stack), false)) > 0)
|
||||
{
|
||||
tank.fill(ForgeDirection.getOrientation(sideIThink), container.getFluid(player.getHeldItem()).copy(), true);
|
||||
container.drain(player.getHeldItem(), container.getFluid(player.getHeldItem()).amount, true);
|
||||
amount = tank.fill(ForgeDirection.getOrientation(sideIThink), container.getFluid(stack), true);
|
||||
container.drain(stack, amount, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
package steamcraft.common.tiles;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
@ -29,12 +30,13 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
|||
*/
|
||||
public class TileCopperTank extends TileEntity implements IFluidHandler
|
||||
{
|
||||
private static int ticksTillFluidUpdate = 5;
|
||||
private static int ticksTillFluidUpdate = 100;
|
||||
public static int capacity = 20000;
|
||||
|
||||
public FluidTank tank;
|
||||
public float fluidScaled = 0;
|
||||
private int ticksSinceUpdate = 0;
|
||||
private int lastAmount = 0;
|
||||
|
||||
public TileCopperTank()
|
||||
{
|
||||
|
@ -46,6 +48,12 @@ public class TileCopperTank extends TileEntity implements IFluidHandler
|
|||
{
|
||||
if(!this.worldObj.isRemote)
|
||||
{
|
||||
if (tank.getFluidAmount() != this.lastAmount)
|
||||
{
|
||||
updateClientFluid();
|
||||
this.lastAmount = tank.getFluidAmount();
|
||||
}
|
||||
|
||||
ticksSinceUpdate++;
|
||||
|
||||
if (this.ticksSinceUpdate >= ticksTillFluidUpdate)
|
||||
|
@ -71,6 +79,22 @@ public class TileCopperTank extends TileEntity implements IFluidHandler
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
this.tank.writeToNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
|
||||
this.tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue