Merge branch '6.4.x' of github.com:BuildCraft/BuildCraft into 6.5.x

This commit is contained in:
asiekierka 2015-04-10 21:04:27 +02:00
commit b6ac3bb406
9 changed files with 154 additions and 85 deletions

View file

@ -243,8 +243,12 @@ public class MappingRegistry {
for (Block b : idToBlock) { for (Block b : idToBlock) {
NBTTagCompound sub = new NBTTagCompound(); NBTTagCompound sub = new NBTTagCompound();
sub.setString("name", String name = Block.blockRegistry.getNameForObject(b);
Block.blockRegistry.getNameForObject(b)); if (name == null || name.length() == 0) {
BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + ") has an empty registry name! This is a bug!");
} else {
sub.setString("name", name);
}
blocksMapping.appendTag(sub); blocksMapping.appendTag(sub);
} }
@ -254,8 +258,12 @@ public class MappingRegistry {
for (Item i : idToItem) { for (Item i : idToItem) {
NBTTagCompound sub = new NBTTagCompound(); NBTTagCompound sub = new NBTTagCompound();
sub.setString("name", String name = Item.itemRegistry.getNameForObject(i);
Item.itemRegistry.getNameForObject(i)); if (name == null || name.length() == 0) {
BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + ") has an empty registry name! This is a bug!");
} else {
sub.setString("name", name);
}
itemsMapping.appendTag(sub); itemsMapping.appendTag(sub);
} }
@ -278,6 +286,12 @@ public class MappingRegistry {
for (int i = 0; i < blocksMapping.tagCount(); ++i) { for (int i = 0; i < blocksMapping.tagCount(); ++i) {
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i); NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
if (!sub.hasKey("name")) {
// Keeping the order correct
idToBlock.add(null);
BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
continue;
}
String name = sub.getString("name"); String name = sub.getString("name");
Block b = null; Block b = null;
@ -299,6 +313,12 @@ public class MappingRegistry {
for (int i = 0; i < itemsMapping.tagCount(); ++i) { for (int i = 0; i < itemsMapping.tagCount(); ++i) {
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i); NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
if (!sub.hasKey("name")) {
// Keeping the order correct
idToItem.add(null);
BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
continue;
}
String name = sub.getString("name"); String name = sub.getString("name");
Item item = null; Item item = null;

View file

@ -0,0 +1,4 @@
Bugfixes:
[#2621] FluidStack crash with Forge 1355+ (asie)
Crash on invalid mapping - instead reports error to console (asie)
Fluid dupe bug with pump robot (hea3ven)

View file

@ -1,3 +1,3 @@
1.6.4:BuildCraft:4.2.2 1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.16 1.7.2:BuildCraft:6.0.16
1.7.10:BuildCraft:6.4.8 1.7.10:BuildCraft:6.4.9

View file

@ -1,5 +1,7 @@
package buildcraft.core.tablet; package buildcraft.core.tablet;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import buildcraft.api.tablet.ITablet; import buildcraft.api.tablet.ITablet;
import buildcraft.api.tablet.TabletBitmap; import buildcraft.api.tablet.TabletBitmap;
@ -16,28 +18,58 @@ public class TabletProgramMenu extends TabletProgram {
this.tablet = tablet; this.tablet = tablet;
} }
public String[] split(String text, TabletFont font, int width) {
List<String> lines = new ArrayList<String>();
int x = 0;
String line = "";
boolean first = true;
for (String s : text.split(" ")) {
String ts = first ? s : " " + s;
int w = font.getStringWidth(ts);
if (x + w > width) {
x = 0;
ts = s;
lines.add(line);
line = "";
}
x += w;
line += ts;
first = false;
}
if (line.length() > 0) {
lines.add(line);
}
return lines.toArray(new String[lines.size()]);
}
public void tick(float time) { public void tick(float time) {
t+=time; t+=time;
if (!init && t > 2 && tablet.getSide() == Side.CLIENT) { if (!init && t > 2 && tablet.getSide() == Side.CLIENT) {
TabletBitmap bitmap = new TabletBitmap(244, 306); TabletBitmap bitmap = new TabletBitmap(244, 306);
try { try {
TabletFont text = TabletFontManager.INSTANCE.register("DejaVu11", TabletProgramMenu.class.getClassLoader().getResourceAsStream("assets/buildcraftcore/tablet/11.pf2")); TabletFont font = TabletFontManager.INSTANCE.register("DejaVu11", TabletProgramMenu.class.getClassLoader().getResourceAsStream("assets/buildcraftcore/tablet/11.pf2"));
String lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque condimentum, nulla in tincidunt finibus, dolor enim condimentum felis, vitae vulputate lorem turpis nec purus. Nulla iaculis sed turpis in lacinia. Aliquam consectetur leo sit amet placerat blandit. Maecenas euismod magna eros, quis efficitur quam luctus mollis. Nulla facilisi. Quisque tempor turpis ipsum, ut auctor diam hendrerit dictum. Phasellus id viverra purus. Ut sagittis felis eu odio sagittis, vitae mollis felis feugiat. Morbi mi elit, varius id fringilla vel, vehicula ac risus. Curabitur aliquam orci at mollis posuere. Nam vitae neque tincidunt orci rhoncus rutrum."; String lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque condimentum, nulla in tincidunt finibus, dolor enim condimentum felis, vitae vulputate lorem turpis nec purus. Nulla iaculis sed turpis in lacinia. Aliquam consectetur leo sit amet placerat blandit. Maecenas euismod magna eros, quis efficitur quam luctus mollis. Nulla facilisi. Quisque tempor turpis ipsum, ut auctor diam hendrerit dictum. Phasellus id viverra purus. Ut sagittis felis eu odio sagittis, vitae mollis felis feugiat. Morbi mi elit, varius id fringilla vel, vehicula ac risus. Curabitur aliquam orci at mollis posuere. Nam vitae neque tincidunt orci rhoncus rutrum.";
int x = 0;
int y = 0; int y = 0;
boolean first = true; String[] lines = split(lorem, font, 244);
for (int i = 0; i < lines.length; i++) {
for (String s : lorem.split(" ")) { String line = lines[i];
String ts = first ? s : " " + s; String[] words = line.split(" ");
int width = text.getStringWidth(ts); float justifyValue = 0;
if (x + width > 244) { if (i < lines.length - 1) {
x = 0; int widthNoSpaces = 0;
y += text.getHeight() + 1; for (String s : words) {
ts = s; widthNoSpaces += font.getStringWidth(s);
}
justifyValue = (244 - widthNoSpaces) / (float) (words.length - 1);
} }
x += text.draw(bitmap, ts, x, y, 7); float x = 0;
first = false; for (String s: words) {
x += font.draw(bitmap, s, (int) x, y, 7);
x += justifyValue;
}
y += font.getHeight() + 1;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -47,4 +79,4 @@ public class TabletProgramMenu extends TabletProgram {
init = true; init = true;
} }
} }
} }

View file

@ -9,13 +9,11 @@
package buildcraft.robotics.ai; package buildcraft.robotics.ai;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.core.BlockIndex; import buildcraft.api.core.BlockIndex;
import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.utils.BlockUtils;
public class AIRobotPumpBlock extends AIRobot { public class AIRobotPumpBlock extends AIRobot {
@ -48,18 +46,13 @@ public class AIRobotPumpBlock extends AIRobot {
if (waited < 40) { if (waited < 40) {
waited++; waited++;
} else { } else {
Fluid fluid = FluidRegistry.lookupFluidForBlock(robot.worldObj.getBlock(blockToPump.x, blockToPump.y, FluidStack fluidStack = BlockUtils.drainBlock(robot.worldObj, blockToPump.x, blockToPump.y, blockToPump.z, false);
blockToPump.z)); if (fluidStack != null) {
if (robot.fill(ForgeDirection.UNKNOWN, fluidStack, true) > 0) {
if (fluid != null) { BlockUtils.drainBlock(robot.worldObj, blockToPump.x, blockToPump.y,
pumped = robot.fill(ForgeDirection.UNKNOWN, blockToPump.z, true);
new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME), true);
if (pumped > 0) {
robot.worldObj.setBlockToAir(blockToPump.x, blockToPump.y, blockToPump.z);
} }
} }
terminate(); terminate();
} }

View file

@ -41,6 +41,7 @@ import buildcraft.transport.pipes.PipeFluidsStone;
import buildcraft.transport.pipes.PipeFluidsVoid; import buildcraft.transport.pipes.PipeFluidsVoid;
import buildcraft.transport.pipes.PipeFluidsWood; import buildcraft.transport.pipes.PipeFluidsWood;
import buildcraft.transport.pipes.events.PipeEventFluid; import buildcraft.transport.pipes.events.PipeEventFluid;
import buildcraft.transport.utils.FluidRenderData;
public class PipeTransportFluids extends PipeTransport implements IFluidHandler { public class PipeTransportFluids extends PipeTransport implements IFluidHandler {
public static final Map<Class<? extends Pipe<?>>, Integer> fluidCapacities = new HashMap<Class<? extends Pipe<?>>, Integer>(); public static final Map<Class<? extends Pipe<?>>, Integer> fluidCapacities = new HashMap<Class<? extends Pipe<?>>, Integer>();
@ -160,8 +161,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public byte initClient = 0; public byte initClient = 0;
public int travelDelay = 12; public int travelDelay = 12;
public int flowRate; public int flowRate;
public FluidStack[] renderCache = new FluidStack[orientations.length]; public FluidRenderData[] renderCache = new FluidRenderData[orientations.length];
public int[] colorRenderCache = new int[orientations.length];
public final PipeSection[] internalTanks = new PipeSection[orientations.length]; public final PipeSection[] internalTanks = new PipeSection[orientations.length];
private final TransferState[] transferState = new TransferState[directions.length]; private final TransferState[] transferState = new TransferState[directions.length];
private final int[] inputPerTick = new int[directions.length]; private final int[] inputPerTick = new int[directions.length];
@ -258,12 +258,11 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
} }
} }
FluidStack[] renderCacheCopy = this.renderCache.clone(); FluidRenderData[] renderCacheCopy = this.renderCache.clone();
int[] colorRenderCacheCopy = this.colorRenderCache.clone();
for (ForgeDirection dir : orientations) { for (ForgeDirection dir : orientations) {
FluidStack current = internalTanks[dir.ordinal()].getFluid(); FluidStack current = internalTanks[dir.ordinal()].getFluid();
FluidStack prev = renderCacheCopy[dir.ordinal()]; FluidStack prev = renderCacheCopy[dir.ordinal()] != null ? renderCacheCopy[dir.ordinal()].getFluidStack() : null;
if (current != null && current.getFluid() == null) { if (current != null && current.getFluid() == null) {
continue; continue;
@ -276,11 +275,9 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (prev == null ^ current == null) { if (prev == null ^ current == null) {
changed = true; changed = true;
if (current != null) { if (current != null) {
renderCacheCopy[dir.ordinal()] = current.copy(); renderCacheCopy[dir.ordinal()] = new FluidRenderData(current);
colorRenderCacheCopy[dir.ordinal()] = current.getFluid().getColor(current);
} else { } else {
renderCacheCopy[dir.ordinal()] = null; renderCacheCopy[dir.ordinal()] = null;
colorRenderCacheCopy[dir.ordinal()] = 0xFFFFFF;
} }
delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT); delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT);
delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_AMOUNT_BIT); delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_AMOUNT_BIT);
@ -293,8 +290,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (!prev.equals(current) || initPacket) { if (!prev.equals(current) || initPacket) {
changed = true; changed = true;
renderCacheCopy[dir.ordinal()] = current; renderCacheCopy[dir.ordinal()] = new FluidRenderData(current);
colorRenderCacheCopy[dir.ordinal()] = current.getFluid().getColor(current);
delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT); delta.set(dir.ordinal() * PacketFluidUpdate.FLUID_DATA_NUM + PacketFluidUpdate.FLUID_ID_BIT);
} }
@ -313,13 +309,11 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (persistChange) { if (persistChange) {
this.renderCache = renderCacheCopy; this.renderCache = renderCacheCopy;
this.colorRenderCache = colorRenderCacheCopy;
} }
if (changed || initPacket) { if (changed || initPacket) {
PacketFluidUpdate packet = new PacketFluidUpdate(container.xCoord, container.yCoord, container.zCoord, initPacket); PacketFluidUpdate packet = new PacketFluidUpdate(container.xCoord, container.yCoord, container.zCoord, initPacket);
packet.renderCache = renderCacheCopy; packet.renderCache = renderCacheCopy;
packet.colorRenderCache = colorRenderCacheCopy;
packet.delta = delta; packet.delta = delta;
return packet; return packet;
} }
@ -528,7 +522,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
internalTanks[direction.ordinal()].reset(); internalTanks[direction.ordinal()].reset();
transferState[direction.ordinal()] = TransferState.None; transferState[direction.ordinal()] = TransferState.None;
renderCache[direction.ordinal()] = null; renderCache[direction.ordinal()] = null;
colorRenderCache[direction.ordinal()] = 0xFFFFFF;
} }
} }
} }

View file

@ -13,13 +13,13 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.core.lib.network.PacketCoordinates; import buildcraft.core.lib.network.PacketCoordinates;
import buildcraft.core.lib.utils.BitSetUtils; import buildcraft.core.lib.utils.BitSetUtils;
import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketIds;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.utils.FluidRenderData;
public class PacketFluidUpdate extends PacketCoordinates { public class PacketFluidUpdate extends PacketCoordinates {
@ -27,8 +27,7 @@ public class PacketFluidUpdate extends PacketCoordinates {
public static int FLUID_AMOUNT_BIT = 1; public static int FLUID_AMOUNT_BIT = 1;
public static int FLUID_DATA_NUM = 2; public static int FLUID_DATA_NUM = 2;
public FluidStack[] renderCache = new FluidStack[ForgeDirection.values().length]; public FluidRenderData[] renderCache = new FluidRenderData[ForgeDirection.values().length];
public int[] colorRenderCache = new int[ForgeDirection.values().length];
public BitSet delta; public BitSet delta;
public PacketFluidUpdate(int xCoord, int yCoord, int zCoord) { public PacketFluidUpdate(int xCoord, int yCoord, int zCoord) {
@ -69,7 +68,6 @@ public class PacketFluidUpdate extends PacketCoordinates {
PipeTransportFluids transLiq = (PipeTransportFluids) pipe.pipe.transport; PipeTransportFluids transLiq = (PipeTransportFluids) pipe.pipe.transport;
renderCache = transLiq.renderCache; renderCache = transLiq.renderCache;
colorRenderCache = transLiq.colorRenderCache;
byte[] dBytes = new byte[2]; byte[] dBytes = new byte[2];
data.readBytes(dBytes); data.readBytes(dBytes);
@ -79,15 +77,21 @@ public class PacketFluidUpdate extends PacketCoordinates {
for (ForgeDirection dir : ForgeDirection.values()) { for (ForgeDirection dir : ForgeDirection.values()) {
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) { if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
int id = data.readShort();
int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0; int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0;
renderCache[dir.ordinal()] = new FluidStack(data.readShort(), amt); int color = id != 0 ? data.readInt() : 0xFFFFFF;
colorRenderCache[dir.ordinal()] = data.readInt();
renderCache[dir.ordinal()] = new FluidRenderData(id, amt, color);
} }
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) { if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {
if (renderCache[dir.ordinal()] == null) { int amt = Math.min(transLiq.getCapacity(), data.readUnsignedShort());
renderCache[dir.ordinal()] = new FluidStack(0, 0);
} if (renderCache[dir.ordinal()] != null) {
renderCache[dir.ordinal()].amount = Math.min(transLiq.getCapacity(), data.readUnsignedShort()); renderCache[dir.ordinal()].amount = amt;
} else {
renderCache[dir.ordinal()] = new FluidRenderData(0, amt, 0xFFFFFF);
}
} }
} }
} }
@ -101,15 +105,14 @@ public class PacketFluidUpdate extends PacketCoordinates {
data.writeBytes(dBytes); data.writeBytes(dBytes);
for (ForgeDirection dir : ForgeDirection.values()) { for (ForgeDirection dir : ForgeDirection.values()) {
FluidStack liquid = renderCache[dir.ordinal()]; FluidRenderData liquid = renderCache[dir.ordinal()];
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) { if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_ID_BIT)) {
if (liquid != null) { if (liquid != null && liquid.fluidID != 0) {
data.writeShort(liquid.fluidID); data.writeShort(liquid.fluidID);
data.writeInt(colorRenderCache[dir.ordinal()]); data.writeInt(liquid.color);
} else { } else {
data.writeShort(0); data.writeShort(0);
data.writeInt(0xFFFFFF);
} }
} }
if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) { if (delta.get(dir.ordinal() * FLUID_DATA_NUM + FLUID_AMOUNT_BIT)) {

View file

@ -27,7 +27,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftCore.RenderMode; import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
@ -50,6 +50,7 @@ import buildcraft.transport.PipeTransportPower;
import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import buildcraft.transport.gates.GatePluggable; import buildcraft.transport.gates.GatePluggable;
import buildcraft.transport.utils.FluidRenderData;
public class PipeRendererTESR extends TileEntitySpecialRenderer { public class PipeRendererTESR extends TileEntitySpecialRenderer {
public static final float DISPLAY_MULTIPLIER = 0.1f; public static final float DISPLAY_MULTIPLIER = 0.1f;
@ -100,17 +101,23 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
return displayFluidLists.get(liquidId); return displayFluidLists.get(liquidId);
} }
Fluid fluid = FluidRegistry.getFluid(liquidId);
if (fluid == null) {
return null;
}
DisplayFluidList d = new DisplayFluidList(); DisplayFluidList d = new DisplayFluidList();
displayFluidLists.put(liquidId, d); displayFluidLists.put(liquidId, d);
RenderInfo block = new RenderInfo(); RenderInfo block = new RenderInfo();
Fluid fluid = FluidRegistry.getFluid(liquidId);
if (fluid.getBlock() != null) { if (fluid.getBlock() != null) {
block.baseBlock = fluid.getBlock(); block.baseBlock = fluid.getBlock();
} else { } else {
block.baseBlock = Blocks.water; block.baseBlock = Blocks.water;
} }
block.texture = fluid.getStillIcon(); block.texture = fluid.getStillIcon();
float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
@ -661,8 +668,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
boolean needsRender = false; boolean needsRender = false;
for (int i = 0; i < 7; ++i) { for (int i = 0; i < 7; ++i) {
FluidStack fluidStack = trans.renderCache[i]; FluidRenderData renderData = trans.renderCache[i];
if (fluidStack != null && fluidStack.amount > 0) { if (renderData != null && renderData.amount > 0) {
needsRender = true; needsRender = true;
break; break;
} }
@ -688,9 +695,9 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
int i = side.ordinal(); int i = side.ordinal();
FluidStack fluidStack = trans.renderCache[i]; FluidRenderData fluidRenderData = trans.renderCache[i];
if (fluidStack == null || fluidStack.amount <= 0) { if (fluidRenderData == null || fluidRenderData.amount <= 0) {
continue; continue;
} }
@ -698,13 +705,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
continue; continue;
} }
DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj()); DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
if (d == null) { if (d == null) {
continue; continue;
} }
int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); int stage = (int) ((float) fluidRenderData.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
GL11.glPushMatrix(); GL11.glPushMatrix();
int list = 0; int list = 0;
@ -733,21 +740,21 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
default: default:
} }
bindTexture(TextureMap.locationBlocksTexture); bindTexture(TextureMap.locationBlocksTexture);
RenderUtils.setGLColorFromInt(trans.colorRenderCache[i]); RenderUtils.setGLColorFromInt(fluidRenderData.color);
GL11.glCallList(list); GL11.glCallList(list);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
// CENTER // CENTER
FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()]; FluidRenderData fluidRenderData = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];
if (fluidStack != null && fluidStack.amount > 0) { if (fluidRenderData != null && fluidRenderData.amount > 0) {
DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj()); DisplayFluidList d = getDisplayFluidLists(fluidRenderData.fluidID, pipe.container.getWorldObj());
if (d != null) { if (d != null) {
int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); int stage = (int) ((float) fluidRenderData.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
bindTexture(TextureMap.locationBlocksTexture); bindTexture(TextureMap.locationBlocksTexture);
RenderUtils.setGLColorFromInt(trans.colorRenderCache[ForgeDirection.UNKNOWN.ordinal()]); RenderUtils.setGLColorFromInt(fluidRenderData.color);
if (above) { if (above) {
GL11.glCallList(d.centerVertical[stage]); GL11.glCallList(d.centerVertical[stage]);
@ -764,17 +771,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
private DisplayFluidList getListFromBuffer(FluidStack stack, World world) {
int liquidId = stack.fluidID;
if (liquidId == 0) {
return null;
}
return getDisplayFluidLists(liquidId, world);
}
private void renderSolids(Pipe<PipeTransportItems> pipe, double x, double y, double z, float f) { private void renderSolids(Pipe<PipeTransportItems> pipe, double x, double y, double z, float f) {
GL11.glPushMatrix(); GL11.glPushMatrix();

View file

@ -0,0 +1,28 @@
package buildcraft.transport.utils;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class FluidRenderData {
public int fluidID, amount, color;
public FluidRenderData(int fluidID, int amount, int color) {
this.fluidID = fluidID;
this.amount = amount;
this.color = color;
}
public FluidRenderData(FluidStack stack) {
this(stack.getFluid().getID(), stack.amount, stack.getFluid().getColor(stack));
}
public FluidStack getFluidStack() {
Fluid fluid = FluidRegistry.getFluid(fluidID);
if (fluid != null) {
return new FluidStack(fluid, amount);
} else {
return null;
}
}
}