Jump to content

TuxCraft

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by TuxCraft

  1. So how would I have my code call the Item an itemstack? When I do this... public static ItemStack thisSpear = new ItemStack(this, 1); It says this can't be used with a static modifier but adding the static modifier is the only way to get the entity to read it. I'll look at the entityItem code, that might have some insight on my dilemma.
  2. Ahh, thanks. Damage is also on the itemstack too right? Like when you use an inventory an you stack weapons they all have the same damage value. Also how would you set the spear as an itemstack and send it to the entity's pickup code?
  3. Ahh, thanks. Damage is also on the itemstack too right? Like when you use an inventory an you stack weapons they all have the same damage value. Also how would you set the spear as an itemstack and send it to the entity's pickup code?
  4. Hmm, well I've always had trouble with the difference between itemStack and item, so I don't necessarily know how to do that...
  5. Hmm, well I've always had trouble with the difference between itemStack and item, so I don't necessarily know how to do that...
  6. I'm making a mod with a spear in it and when you throw it you can go over and pick it back up. How would I make so that you pick up the exact same spear you threw with enchantments, and damage, and everything. I thought about using "this", but the spear pick up code is in the entity class so I can't do that. Is there any way to instead of "this" do "that"? Any way, what realistic way could I solve my problem, would packaging all the data I want the spear to keep into nbt data and sending it to the entity work?
  7. I'm making a mod with a spear in it and when you throw it you can go over and pick it back up. How would I make so that you pick up the exact same spear you threw with enchantments, and damage, and everything. I thought about using "this", but the spear pick up code is in the entity class so I can't do that. Is there any way to instead of "this" do "that"? Any way, what realistic way could I solve my problem, would packaging all the data I want the spear to keep into nbt data and sending it to the entity work?
  8. What is the default itemrenderer equipped code? In the minecraft forge docs (http://jd.minecraftforge.net/net/minecraftforge/client/IItemRenderer.ItemRenderType.html) it says to look at net.minecraft.src.ItemRenderer. I did and tried pasting the two methods "renderItem" and "renderItemIn2D", fiddled around with it to not have any visible errors. I ended up with this code... private static RenderItem renderItem = new RenderItem(); private Minecraft mc; private RenderBlocks renderBlocksInstance = new RenderBlocks(); private EntityLiving par1EntityLiving; private int par3; public boolean handleRenderType(ItemStack item, ItemRenderType type) { if (type == ItemRenderType.EQUIPPED) { return true; } return false; } public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return false; } @Override public void renderItem(ItemRenderType type, ItemStack par2ItemStack, Object... data) { GL11.glPushMatrix(); Icon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3); if (icon == null) { GL11.glPopMatrix(); return; } if (par2ItemStack.getItemSpriteNumber() == 0) { this.mc.renderEngine.bindTexture("/terrain.png"); } else { this.mc.renderEngine.bindTexture("/gui/items.png"); } Tessellator tessellator = Tessellator.instance; float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); float f4 = 0.0F; float f5 = 0.3F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(-f4, -f5, 0.0F); float f6 = 1.5F; GL11.glScalef(f6, f6, f6); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); renderItemIn2D(tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(), 0.0625F); if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); this.mc.renderEngine.bindTexture("%blur%/misc/glint.png"); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); } public static void renderItemIn2D(Tessellator par0Tessellator, float par1, float par2, float par3, float par4, int par5, int par6, float par7) { par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 0.0F, 1.0F); par0Tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)par1, (double)par4); par0Tessellator.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)par3, (double)par4); par0Tessellator.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)par3, (double)par2); par0Tessellator.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)par1, (double)par2); par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 0.0F, -1.0F); par0Tessellator.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - par7), (double)par1, (double)par2); par0Tessellator.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - par7), (double)par3, (double)par2); par0Tessellator.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - par7), (double)par3, (double)par4); par0Tessellator.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - par7), (double)par1, (double)par4); par0Tessellator.draw(); float f5 = (float)par5 * (par1 - par3); float f6 = (float)par6 * (par4 - par2); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(-1.0F, 0.0F, 0.0F); int k; float f7; float f8; for (k = 0; (float)k < f5; ++k) { f7 = (float)k / f5; f8 = par1 + (par3 - par1) * f7 - 0.5F / (float)par5; par0Tessellator.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(1.0F, 0.0F, 0.0F); float f9; for (k = 0; (float)k < f5; ++k) { f7 = (float)k / f5; f8 = par1 + (par3 - par1) * f7 - 0.5F / (float)par5; f9 = f7 + 1.0F / f5; par0Tessellator.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 1.0F, 0.0F); for (k = 0; (float)k < f6; ++k) { f7 = (float)k / f6; f8 = par4 + (par2 - par4) * f7 - 0.5F / (float)par6; f9 = f7 + 1.0F / f6; par0Tessellator.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)par1, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)par3, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - par7), (double)par3, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - par7), (double)par1, (double)f8); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, -1.0F, 0.0F); for (k = 0; (float)k < f6; ++k) { f7 = (float)k / f6; f8 = par4 + (par2 - par4) * f7 - 0.5F / (float)par6; par0Tessellator.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)par3, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)par1, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - par7), (double)par1, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - par7), (double)par3, (double)f8); } par0Tessellator.draw(); } However when I run the game it throws me an NPE, what am I doing wrong? What I'm trying to do is making my bow that I'v made render horizontally instead of vertically just to give it a cool little effect.
  9. What is the default itemrenderer equipped code? In the minecraft forge docs (http://jd.minecraftforge.net/net/minecraftforge/client/IItemRenderer.ItemRenderType.html) it says to look at net.minecraft.src.ItemRenderer. I did and tried pasting the two methods "renderItem" and "renderItemIn2D", fiddled around with it to not have any visible errors. I ended up with this code... private static RenderItem renderItem = new RenderItem(); private Minecraft mc; private RenderBlocks renderBlocksInstance = new RenderBlocks(); private EntityLiving par1EntityLiving; private int par3; public boolean handleRenderType(ItemStack item, ItemRenderType type) { if (type == ItemRenderType.EQUIPPED) { return true; } return false; } public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return false; } @Override public void renderItem(ItemRenderType type, ItemStack par2ItemStack, Object... data) { GL11.glPushMatrix(); Icon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3); if (icon == null) { GL11.glPopMatrix(); return; } if (par2ItemStack.getItemSpriteNumber() == 0) { this.mc.renderEngine.bindTexture("/terrain.png"); } else { this.mc.renderEngine.bindTexture("/gui/items.png"); } Tessellator tessellator = Tessellator.instance; float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); float f4 = 0.0F; float f5 = 0.3F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(-f4, -f5, 0.0F); float f6 = 1.5F; GL11.glScalef(f6, f6, f6); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); renderItemIn2D(tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(), 0.0625F); if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); this.mc.renderEngine.bindTexture("%blur%/misc/glint.png"); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); } public static void renderItemIn2D(Tessellator par0Tessellator, float par1, float par2, float par3, float par4, int par5, int par6, float par7) { par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 0.0F, 1.0F); par0Tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)par1, (double)par4); par0Tessellator.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)par3, (double)par4); par0Tessellator.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)par3, (double)par2); par0Tessellator.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)par1, (double)par2); par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 0.0F, -1.0F); par0Tessellator.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - par7), (double)par1, (double)par2); par0Tessellator.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - par7), (double)par3, (double)par2); par0Tessellator.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - par7), (double)par3, (double)par4); par0Tessellator.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - par7), (double)par1, (double)par4); par0Tessellator.draw(); float f5 = (float)par5 * (par1 - par3); float f6 = (float)par6 * (par4 - par2); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(-1.0F, 0.0F, 0.0F); int k; float f7; float f8; for (k = 0; (float)k < f5; ++k) { f7 = (float)k / f5; f8 = par1 + (par3 - par1) * f7 - 0.5F / (float)par5; par0Tessellator.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(1.0F, 0.0F, 0.0F); float f9; for (k = 0; (float)k < f5; ++k) { f7 = (float)k / f5; f8 = par1 + (par3 - par1) * f7 - 0.5F / (float)par5; f9 = f7 + 1.0F / f5; par0Tessellator.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)par2); par0Tessellator.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)par4); par0Tessellator.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, 1.0F, 0.0F); for (k = 0; (float)k < f6; ++k) { f7 = (float)k / f6; f8 = par4 + (par2 - par4) * f7 - 0.5F / (float)par6; f9 = f7 + 1.0F / f6; par0Tessellator.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)par1, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)par3, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - par7), (double)par3, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - par7), (double)par1, (double)f8); } par0Tessellator.draw(); par0Tessellator.startDrawingQuads(); par0Tessellator.setNormal(0.0F, -1.0F, 0.0F); for (k = 0; (float)k < f6; ++k) { f7 = (float)k / f6; f8 = par4 + (par2 - par4) * f7 - 0.5F / (float)par6; par0Tessellator.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)par3, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)par1, (double)f8); par0Tessellator.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - par7), (double)par1, (double)f8); par0Tessellator.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - par7), (double)par3, (double)f8); } par0Tessellator.draw(); } However when I run the game it throws me an NPE, what am I doing wrong? What I'm trying to do is making my bow that I'v made render horizontally instead of vertically just to give it a cool little effect.
  10. That was my own enumtoolmaterial file. Anyways I got it to work, I used this code for the config... And this for the array in enumweaponmaterials... Thank you Jordan so much for you help I couldn't have done it without you
  11. Awesome, that works! Now, one last thing, I added some stuff to the for loop, what it should do now is add the enum material to the array in the EnumWeaponMaterial file (public static EnumWeaponMaterial[] weaponMats;) but instead it gives me another npe. When I disable the last line minecraft starts but nothing has happened.
  12. When I run it like this it gives me an npe although weaponMatsArray is defined in the preInit
  13. Yes that is exactly what I had, I'm just having trouble getting the stringArray to be read out of the preInit. For example putting the for line in the load section. I've tried making a variable for it but it doesn't see it, am I stuck with having all of my code in the preInit method? Also I still don't know how to parse it, would something like this work? for(int i = 0; i < toStringArray.length; i++) EnumToolMaterial x = EnumToolMaterial.valueOf(toStringArray);
  14. Yes and no. No that isn't what I needed but yes I could totally use it, and it isn't really that far from what I need anyway . I need an array of all the tool material names, like array = {HERP, DERP}. It shouldn't be too hard though to change your code into something that will work for me. However I don't know how to call the string from the config, I was reading the tutorial off the forge forum and it didn't go over that. I'll do some more research on it but for now I'm stuck. Also in the minecraft forge configuration.java file I found this... public Property get(String category, String key, String[] defaultValue) { return get(category, key, defaultValue, null); } String[] being the important part here. Does this mean you could do an array of strings for the config or would it be more impractical and less user friendly than your method? One last thing, how would I parse a string to a tool material? I know how to do numbers to strings but that's where my knowledge on the subject ends.
  15. I know how to make enumtoolmaterials, but I don't even use them I use my own enum file I made. What I want to do is make an array of all the enum materials and then the player can go enable and disable whatever he/she wants in the config. Would I have to do this with XML, and if so could someone point me towards a good tutorial, I already found one that generates a config.txt and puts a string in it, I'm just haveing trouble turning the string into an array and calling it back.
  16. Would it be possible to make an array of enumToolMaterials in the config file? If so than how. Also if that's not possible would there be a way to do it with the tools forge already gives you. Or would I need to make my own config type file.
  17. Alright, I'm making a weapon mod where in the config all you have to do is add a new weapon material and your ore can be crafted into my mods weapons. So in my main mod file I'm trying to find a way to run through all the weapon mats and make a weapon for each. Here's the code I have so far it works in every way I want it to except I can't add an in-game name to the item... In my weapon mats file they are set up as an array so that's why you see weaponMats[ ]. Just point me in the direction of the code that adds a name to an item and I should be able to figure the rest out. edit: figured it out, should probably try doing it myself before crying for help
  18. Would it be possible to make the Item name a variable, for example... var1 = Iron public static itemAxe + var1 = new itemAxe(9000) etc. So it would read it as itemAxeIron. How could I do this and would it even be possible with forge?
  19. here's an idea I've had, make the recipes look like this addShapelessRecipe(CustomSword, 0xf600ff, clay, obsidian); addShapelessRecipe(CustomSword, 0x00f6ff, CustomSword, obsidian); and add this function here public static int addShapelessRecipe(ItemStack output, int ii, Object... params) { CraftingManager.getInstance().addShapelessRecipe(output, params); return ii; } My only problem is I don't know how to get int ii from my mod_ file to NBT data in my item file.
  20. How would I make an object that when it is crafted it is given a different NBT value depending on the ingredient.
  21. How would you go about making a variable that saves when minecraft is closed and make it possible that different item stacks of the same item could have a different value. Basically experience for items.
  22. I tried copying and pasting the arrow render code and other throwable objects render code for the renderer but it didn't work.
  23. Should I make my own render class?
  24. Please help, I bet it's a simple error and I'm a noob at java so I can't find it.
×
×
  • Create New...

Important Information

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