From 4d92a9b918d825309a286096a31c07b6badc1c21 Mon Sep 17 00:00:00 2001 From: Flow86 Date: Thu, 28 Mar 2013 10:00:05 +0100 Subject: [PATCH] fix RenderTank --- common/buildcraft/BuildCraftEnergy.java | 17 +++++++++++++++++ .../buildcraft/factory/render/RenderTank.java | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index c178fb0c..b84b5318 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -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() { diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java index 9d137daf..35e448fc 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -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 stage = new HashMap(); + private final HashMap stage = new HashMap(); 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;