Help with dealing more damage under contions

Started by oddo1 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with dealing more damage under contions
Tue, 10/07/2025 - 13:25 (edited)

So, basically i wanted to make a scythe weapon (and other stuff too), i wanted the scythe to deal 5 extra damage to entities without helmet...i have the procedure but ik that in the way minecraft works, with mcreator is basically impossible. Minecraft has a 10ticks delay when an entity is hurt, so trying to deal another value of damage is going to make the game crash or the damage is completely ignored. I really need help since i'm stuck on this problem for 1 month, i'm currently using 2024.4 version of MCreator. Thanks 

Edited by oddo1 on Tue, 10/07/2025 - 13:25
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
what is your minecraft…
Fri, 10/03/2025 - 15:47

what is your minecraft version?

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
my minecraft version is 1.20…
Mon, 10/06/2025 - 17:08

my minecraft version is 1.20.1

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
does that version of…
Mon, 10/06/2025 - 17:25

does that version of mcreator have the generated code viewer button?

and what damage triggers are available?

 

Can you show the generated code for all of them? There are probably two something like,

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, there are those 2…
Tue, 10/07/2025 - 05:50

Yes, there are those 2 conditions and yes there is the generated code view 

First method: Entity is attacked ---> If get item armor slot 3 == air ----> deal 5 damage to event entity from source damage generic made by source entity 

The second method is the same as the other one but the global condition is "Entity is hurt".

First method's code: 

package net.mcreator.oddoosrpg.procedures;

/* imports omitted */

@Mod.EventBusSubscriber

public class ScytheDealsMoreDamageProcedure {

    @SubscribeEvent

    public static void onEntityAttacked(LivingAttackEvent event) {

        if (event != null && event.getEntity() != null) {

            execute(event, event.getEntity().level(), event.getEntity(), event.getSource().getEntity());

        }

    }



    public static void execute(LevelAccessor world, Entity entity, Entity sourceentity) {

        execute(null, world, entity, sourceentity);

    }



    private static void execute(@Nullable Event event, LevelAccessor world, Entity entity, Entity sourceentity) {

        if (entity == null || sourceentity == null)

            return;

        if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.HEAD) : ItemStack.EMPTY).getItem() == Blocks.AIR.asItem()) {

            entity.hurt(new DamageSource(world.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.GENERIC), sourceentity), 5);

        }

    }

}
Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I even accept solutions that…
Tue, 10/07/2025 - 05:52

I even accept solutions that require coding because i REALLY need this... Also, how do you send images here?

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
And i forgot to say…
Tue, 10/07/2025 - 05:55

And i forgot to say something... if i put a damage that is bigger than the damage you are going to do, the bigger damage will replace your damage with the value...

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sure, here:  package net…
Tue, 10/07/2025 - 11:05

Sure, here: 

package net.mcreator.oddoosrpg.procedures;

/* imports omitted */

@Mod.EventBusSubscriber

public class AaaaaaProcedure {

    @SubscribeEvent

    public static void onEntityAttacked(LivingHurtEvent event) {

        if (event != null && event.getEntity() != null) {

            execute(event, event.getEntity().level(), event.getEntity(), event.getSource().getEntity());

        }

    }



    public static void execute(LevelAccessor world, Entity entity, Entity sourceentity) {

        execute(null, world, entity, sourceentity);

    }



    private static void execute(@Nullable Event event, LevelAccessor world, Entity entity, Entity sourceentity) {

        if (entity == null || sourceentity == null)

            return;

        if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.HEAD) : ItemStack.EMPTY).getItem() == Blocks.AIR.asItem()) {

            entity.hurt(new DamageSource(world.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.GENERIC), sourceentity), 5);

        }

    }

}
Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
great that one works so you…
Tue, 10/07/2025 - 11:09

great that one works so you have to use that trigger, and then

try this,

((LivingHurtEvent)event).setAmount((float)set_amount);

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I will try this and tell you…
Tue, 10/07/2025 - 11:11

I will try this and tell you if it works, thank you so much

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Umh.. idk if i'm stupid (bc…
Tue, 10/07/2025 - 11:28

Umh.. idk if i'm stupid (bc i'm not familiar with java) but this doesn't seem to work... i have a question... what does the local variable "set_amount" do exactly..?

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it's just a helper variable…
Tue, 10/07/2025 - 11:30

it's just a helper variable so you don't have to change the custom code snippet to change what it sets the damage to

what about it doesn't work?

Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ohh... ok... i re-tried…
Tue, 10/07/2025 - 11:39

ohh... ok... i re-tried again putting the value in the local variable but the damage it's still the same...

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
any errors in console? I don…
Tue, 10/07/2025 - 11:41

any errors in console? I don't have mcreator for 1.20.1 set up rn so I can't test