Make Tanks emit light if the Fluid glows

This commit is contained in:
CovertJaguar 2013-09-03 02:11:14 -07:00
parent ddc203fe59
commit ae77912afd
2 changed files with 27 additions and 3 deletions

View file

@ -23,6 +23,7 @@ import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -157,4 +158,14 @@ public class BlockTank extends BlockContainer {
textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side"); textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side");
textureTop = par1IconRegister.registerIcon("buildcraft:tank_top"); textureTop = par1IconRegister.registerIcon("buildcraft:tank_top");
} }
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileTank) {
TileTank tank = (TileTank) tile;
return tank.getFluidLightLevel();
}
return super.getLightValue(world, x, y, z);
}
} }

View file

@ -21,6 +21,7 @@ import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.EnumSkyBlock;
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;
@ -35,18 +36,25 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
public final TankManager tankManager = new TankManager(tank); public final TankManager tankManager = new TankManager(tank);
public boolean hasUpdate = false; public boolean hasUpdate = false;
public SafeTimeTracker tracker = new SafeTimeTracker(); public SafeTimeTracker tracker = new SafeTimeTracker();
private int prevLightValue = 0;
/* UPDATING */ /* UPDATING */
@Override @Override
public void updateEntity() { public void updateEntity() {
if (CoreProxy.proxy.isRenderWorld(worldObj)) if (CoreProxy.proxy.isRenderWorld(worldObj)) {
int lightValue = getFluidLightLevel();
if (prevLightValue != lightValue) {
prevLightValue = lightValue;
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
}
return; return;
}
// Have liquid flow down into tanks below if any. // Have liquid flow down into tanks below if any.
if (tank.getFluid() != null) { if (tank.getFluid() != null) {
moveFluidBelow(); moveFluidBelow();
} }
if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) { if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
sendNetworkUpdate(); sendNetworkUpdate();
hasUpdate = false; hasUpdate = false;
@ -242,4 +250,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
public boolean canDrain(ForgeDirection from, Fluid fluid) { public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false; return false;
} }
public int getFluidLightLevel() {
FluidStack tankFluid = tank.getFluid();
return tankFluid == null ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
}
} }