1

Adding a potion effect when you step on a block

Fire_Mutt 9/17/15 6:56 am
683
9/25/2015 7:49 am
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
Level 2 : Apprentice Miner
2

  Have something to say?

JoinSign in

12

YTCereal
09/17/2015 7:34 am
Level 22 : Expert Network
yeah. you can do that.

/execute @a ~ ~ ~ detect something..
1
DaSquyd
09/17/2015 9:00 am
Level 32 : Artisan Toast
That would be how you'd do it in vanilla, but it looks like they're asking about mod-making.
1
Bertiecrafter
09/17/2015 9:02 am
Level 72 : Legendary System
to finish the command:
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:<block> 0 /effect @p minecraft:<effect> <time> <Level> <hide particles, true/false>
1
YTCereal
09/17/2015 10:25 am
Level 22 : Expert Network
or you set the block to the id what are you using in the mod. dadaaa.a.
1
bwfcwalshy
09/17/2015 11:00 am
Level 1 : New Miner
Vanilla, plugin, mod?
1
Fire_Mutt
09/18/2015 7:29 pm
Level 2 : Apprentice Miner
I'm talking about java coding
1
Fire_Mutt
09/19/2015 5:40 pm
Level 2 : Apprentice Miner
This doesn't work for modding, anyone know how I can do this, or if not, where I should ask besides here?
1
ButterChuckles
09/21/2015 7:14 pm
Level 2 : Apprentice Network
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
Fire_Mutt
09/21/2015 7:03 pm
Level 2 : Apprentice Miner
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
AuzziPuppy
09/21/2015 7:11 pm
Level 4 : Apprentice Llama
Probably some sort of "if" statement.
1
that2guy
09/25/2015 7:00 am
Level 48 : Master Nerd
*claps sarcastingly*
1
Creeper_4869
09/25/2015 7:49 am
Level 15 : Journeyman System
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

Welcome