How to make mob immune to certain effect/damage type (SOLVED)

Started by BryAstro on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make mob immune to certain effect/damage type (SOLVED)
Thu, 12/21/2023 - 00:32 (edited)

Version 2021.1 (1.12.2 Generator)

Basically I want to make a mob that is immune to certain effects (i know how to make it immune to fire/drowning/potions/wither etc.)

But what I mean is it being immune to only one or two effects, I want it to be immune to e.g. poison, but no other potion effect.

Edited by BryAstro on Thu, 12/21/2023 - 00:32
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Something like this I have…
Tue, 04/11/2023 - 02:40

Something like this

I have not tested it but it should work

Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This doesn't work for some…
Tue, 07/04/2023 - 23:45

This doesn't work for some things, as it deals damage once then gets removed since this procedure has a delay with respect to the poison applying its damage. 

Instead, if you're not afraid to code, you may want to try this: click the Edit Code button on the left with your Entity element selected, then go to <YourEntity>Entity.java, then scroll a bit down and below any brackets (just not inside any functions) paste the @Override thing there and the import stuff at the very top of everything in the file. Save and lock code. Make sure to do everything else about the entity before you make this change (if you're wondering, this is how Minecraft handles poison on spiders).

import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.effect.MobEffect;
@Override
	public boolean canBeAffected(MobEffectInstance effect)
	{
		 if (!return effect.getEffect() == MobEffects.POISON)
		 {
		 	super.canBeAffected(effect);
		 }
	}
Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wait it's wrong and I can't…
Tue, 07/04/2023 - 23:47

Wait it's wrong and I can't edit it?? Get rid of the word "return" there

@Override
	public boolean canBeAffected(MobEffectInstance effect)
	{
		 if (!effect.getEffect() == MobEffects.POISON)
		 {
		 	super.canBeAffected(effect);
		 }
	}
Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I dont understand how this…
Mon, 01/01/2024 - 20:35

I dont understand how this is solved also where da heck do i find the AND block ive looked everywhere

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It is in the logic tab, the…
Tue, 01/02/2024 - 01:06

It is in the logic tab, the block says = in the middle, but if you click on to it's options, it should say AND.