How to make an entity that when hurt another entity/player poisons them

Started by PsulAqae_YT on Tue, 08/11/2020 - 14:44

Topic category: Help with modding (Java Edition)

Last seen on 09:08, 16. Aug 2021
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to make an entity that when hurt another entity/player poisons them
Tue, 08/11/2020 - 14:44

Hello
How can I make an entity that when hurt another entity/player poisons them?

Use procedures and source…
Tue, 08/11/2020 - 17:15

Use procedures and source/target entity with entity type check for this. 

Then apply potion using procedure block for this.

I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
another way of doing that is…
Tue, 08/11/2020 - 18:05

another way of doing that is by adding this to the entity code:

// POISON CODE
		 public boolean attackEntityAsMob(Entity entityIn) {
      		if (super.attackEntityAsMob(entityIn)) {
         		if (entityIn instanceof LivingEntity) {
            		int i = 0;
            			if (this.world.getDifficulty() == Difficulty.NORMAL) {
               				i = 7;
            			} else if (this.world.getDifficulty() == Difficulty.HARD) {
               				i = 15;
           				}

            		if (i > 0) {
               	((LivingEntity)entityIn).addPotionEffect(new EffectInstance(Effects.POISON, i * 20, 0));
            	}
         }

         return true;
      } else {
         return false;
      }
   }
// POISON CODE END

 

Last seen on 19:53, 2. Jun 2021
Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
i = duration of poison (in…
Tue, 08/11/2020 - 18:06

i = duration of poison (in RL seconds)