forum Forumsplay_arrow Minecraft fiber_manual_record Mods

1

Swords with Poison Effect? [Forge|1.6.4]

1 emerald10 replies2,809 views
created 12/29/2013 3:24 pm by TheLuigiplayer
last reply 06/24/2014 3:37 pm
I wanted to make a mod,with swords,that give mobs an posion effect,if you hit them.
So I googled and no code worked.Can you help me please?The sword data is completely finished,only the effect code is missing.
It would be very nice,if you could help me please.
Thank you!

-Luigiplayer
Posted by avatar
TheLuigiplayer
Level 58 : Grandmaster Architect
57

10 replies

1
06/24/2014 12:19 pm
Level 37 : Artisan Engineer
TheXWolf
avatar
It's a boolean so the return type would have to be true
1
06/23/2014 12:15 am
Level 37 : Artisan Network
Mortifer
avatar
1
12/31/2013 7:52 pm
Level 58 : Grandmaster Architect
TheLuigiplayer
avatar
Yesterday,I got a right code,that works at tools,but not at swords.
I will try a few other codes,but thanks!
1
12/31/2013 11:43 am
Level 20 : Expert Nerd
Endermonarch Durbius
avatar
There's a craftbukkit server plugin for poison swords, the plugin's called "Custom Enchantments."
1
12/31/2013 11:15 am
Level 68 : High Grandmaster Modder
coolAlias
avatar
You just need to add the potion effect for poison when you hit the entity.

@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
// parameters of PotionEffect are: id, amplifier, duration in ticks (20 = 1 second)
target.addPotionEffect(new PotionEffect(Potion.poison.id, 1, 60));
}

if that doesn't work as expected, I may have gotten the 'target' and 'attacker' parameters backwards, but I'm pretty sure that's right So just switch them around if the mob isn't getting poisoned.
1
06/24/2014 3:37 pm
Level 1 : New Miner
theshoal12
avatar
Well, you did mix something up, but it wasn't the attack/target variables. I am a java newbie, but I did do some testing and found that the error was in the line where you add the potion effect. The effect WAS there, but it was too short to be noticed. Right now, the effect is set to 1 tick (1/20th of a second) and amplifier 60. Try swapping the amplifier and the duration. Here's my code:

public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
// parameters of PotionEffect are: id, duration in ticks (20 = 1 second), and amplifier
target.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 1));
return true;
}

Here's a tip: Where it says

target.addPotionEffect(new PotionEffect(Potion.poison.id, 60, 1));

try replacing '60' with '20 * 3'. It's good if you don't want to multiply it yourself lol.
EDIT: It appears that for the amplifier, if you put down a 1, it will make a level 2 potion, 2 is a level 3, ect.
1
06/23/2014 12:00 am
Level 1 : New Miner
jordonlikesminecraft
avatar
what is the return statement supposed to be
1
12/29/2013 3:44 pm
Level 58 : Grandmaster Architect
TheLuigiplayer
avatar
No,you understood me wrong,I wanted to code a sword,that gives mobs a poison effect,if you hit them.I know,that its possible,but I dont know,how ;D
But thanks,for your quick answser.
1
12/29/2013 3:43 pm
Level 8 : Apprentice Network
FuzionPVPServer
avatar
Ik that this is possible whit bukkit
If you try it use
EntityDamageByEntityEvent
1
12/29/2013 3:40 pm
Level 20 : Expert Narwhal
hober64
avatar
I think using MCedit this is possible, but I could be wrong, but I am sure someone could figure it out with a mod, I mean, look at gontroller, they have special swords with a 1% chance to poison / give wither effect, so it is surely possible

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome