diff --git a/buildcraft_resources/mods/buildcraft/textures/items/icons/guiicons_0_0.png b/buildcraft_resources/mods/buildcraft/textures/items/icons/energy.png similarity index 100% rename from buildcraft_resources/mods/buildcraft/textures/items/icons/guiicons_0_0.png rename to buildcraft_resources/mods/buildcraft/textures/items/icons/energy.png diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 9f19a24b..c342b888 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -19,6 +19,7 @@ import net.minecraft.entity.EntityList; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; +import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.Property; @@ -34,6 +35,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.EntityEnergyLaser; import buildcraft.core.EntityPowerLaser; import buildcraft.core.EntityRobot; +import buildcraft.core.CoreIconProvider; import buildcraft.core.ItemBuildCraft; import buildcraft.core.ItemWrench; import buildcraft.core.RedstonePowerFramework; @@ -77,6 +79,7 @@ import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeSubscribe; @Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies = "required-after:Forge@[6.5.0.0,)") @NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) @@ -124,6 +127,9 @@ public class BuildCraftCore { public static Icon stripesLaserTexture; @SideOnly(Side.CLIENT) public static Icon transparentTexture; + + @SideOnly(Side.CLIENT) + public static IIconProvider iconProvider; public static int blockByEntityModel; public static int legacyPipeModel; @@ -252,6 +258,9 @@ public class BuildCraftCore { diamondGearItem = (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem"); LanguageRegistry.addName(diamondGearItem, "Diamond Gear"); + + MinecraftForge.EVENT_BUS.register(this); + } finally { if (mainConfiguration.hasChanged()) { mainConfiguration.save(); @@ -307,6 +316,15 @@ public class BuildCraftCore { public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new CommandBuildCraft()); } + + @ForgeSubscribe + @SideOnly(Side.CLIENT) + public void textureHook(TextureStitchEvent.Pre event){ + if ("items".equals(event.map.field_94253_b)){ + iconProvider = new CoreIconProvider(); + iconProvider.registerIcons(event.map); + } + } public void loadRecipes() { GameRegistry.addRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem); diff --git a/common/buildcraft/core/CoreIconProvider.java b/common/buildcraft/core/CoreIconProvider.java new file mode 100644 index 00000000..2140265e --- /dev/null +++ b/common/buildcraft/core/CoreIconProvider.java @@ -0,0 +1,32 @@ +package buildcraft.core; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import buildcraft.api.core.IIconProvider; + +public class CoreIconProvider implements IIconProvider { + + public static int ENERGY = 0; + + public static int MAX = 1; + + private Icon[] _icons; + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int iconIndex) { + return _icons[iconIndex]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) { + _icons = new Icon[MAX]; + + _icons[ENERGY] = iconRegister.func_94245_a("buildcraft:icons/energy"); + + } + +} diff --git a/common/buildcraft/energy/gui/GuiEngine.java b/common/buildcraft/energy/gui/GuiEngine.java index aa2a0929..8a92a2f3 100644 --- a/common/buildcraft/energy/gui/GuiEngine.java +++ b/common/buildcraft/energy/gui/GuiEngine.java @@ -1,10 +1,9 @@ package buildcraft.energy.gui; -import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import buildcraft.BuildCraftTransport; -import buildcraft.core.DefaultProps; +import buildcraft.BuildCraftCore; +import buildcraft.core.CoreIconProvider; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtil; @@ -33,8 +32,8 @@ public abstract class GuiEngine extends GuiBuildCraft { drawBackground(x, y); // Draw icon - drawIcon(DefaultProps.TEXTURE_ICONS, 0, x + 3, y + 4); - //drawIcon(BuildCraftTransport.instance.wireIconProvider.getIcon(0), x + 3, y + 4); + Minecraft.getMinecraft().renderEngine.func_98187_b("/gui/items.png"); + drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) return; diff --git a/common/buildcraft/silicon/gui/GuiAssemblyAdvancedWorkbench.java b/common/buildcraft/silicon/gui/GuiAssemblyAdvancedWorkbench.java index cdbca78a..4a20b5f7 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyAdvancedWorkbench.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyAdvancedWorkbench.java @@ -1,5 +1,6 @@ package buildcraft.silicon.gui; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -7,7 +8,9 @@ import net.minecraft.item.crafting.IRecipe; import org.lwjgl.opengl.GL11; +import buildcraft.BuildCraftCore; import buildcraft.core.DefaultProps; +import buildcraft.core.CoreIconProvider; import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.utils.StringUtil; import buildcraft.silicon.TileAssemblyAdvancedWorkbench; @@ -30,7 +33,8 @@ public class GuiAssemblyAdvancedWorkbench extends GuiAdvancedInterface { drawBackground(x, y); // Draw icon - drawIcon(DefaultProps.TEXTURE_ICONS, 0, x + 3, y + 4); + Minecraft.getMinecraft().renderEngine.func_98187_b("/gui/items.png"); + drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) return; diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index 0192b6fd..51980ba3 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -12,13 +12,16 @@ package buildcraft.silicon.gui; import java.util.Iterator; import java.util.LinkedList; +import net.minecraft.client.Minecraft; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; +import buildcraft.BuildCraftCore; import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.core.DefaultProps; +import buildcraft.core.CoreIconProvider; import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; @@ -50,7 +53,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { drawBackground(x, y); // Draw icon - drawIcon(DefaultProps.TEXTURE_ICONS, 0, x + 3, y + 4); + Minecraft.getMinecraft().renderEngine.func_98187_b("/gui/items.png"); + drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4); if (!isFullyOpened()) return;