1

Adding a potion effect when you step on a block

Fire_Mutt's Avatar Fire_Mutt9/17/15 6:56 am
9/25/2015 7:49 am
Creeper_4869's Avatar Creeper_4869
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?
Posted by Fire_Mutt's Avatar
Fire_Mutt
Level 2 : Apprentice Miner
2

Create an account or sign in to comment.

12

1
09/25/2015 7:49 am
Level 15 : Journeyman Engineer
Creeper_4869
Creeper_4869's Avatar
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


Seriously... 8 days? Nobody?
Has anyone else ever even tried to mod minecraft before?
1
09/21/2015 7:11 pm
Level 4 : Apprentice Llama
AuzziPuppy
AuzziPuppy's Avatar
Probably some sort of "if" statement.
1
09/25/2015 7:00 am
Level 48 : Master Nerd
that2guy
that2guy's Avatar
*claps sarcastingly*
1
09/21/2015 7:03 pm
Level 2 : Apprentice Miner
Fire_Mutt
Fire_Mutt's Avatar
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
09/19/2015 5:40 pm
Level 2 : Apprentice Miner
Fire_Mutt
Fire_Mutt's Avatar
This doesn't work for modding, anyone know how I can do this, or if not, where I should ask besides here?
1
09/21/2015 7:14 pm
Level 2 : Apprentice Network
ButterChuckles
ButterChuckles's Avatar
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
09/18/2015 7:29 pm
Level 2 : Apprentice Miner
Fire_Mutt
Fire_Mutt's Avatar
I'm talking about java coding
1
09/17/2015 11:00 am
Level 1 : New Miner
bwfcwalshy
bwfcwalshy's Avatar
Vanilla, plugin, mod?
1
09/17/2015 10:25 am
Level 22 : Expert Network
YTCereal
YTCereal's Avatar
or you set the block to the id what are you using in the mod. dadaaa.a.
1
09/17/2015 9:02 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
to finish the command:
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:<block> 0 /effect @p minecraft:<effect> <time> <Level> <hide particles, true/false>
1
09/17/2015 7:34 am
Level 22 : Expert Network
YTCereal
YTCereal's Avatar
yeah. you can do that.

/execute @a ~ ~ ~ detect something..
1
09/17/2015 9:00 am
Level 32 : Artisan Toast
DaSquyd
DaSquyd's Avatar
That would be how you'd do it in vanilla, but it looks like they're asking about mod-making.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome