Fixed tank fluid rendering

This took a bit of time too do plus rewriting BuildCraft fluid render
code to just find out they registered the texture path wrong
This commit is contained in:
DarkGuardsman 2013-07-15 19:21:55 -04:00
parent c6dbe71cfe
commit 4404f4feab
6 changed files with 31 additions and 31 deletions

View file

@ -136,7 +136,14 @@ public class NetworkFluidTiles extends NetworkTileEntities
}
}
}
this.combinedStorage().setFluid(new FluidStack(fluid, volume));
if (fluid != null)
{
this.combinedStorage().setFluid(new FluidStack(fluid, volume));
}
else
{
this.combinedStorage().setFluid(null);
}
this.loadedLiquids = true;
}

View file

@ -10,7 +10,7 @@ import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.api.ColorCode;
import dark.core.render.LiquidRenderer;
import dark.core.render.FluidBlockRenderer;
import dark.core.render.RenderMachine;
import dark.fluid.client.model.ModelTankSide;
import dark.fluid.common.machines.TileEntityTank;
@ -42,28 +42,27 @@ public class RenderTank extends RenderMachine
render = ((TileEntityTank) tileEntity).renderConnection;
color = ((TileEntityTank) tileEntity).getColor();
}
if (liquid != null && liquid.amount > 0)
if (liquid != null && liquid.amount > 100)
{
int[] displayList = LiquidRenderer.getLiquidDisplayLists(liquid, tileEntity.worldObj, false);
if (displayList != null)
{
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTextureByName("",LiquidRenderer.getLiquidSheet(liquid.getFluid()));
int[] displayList = FluidBlockRenderer.getFluidDisplayLists(liquid, tileEntity.worldObj, false);
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glScalef(1.01F, 1.01F, 1.01F);
int cap = (tileEntity instanceof TileEntityTank ? ((TileEntityTank) tileEntity).getTank().getCapacity() : 8000);
GL11.glCallList(displayList[(int) ((float) Math.min(liquid.amount, cap) / (float) (cap) * (LiquidRenderer.DISPLAY_STAGES - 1))]);
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
func_110628_a(FluidBlockRenderer.getFluidSheet(liquid));
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glScalef(1.01F, 1.01F, 1.01F);
int cap = tileEntity instanceof TileEntityTank ? ((TileEntityTank)tileEntity).getTankSize() : liquid.amount;
GL11.glCallList(displayList[(int) ((float) liquid.amount / (float) (cap) * (FluidBlockRenderer.DISPLAY_STAGES - 1))]);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
bindTextureByName(this.getTexture(tileEntity.getBlockType().blockID, tileEntity.getBlockMetadata()));

View file

@ -88,7 +88,7 @@ public class FluidMech extends DummyModContainer
public static ModMetadata meta;
/* RESOURCE FILE PATHS */
public static final String DIRECTORY_NO_SLASH = "assets/fm/";
public static final String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/";
public static final String DIRECTORY = "/" + DIRECTORY_NO_SLASH;
public static final String LANGUAGE_PATH = DIRECTORY + "languages/";
public static final String SOUND_PATH = DIRECTORY + "audio/";
@ -135,7 +135,6 @@ public class FluidMech extends DummyModContainer
/* LOGGER - EXTENDS FORGE'S LOG SYSTEM */
public static Logger FMLog = Logger.getLogger(FluidMech.MOD_NAME);
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
@ -150,10 +149,10 @@ public class FluidMech extends DummyModContainer
MinecraftForge.EVENT_BUS.register(new FluidRestrictionHandler());
/* CONFIGS */
CONFIGURATION.load();
/* LIQUID DIRECTORY CALL */
Fluid waste = new Fluid("waste").setBlockID(FluidMech.CONFIGURATION.getBlock("WasteLiquid", BLOCK_ID_PREFIX + 7).getInt());
/* BLOCK DECLARATION -- CONFIG LOADER */
blockGenPipe = new BlockPipe(FluidMech.CONFIGURATION.getBlock("Pipes", BLOCK_ID_PREFIX).getInt());
blockMachine = new BlockPumpMachine(FluidMech.CONFIGURATION.getBlock("Machines", BLOCK_ID_PREFIX + 1).getInt());

View file

@ -232,7 +232,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
if (this.fakeTank != null)
if (this.fakeTank != null && this.fakeTank.getFluid() != null)
{
nbt.setTag("FluidTank", this.fakeTank.getFluid().writeToNBT(new NBTTagCompound()));
}

View file

@ -1,7 +1,5 @@
package dark.fluid.common.pipes.tele;
import java.util.List;
import dark.fluid.api.INetworkPipe;
/** Used by IFluidNetworkPart to signal this block is remotely connected to another network. It will
@ -17,7 +15,4 @@ public interface INetworkConnector extends INetworkPipe
public String getOwner();
public void setOwner(String username);
/** gets a list off all INetworkConnector this pipe shares frequency and owner with */
public List<INetworkConnector> getConnectedParts();
}

View file

@ -109,7 +109,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
if (this.tank != null)
if (this.tank != null && this.tank.getFluid() != null)
{
nbt.setTag("FluidTank", this.tank.getFluid().writeToNBT(new NBTTagCompound()));
}