Merge pull request #704 from Flow86/patch-renderTank

Patch render tank
This commit is contained in:
Flow86 2013-03-28 02:02:41 -07:00
commit 042f0a1ad8
3 changed files with 41 additions and 10 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,15 +11,19 @@ package buildcraft.energy;
import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.liquids.ILiquid;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftEnergy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockOilStill extends BlockStationary implements ILiquid {
@SideOnly(Side.CLIENT)
private Icon[] field_94425_a;
private Icon[] theIcon;
public BlockOilStill(int i, Material material) {
super(i, material);
@ -52,17 +56,17 @@ public class BlockOilStill extends BlockStationary implements ILiquid {
public boolean isBlockReplaceable(World world, int i, int j, int k) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister){
this.field_94425_a = new Icon[] {iconRegister.registerIcon("buildcraft:oil"), iconRegister.registerIcon("buildcraft:oil_flow")};
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
this.theIcon = new Icon[] { iconRegister.registerIcon("buildcraft:oil"), iconRegister.registerIcon("buildcraft:oil_flow") };
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) {
return par1 != 0 && par1 != 1 ? this.field_94425_a[1] : this.field_94425_a[0];
return par1 != 0 && par1 != 1 ? this.theIcon[1] : this.theIcon[0];
}
}

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;