fix RenderTank

This commit is contained in:
Flow86 2013-03-28 10:00:05 +01:00
parent f9b6980993
commit 4d92a9b918
2 changed files with 31 additions and 4 deletions

View file

@ -12,11 +12,14 @@ import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.Property;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
@ -53,6 +56,8 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE)
@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
@ -160,6 +165,18 @@ public class BuildCraftEnergy {
bucketOil), new ItemStack(Item.bucketEmpty)));
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Fuel", LiquidContainerRegistry.BUCKET_VOLUME),
new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty)));
MinecraftForge.EVENT_BUS.register(this);
}
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event) {
if (event.map == Minecraft.getMinecraft().renderEngine.textureMapItems) {
LiquidDictionary.getCanonicalLiquid("Fuel").setRenderingIcon(fuel.getIconFromDamage(0));
} else {
LiquidDictionary.getCanonicalLiquid("Oil").setRenderingIcon(oilStill.getBlockTextureFromSide(1));
}
}
public static void loadRecipes() {

View file

@ -11,6 +11,7 @@ package buildcraft.factory.render;
import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,25 +30,34 @@ public class RenderTank extends TileEntitySpecialRenderer {
final static private int displayStages = 100;
private HashMap<LiquidStack, int[]> stage = new HashMap<LiquidStack, int[]>();
private final HashMap<LiquidStack, int[]> stage = new HashMap<LiquidStack, int[]>();
private int[] getDisplayLists(LiquidStack liquid, World world) {
if (stage.containsKey(liquid)) {
return stage.get(liquid);
return stage.get(liquid);
}
int[] d = new int[displayStages];
stage.put(liquid, d);
BlockInterface block = new BlockInterface();
block.baseBlock = Block.waterStill;
block.texture = liquid.getRenderingIcon();
Minecraft.getMinecraft().renderEngine.bindTexture("/terrain.png");
String spriteSet = "/gui/items.png";
if (liquid.itemID < Block.blocksList.length) {
spriteSet = "/terrain.png";
block.baseBlock = Block.blocksList[liquid.itemID];
}
for (int s = 0; s < displayStages; ++s) {
d[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d[s], 4864 /* GL_COMPILE */);
Minecraft.getMinecraft().renderEngine.bindTexture(spriteSet);
block.minX = 0.125 + 0.01;
block.minY = 0;
block.minZ = 0.125 + 0.01;
@ -71,7 +81,7 @@ public class RenderTank extends TileEntitySpecialRenderer {
String liquidName = tank.tank.getLiquidName();
LiquidStack liquid = tank.tank.getLiquid();
LiquidStack refLiquid = LiquidDictionary.getCanonicalLiquid(liquidName);
LiquidStack refLiquid = LiquidDictionary.getCanonicalLiquid(liquidName);
if (refLiquid == null || liquid.amount <= 0)
return;