From ae77912afdd99687e841d74292d4d55da40a8497 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 3 Sep 2013 02:11:14 -0700 Subject: [PATCH] Make Tanks emit light if the Fluid glows --- common/buildcraft/factory/BlockTank.java | 11 +++++++++++ common/buildcraft/factory/TileTank.java | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index a23256cc..8ab8840a 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -23,6 +23,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -157,4 +158,14 @@ public class BlockTank extends BlockContainer { textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side"); 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); + } } diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index b90ceb56..43cc1d12 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -21,6 +21,7 @@ import java.io.DataOutputStream; import java.io.IOException; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -35,18 +36,25 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { public final TankManager tankManager = new TankManager(tank); public boolean hasUpdate = false; public SafeTimeTracker tracker = new SafeTimeTracker(); + private int prevLightValue = 0; /* UPDATING */ @Override 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; - + } + // Have liquid flow down into tanks below if any. if (tank.getFluid() != null) { moveFluidBelow(); } - + if (hasUpdate && tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) { sendNetworkUpdate(); hasUpdate = false; @@ -242,4 +250,9 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } + + public int getFluidLightLevel() { + FluidStack tankFluid = tank.getFluid(); + return tankFluid == null ? 0 : tankFluid.getFluid().getLuminosity(tankFluid); + } }