Override Item#hitEntity and use EntityLivingBase#addPotionEffect. The second argument of hitEntity is the Entity that was attacked, the third is the Entity that did the attacking.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
EntityLivingBase#addPotionEffect means that addPotionEffect needs to be called on an instance of the EntityLivingBase class (like the one you receive as an argument of hitEntity).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I'd highly recommend learning Java completely before starting to make mods.
If there's a specific part of my what I've said that you don't understand, let me know.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Try set a breakpoint in your hitEntity method*, launch Minecraft in debug mode and hit something with the item. Does it reach the breakpoint?
* In IntelliJ IDEA, you do this by clicking in the column to the left of the code with the line numbers in it. I'm pretty sure Eclipse is similar.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I think I identified the problem, what is the 1.6.4 version of @Override? Because @Override isn't registering which can only mean it is not in the game.
I think I identified the problem, what is the 1.6.4 version of @Override? Because @Override isn't registering which can only mean it is not in the game.
Nvm that message I was wrong
@Override exists in all versions because it's part of the JDK rather than Minecraft. If @Override gives you an error, your method signature doesn't match any inherited method's signature.
Let me know if you're still having problems.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
It probably isn't working because your potion effect's duration is too small, not giving enough time for you to notice the potion effect. Since the duration is in ticks, and 20 ticks are 1 second long, you need to input 40 instead of 2.
Note: This is how it works for 1.7.10, I assume that it's the same for 1.6.4.
This is the PotionEffect constructor called by the two- and three-parameter constructors:
public PotionEffect(int par1, int par2, int par3, boolean par4)
{
this.potionID = par1;
this.duration = par2;
this.amplifier = par3;
this.isAmbient = par4;
this.curativeItems = new ArrayList();
this.curativeItems.add(new ItemStack(Item.bucketMilk));
}
So duration is the second argument, amplifier is the third argument.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Does anyone know the code need for have weapons/items inflict potion effects?
Override Item#hitEntity and use EntityLivingBase#addPotionEffect. The second argument of hitEntity is the Entity that was attacked, the third is the Entity that did the attacking.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I'm kind of new to this, so you could you possible write out what you just said?
Thanks
Do you know Java? Knowing at least the basics of Java is essential to modding.
This tutorial explains how to override methods.
EntityLivingBase#addPotionEffect means that addPotionEffect needs to be called on an instance of the EntityLivingBase class (like the one you receive as an argument of hitEntity).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I think I'm doing well for starting yesterday.
I'd highly recommend learning Java completely before starting to make mods.
If there's a specific part of my what I've said that you don't understand, let me know.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Okay, so like this?
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase){
par1ItemStack.damageItem(1, par3EntityLivingBase);
par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(),2 , 2));
return true;
(Note: this doesn't seem to work)
Also, sorry if I don't know alot. I just started 2 days ago.
That should work.
Try set a breakpoint in your hitEntity method*, launch Minecraft in debug mode and hit something with the item. Does it reach the breakpoint?
* In IntelliJ IDEA, you do this by clicking in the column to the left of the code with the line numbers in it. I'm pretty sure Eclipse is similar.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I think I identified the problem, what is the 1.6.4 version of @Override? Because @Override isn't registering which can only mean it is not in the game.
Nvm that message I was wrong
@Override exists in all versions because it's part of the JDK rather than Minecraft. If @Override gives you an error, your method signature doesn't match any inherited method's signature.
Let me know if you're still having problems.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
It probably isn't working because your potion effect's duration is too small, not giving enough time for you to notice the potion effect. Since the duration is in ticks, and 20 ticks are 1 second long, you need to input 40 instead of 2.
Note: This is how it works for 1.7.10, I assume that it's the same for 1.6.4.
~ Crows
Avatar Mod 2 -- Elemental Bending from Avatar: The Last Airbender
Contact: PM or [email protected]
Is the first 2 the modifier or the ticks?
[url ="http://www.minecraftforum.net/topic/1066990-hardcore-ender-expansion"]
[I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
[url=http://www.minecraftnoobtest.com/test.php][/url]
To take the test, check out
[url=http://www.minecraftnoobtest.com/test.php]http://minecraftnoobtest.com/test.php[/url]
This is the PotionEffect constructor called by the two- and three-parameter constructors:
So duration is the second argument, amplifier is the third argument.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Thank you
[url ="http://www.minecraftforum.net/topic/1066990-hardcore-ender-expansion"]
[I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
[url=http://www.minecraftnoobtest.com/test.php][/url]
To take the test, check out
[url=http://www.minecraftnoobtest.com/test.php]http://minecraftnoobtest.com/test.php[/url]