Throwable Entity

Started by maxence_abrt on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Throwable Entity

How to make an entity that moves where the player looks and explodes if it comes into contact with something (example: I created my entity on blockbench, and I would like that when I click right with my sword it summons it and throws it in the direction where the player looks and if it collides with a block or other entity it explodes.)

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Grenades are fun. You'll…
Fri, 09/22/2023 - 03:59

Grenades are fun. You'll want to make an entity, then make an item that, when right clicked by the player, shrinks the item stack, summons an entity, and then sets the momentum of the nearest entity of that type to the x/y/z look angle vectors of the player throwing it. (Use the 'attempt to override motion-vector' function block, and the 'x/y/z look-angle vector of...' blocks.) Then, on the entity's tick update, make a procedure that despawns the entity and creates an explosion if that entity's velocities are all at or near zero. 

The problem here, (as I may have learned the hard way), is that if you spawn the entity and then add momentum to it, there's a chance the explosion will trigger immedieately, because the entity has no velocity when you first spawn it, meaning you either need a different explosion trigger, or... (and this is a weird work around), on the entity's 'when entity spawns' trigger, you also give it a set number of ticks of a random potion, (like Luck, for example), and then only trigger the explosion if velocity is zero and the entity doesn't have the specific potion effect. (Giving the thing a delay that you can then configure.)