1
Adding a potion effect when you step on a block
I am trying to add a potion effect when you step on a block (Example: Get fire resistance when you step on a custom block). I am using forge 1.8. Anyone know how I can do this for all potion effects?
Create an account or sign in to comment.
12
1
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if (par5Entity instanceof EntityLiving) {
((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.heal.getId(), 50, 1));
}
}
To break it down...
if (par5Entity instanceof EntityLiving) {
This simply checks if the entity walking on it is alive, not dead.
((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.heal.getId(), 50, 1));
That just adds the effect to the entity, simple!
The second integer is the duration of the potion in ticks, and the third is the amplifier.
Just replace 'heal' with one of these:
Click to reveal
moveSpeed
moveSlowdown
digSpeed
digSlowdown
damageBoost
heal
harm
jump
confusion
regeneration
resistance
fireResistance
waterBreathing
invisibility
blindness
nightVision
hunger
weakness
poison
moveSlowdown
digSpeed
digSlowdown
damageBoost
heal
harm
jump
confusion
regeneration
resistance
fireResistance
waterBreathing
invisibility
blindness
nightVision
hunger
weakness
poison
Seriously... 8 days? Nobody?
Has anyone else ever even tried to mod minecraft before?
1
Probably some sort of "if" statement.
1
*claps sarcastingly*
1
I am using eclipse for this if that helps at all: Please help! I know there is a way to mod a block to give you a potion effect when you or a mob steps on it, but what is it?
1
This doesn't work for modding, anyone know how I can do this, or if not, where I should ask besides here?
1
Well I feel bad for you since all these people are just guessing and not understanding you but you should go to the forge forums.
1
I'm talking about java coding
1
Vanilla, plugin, mod?
1
or you set the block to the id what are you using in the mod. dadaaa.a.
1
to finish the command:
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:<block> 0 /effect @p minecraft:<effect> <time> <Level> <hide particles, true/false>
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:<block> 0 /effect @p minecraft:<effect> <time> <Level> <hide particles, true/false>