Jump to content

TheNuclearDuck

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by TheNuclearDuck

  1. I have this block, which has multiple subtypes using metadata (15 different subtypes). I am using the following code: public int getBlockTextureFromSideAndMetadata(int side, int metadata) { switch(side) { case 0: return 32; case 1: return 0 + metadata; default: return 16; } } to change the top side texture depending on the metadata. I am also using this code: public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) { return getBlockTextureFromSideAndMetadata(l, worldAccess.getBlockMetadata(i, j, k)); } Which should, as far as I know, do what I want it to do. However, for some reason, the texture only changes in the inventory slots, and when seen in the player's hand. When placed down, it stays at the texture for the block without metadata. Any ideas why this is happening? I think I've given all the relevant code, but if you need anything else, just tell me.
  2. It's actually extemely simple. Since GUIs use drawTexturedModalRect(...) you simply change where you input the progress value into this line of code. At the moment it should look something like this: this.drawTexturedModalRect(x + *, y + *, *, *, *, progressVariable); Just change this to: this.drawTexturedModalRect(x + *, y + *, *, *, progressVariable, *); Where the asterisks can be any value. by the way, for reference, here are the parameters for drawTexturedModalRect(): drawTexturedModalRect(xPosition, yPosition, sourceTextureX, sourceTextureY, width, height); Hope I helped!
  3. I'd like to know whether there is any sort of way, in Minecraft Forge API, to draw directly onto the player's HUD. That is, with the health bar, xp bar, hotbar etc. Any ideas?
  4. Okay, so I have added a variable to my Container***** file which sets itself to the tile entity's variable, now how do I pass this variable along to my Gui***** file? I am confused as what to reference, for example should I put Container*****.variable or what? Please help, I know I'm so close to the solution.
  5. Well, I tried using TileEntity*****.variable but this seems to gt the same value for every block which is placed with this GUI, meaning when a block is placed and there have been previous blocks placed also, it will start by rendering the same value as the other block. I want each block to have an individual variable for its GUI. Edit: When I try to access my GUI***** file's tile_entity parameter, I get an error saying it does not exist.
  6. Hey all, I am making a mod and would like to know how to read an int from a block's tile entity from it's Gui***** file. I have declared a variable in the tile entity which is a public static int. I need to know how to access this variable in my Gui***** file's drawGuiContainerBackgroundLayer method in order to render a graph representing this int. Any ideas on how to do this? Thanks for reading this, hope you can help
  7. Okay, all is good, now i need to know how to change how filled up the meter is. Now the meter integer (chargeMeter) is in the draw background method, and I need to update it every time the redstone is filled up. It all works!
  8. Any ideas? The game force closes when I try to place the block and goes to a crash screen saying there's a nullpointerexception.
  9. Okay, that works, so now how can I change the charge meter value, which is in drawGuiContainerBackgroundLayer()? Also, why am I getting a NullPointerException with that last code?
  10. So in which class should I put this code, and where? GUI***? I'm getting a "cannot make a static reference to thee non-static method".
  11. I need to be able to check the contents (I assume an ItemStack) of a particular slot in my GUI, so I can use an if to check if the item in the slot matches redstone, to fill up my meter.
  12. Okay, thank you very much. I'll change the math now Any ideas for checking contents of a slot?
  13. Hello, I am trying to create a new GUI using Minecraft Forge and GUI****, however when I try to use this math to display a charge meter, for some obscure reason chargePx always returns 0 and the image is not displayed at all. Can anyone help me, or does anyone know why this would be happening? int barHeight = 32; int chargeMeter = 50; //Charge % int chargePx = Math.round(barHeight * (chargeMeter / 100)); this.drawTexturedModalRect(x + 20, y + 16, 176, 16, 16, chargePx); P.s. I tested out the sum on a scientific calculator, and it equalled 16, as it should. This is why I don't understand why Java cannot do simple calculations such as this. I would also like to know how to find the contents of a particular slot in a GUI, in order to use up an item in a specific slot if said item is redstone, for example.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.