package xyz.brassgoggledcoders.steamagerevolution.modules.steam.tileentities;

import com.teamacronymcoders.base.tileentities.TileEntitySlowTick;

import net.minecraft.entity.EntityLiving;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import xyz.brassgoggledcoders.steamagerevolution.modules.steam.FluidTankSingleType;
import xyz.brassgoggledcoders.steamagerevolution.modules.steam.blocks.BlockSteamVent;

public class TileEntitySteamVent extends TileEntitySlowTick {

	public FluidTank tank = new FluidTankSingleType(Fluid.BUCKET_VOLUME * 3, "steam");

	@Override
	// TODO No real need to tick.
	public void updateTile() {
		World w = getWorld();
		BlockPos pos = getPos();
		if(w.isBlockPowered(pos) && this.tank.getFluidAmount() >= Fluid.BUCKET_VOLUME) {
			EnumFacing f = w.getBlockState(pos).getValue(BlockSteamVent.FACING);
			pos.offset(f);
			this.tank.drain(Fluid.BUCKET_VOLUME, true);
			for(EntityLiving e : w.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(pos))) {
				e.attackEntityFrom(DamageSource.inFire, 3F);
			}
			// TODO particles and noise
		}
	}

	@Override
	public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
		return (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
				|| super.hasCapability(capability, facing);
	}

	@Override
	public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
		if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
			return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
		return super.getCapability(capability, facing);
	}

	@Override
	public NBTTagCompound writeToDisk(NBTTagCompound tag) {
		tag.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
		return super.writeToDisk(tag);
	}

	@Override
	public void readFromDisk(NBTTagCompound tag) {
		tank.readFromNBT(tag.getCompoundTag("tank"));
		super.readFromDisk(tag);
	}

	@Override
	public NBTTagCompound writeToUpdatePacket(NBTTagCompound tag) {
		tank.writeToNBT(tag);
		return super.writeToUpdatePacket(tag);
	}

	@Override
	public void readFromUpdatePacket(NBTTagCompound tag) {
		tank.readFromNBT(tag);
		super.readFromUpdatePacket(tag);
	}

}

@@ -937,17 +937,17 @@
 OLUME * 
-3
+6
 , %22steam
@@ -1231,73 +1231,8 @@
 G);%0A
-%09%09%09pos.offset(f);%0A%09%09%09this.tank.drain(Fluid.BUCKET_VOLUME, true);%0A
 %09%09%09f
@@ -1316,16 +1316,26 @@
 edBB(pos
+.offset(f)
 ))) %7B%0A%09%09
@@ -1386,16 +1386,63 @@
 );%0A%09%09%09%7D%0A
+%09%09%09this.tank.drain(Fluid.BUCKET_VOLUME, true);%0A
 %09%09%09// TO

Fix steam vent position logic