Jump to content

AXELTOPOLINO

Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by AXELTOPOLINO

  1. The same as with the Swords? Swords are different items, they don't have subitems and they use the following method which doesn't seem to be NBT sensitive: public Multimap getItemAttributeModifiers() { Multimap multimap = super.getItemAttributeModifiers(); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.weaponDamage, 0)); return multimap; } I don't think there's another method Thank you, Axel
  2. Ok, not everything is NBT sensitive and the subitems are all loaded correctly. I think this is almost obvious for you, but I still have one problem: how can I modify the ItemStack damage against EntityLivings if it is stored in the NBT of the itemstack (each subitem has got his own value for this field) ? Thanks! Axel
  3. Ahah sorry, english is not my foreign language and sometimes I understand or answer in a very wrong way Anyway I have never made a PullRequest, but I have to do it on github if I have understood your answer correctly, thanks!
  4. Yes, I just hoped there was a forge edit already Where should I pull the request? Here in this forge section or on github? Thanks
  5. Update forge, they updated the MCP mappings lately, it makes things a lot easier. Use ItemStack.stackTagCompound to get the Stack NBT. Then look here: http://www.minecraftwiki.net/wiki/Player.dat_format#Attribute_Modifiers to find out about the format to use. Override getMaxDamage(ItemStack), getDamage(ItemStack) and getDisplayDamage(ItemStack) and return the values you need depending on the NBT of the stack passed in. Whenever you would apply acid damage to the player, check if he has your Item and if that item's NBT contains the "acid-resistant" flag. Items can be stacked if the NBT is equal. Perfect, so I will just edit the Attribute modifier value for having a custom "damage" of the item (decreasing its value for consuming the itemstack), am I right? The thing I wanted to ask in 4) is: Can the subtypes have different MaxStackSize? I really need this feature.. I hope my clicks on "thank you" button will be helpful for you, as you really deserve them Axel Edit: I'm stupid, I didn't see ItemStack#getMaxStackSize Edit2: ItemStack#getMaxStackSize isn't subtype-sensitive as it calls ItemStack#getItem which is not subtype-sensitive. Is there any solution for that? Thanks
  6. Still working on it, trying to understand the idea correctly. First of all I haven't found the method ItemStack#getAttributeModifiers, is it probably func_111283_C()? Anyway: - I put N itemsubtypes using Item#getSubItems increasing the damage value for each subtype - I can show subtypes in creative inventory thanks to Item#getCreativeTabs But: 1) Which is the itemStack method that let me change the attribute modifiers of that itemstack only? 2) How can I damage an itemstack which uses an item subtype (for example it's a subtype of axe which should have a custom "MaxDamage", different from the other subtypes) 3) How can I add a new custom attribute modifier to the itemstack (like "acid-resistence")? 4) Can the nbtcompound be used for item subtypes that can be stackable? I feel so newbie about this part of Minecraft code, but luckily you are helping us Thank you, Axel
  7. I know I'm a bit offtopic, but I'm trying to do what you suggested: using item subtypes instead of several different items. I just have a question: I must create several types of swords, but if I use subtypes I cannot set different itemMaxDamage values. Is there a way for doing it using subtypes? Thanks in advance, Axel
  8. You have helped me so much and I'm really happy that I have learned something new. So really thanks diesieben07, I'll let you know about the ItemStack thing, if it will work I'll post some example code here for the other guys Axel
  9. Override getSubItems in your Item class and add all the ItemStacks you want in the Creative menu to the list you get as the parameter. If you are accessing Minecraft fields/methods, yes there are issues because the fields and methods are obfuscated outside of MCP. But if you access FML or Forge stuff you'll be fine. For ItemStacks: wonderful, I'll let you know if it works (as I must have different itemstacks with 2 big arrays, some String values and some Int and Short values. This is why I thought itemStack weren't the right choice for doing something like this mod) For reflection: I have reflected only FML fields now. But for curiosity: how can I know obfuscated names of fields and methods of MC? Should I check .class files and finding the right name or is there a public available list? Reflection would give us the possibility of avoiding base classes edits for modding
  10. There are enchanted books in the creative inventory, right? And you can pick them up and they are still enchanted, right? Now let me tell you that they all have the same ItemId and the same Damage value. The only difference between is their enchantments which are stored in the ItemStack's NBTTagCompound. When the ItemStack is cloned (on pickup from the creative inventory for example) the NBTTagCompound get's cloned, too. You are literally doing a revolution in my brain So, how can I actually register different itemstacks when minecraft loads (I mean as Minecraft actually does), because I'd like to see them in the creative menu like the enchanted books. Are there any troubles using Java reflection also after recompiling? I'm worried about fields name.. As always thanks for your time and patience! Axel
  11. Yes, Mojang does that because vanilla has all the Item ids they want. They can create as many as they want because they don't have to worry about any restrictions. It's their game after all, they can change it if they need to. Modders can't. Every ItemStack has an NBTTagCompound attached to it which allows you to store basically infinite amount of data into one ItemStack. Vanilla uses this feature for Enchantments, Written Books, etc. Forge provides various hooks in the Item class to make the Item act dependent on the actual ItemStack being used. For example there is a new version of canHarvestBlock which gets the ItemStack being used as a parameter. Then this method can act differently depending on the Data on the NBTTagCompound of the ItemStack. Yes, Mojang does that because vanilla has all the Item ids they want. They can create as many as they want because they don't have to worry about any restrictions. It's their game after all, they can change it if they need to. Modders can't. Every ItemStack has an NBTTagCompound attached to it which allows you to store basically infinite amount of data into one ItemStack. Vanilla uses this feature for Enchantments, Written Books, etc. Forge provides various hooks in the Item class to make the Item act dependent on the actual ItemStack being used. For example there is a new version of canHarvestBlock which gets the ItemStack being used as a parameter. Then this method can act differently depending on the Data on the NBTTagCompound of the ItemStack. That's quite interesting, but you cannot see in the creative menu the itemstacks, but only the items, then a new itemstack is created when you pick up an item. So your idea (which is a really smart one) can't be used for making completely different items in inventory. If I'm wrong, please tell me as it would be the final solution for the 32000 items limit
  12. Long answer: http://docs.oracle.com/javase/tutorial/reflect/ Short answer: http://stackoverflow.com/questions/1196192/how-do-i-read-a-private-field-in-java You don't need to create a new Item instance for stuff like that. Make one Item which uses NBT to store the data. I loved the long answer, I know how to use reflection now Anyway you can't use an unique item instance for making more items with different stats. For example, even if there's only one class ItemSword.java, minecraft calls one instance of the wood sword, one for the iron sword, one for the diamond sword, etc. So I think we cannot use only one Item instance for all my custom items...or am I wrong (and I'd really like to be wrong)? Thanks dude for your helpful support! Axel
  13. First of all, thank you diesieben07 for your helpful reply (I have also clicked the "thanks" button ), I have understood everything of your idea and it seems the very best solution, but even if I have coded many mods, I have never used reflection. Could you link me some documentation about it? As you are right, I need to have access to the private fields. Again thank you! Axel ps. creating Items mid-game? Look is 90% ready: http://www.minecraftforum.net/topic/1965419-wip162-axels-item-printer-create-your-custom-items-in-game/
  14. Please guys (LexManos or cpw), could you add this simple edit to the code? It doesn't change anything to your code, but it's really important for my upcoming mod. Hope to get an answer as I really haven't found any other way for making what I need, Thanks a lot, Axel
  15. Hello everyone, I'm working on a difficult mod and I'm adding some items in game during the game session. I know this is highly discouraged, but there's an important reason if I'm doing it. The problem is that when you register a new item during the game, GameData.newItemAdded() registers it with "Minecraft" as modContainer. Differently I'd like to use my mod's modContainer that I can get via "FMLCommonHandler.instance().findContainerFor(MyModCommon.instance)". For this reason I need a change of the method GameData.newItemAdded(Item item) into GameData.newItemAdded(Item item, ModContainer container), so I can specify the ModContainer. Could you add this feature please? Thanks, Axel
  16. Thank you both, really clean, simple and useful code!
  17. Hello everyone, I really need a way to detect if the client is playing singleplayer (so when there's an integrated server) or if it is playing on multiplayer (on a remote, dedicated server). ClientProxy and ServerProxy don't allow that, as ServerProxy isn't called when we are playing on singleplayer. Also World instance can't help me in this, as it gets the SIDE only (client-side or server-side). I can't see any solution, please give me some tips, thanks guys!
  18. Cool interface LexManos, I didn't see it! Really thanks, I'm going to try it
  19. Hello, I have made a new entity called "EntityBullet", basing on the code of the EntityArrow. The only difference is that my bullet should load a different texture based on the variable "colour". For example when colour is 1 it must load "red.png", when colour is 2 it must load "blue.png". From my tests it seems that the Entity in the server-side has got the right value set, but the render-instance's entity, even if it has the same entityID, has got the wrong value of colour (the default one). Does the server send all the variables of the entity to the client? Or must I add a packet for sending my custom variables to the client? This is how I register my EntityBullet and how I render it: EntityRegistry.registerModEntity(EntityBullet.class, "Bullet", 105, ModCommon.instance, 250, 5, true); EntityRegistry.registerGlobalEntityID(EntityBullet.class, "Bullet", 105); RenderingRegistry.instance().registerEntityRenderingHandler(EntityBullet.class, new RenderBullet()); The value of "colour" is set correctly in the server-side's entity, but it is not passed to the render file: package Starwars.client.render; import net.minecraft.src.*; import org.lwjgl.opengl.GL11; import MyMod.common.entities.EntityBullet; public class RenderBullet extends Render { public RenderSWlaserbeam() { } public void renderBullet(EntityBullet entitybullet, double d, double d1, double d2, float f, float f1) { if(entitybullet.colour == 1) { loadTexture("/red.png"); } else if(entitybullet.colour == 2) { loadTexture("/green.png"); } else {} GL11.glPushMatrix(); GL11.glTranslatef((float)d, (float)d1, (float)d2); GL11.glRotatef((entitybullet.prevRotationYaw + (entitybullet.rotationYaw - entitybullet.prevRotationYaw) * f1) - 90F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(entitybullet.prevRotationPitch + (entitybullet.rotationPitch - entitybullet.prevRotationPitch) * f1, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; int i = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float)(0 + i * 10) / 32F; float f5 = (float)(5 + i * 10) / 32F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float)(5 + i * 10) / 32F; float f9 = (float)(10 + i * 10) / 32F; float f10 = 0.05625F; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); float f11 = (float)entitybullet.arrowShake - f1; if(f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f8); tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f8); tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f9); tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f8); tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f8); tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f9); tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f9); tessellator.draw(); for(int j = 0; j < 4; j++) { GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8D, -2D, 0.0D, f2, f4); tessellator.addVertexWithUV(8D, -2D, 0.0D, f3, f4); tessellator.addVertexWithUV(8D, 2D, 0.0D, f3, f5); tessellator.addVertexWithUV(-8D, 2D, 0.0D, f2, f5); tessellator.draw(); } GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glPopMatrix(); } public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { renderBullet((EntityBullet)entity, d, d1, d2, f, f1); } } The colour's value in RenderBullet is always 0 which is the default one in EntityBullet.java. Could you tell me what's wrong? Thank you!
  20. It was just weird for me seeing packets sent even if I was testing the mod in the "old singleplayer". Now everything is clear, SSP doesn't exist anymore, there are 2 different players instances for the same player and I need packets always. Thank you to all of you guys, have a good day.
  21. Actually with all respect, I can mod Minecraft pretty well and I wrote the post in a wrong way. I just saw that my KeyHandler assigns values to an instance of EntityClientPlayerMP while the player who is playing is an instance of EntityPlayerMP. There are these 2 instances for the same player even if I'm playing without a "server" (using the "old" SinglePlayer). Maybe I just need some rest, but now I really can't understand why the client runs the 2 instances for the same player.
  22. So should packets always be sent from server to client (I mean for having EntityPlayerMP and EntityClientPlayerMP with the same variables) ? Thanks LexManos, for the help and for Forge itself. Have a good day!
  23. Thanks for the reply SanAndreasP, so what can I use instead of ModLoader.getMinecraftInstance().thePlayer; ? This variable is an instance of "EntityClientPlayerMP" while I should assign the variables to the instance of EntityPlayerMP. Thank you for your time
  24. Hello Forge-mates, I'm working on a mod with Forge 4.1.1. When I test the mod on SSP, Minecraft still runs one "EntityPlayerMP" and a "EntityClientPlayerMP". Is it normal? I have problems setting my variable using a KeyHandler, because it assigns them to an instance of "EntityClientPlayerMP" and not to the "EntityPlayerMP" instance. This is the code I use in the KeyHandler: public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if(types.contains(TickType.CLIENT) && tickEnd && ModCommon.proxy.getClientWorld() != null && ModCommon.proxy.getClientWorld().isRemote) { EntityClientPlayerMP player = ModLoader.getMinecraftInstance().thePlayer; if(kb.keyCode == M_binding.keyCode) { player.booleanTest = true; } } } But actually booleanTest isn't set to true in EntityPlayerMP, while it is set in the instance of EntityClientMP. Why are there EntityPlayerMP and EntityClientMP instances if it is SSP? Really thanks for help, AXELTOPOLINO
×
×
  • Create New...

Important Information

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