[SOLVED] Make entity take damage when rammed into?

Started by OkayOak on

Topic category: Help with modding (Java Edition)

Last seen on 22:12, 23. Apr 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] Make entity take damage when rammed into?
Sun, 12/31/2023 - 00:25 (edited)

Hello, I'm trying to make a shield that can ram forward, and deal damage to enemies/knock them back when rammed into. How would I go about this?

Edited by OkayOak on Sun, 12/31/2023 - 00:25
Last seen on 22:12, 23. Apr 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Solved this on my own, so…
Sun, 12/31/2023 - 00:25

Solved this on my own, so for anyone wondering:

Once you have your ram procedure set up (with a keybind or otherwise) have your entity/item run through the "For each entity as entity iterator in cube at x/y/z with radius 1 do", with the if statement "not (is Entity iterator the same entity as Event/target entity [the entity with the item/entity ramming])"and do the following:

For damage: "Deal (however much damage) damage to Entity iterator from source (whatever source you want)"

For knockback: "Attempt to override motion vector of Entity iterator to vx: ((x delta movement of Event/target entity) multiplied by something) vy: (anything) vz: (z delta movement of Event/target entity) multiplied by something)"

Play around with the damage value and vx/vy/vz values until it feels right :)