How do I make throwable tnt? (Basically dynamite, using a item or a ranged item)

Started by NoahBearGaming on

Topic category: Help with MCreator software

Last seen on 02:42, 5. Nov 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make throwable tnt? (Basically dynamite, using a item or a ranged item)

I am trying to make an SMP and need a throwable tnt. I need to make it work in survival mode and fires when you press right click. I also need it to NOT explode on my Minecraft player when throwing the tnt (dynamite) Can someone please help me out, I've been trying to get this to work in 1.20.1 forge and there are no helpful tutorials.

Last seen on 21:55, 20. Feb 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You probably don't want to…
Thu, 11/02/2023 - 02:08

You probably don't want to do this with a Ranged item, as they have a lot of built in code that can be hard to work with for throwable stuff. The basic idea would be like this:

  • Create an entity for your throwable TNT, using the model/texture you would've used for a projectile. Make sure to disable spawning and AI for this entity, and to adjust its hitbox and whatnot to your liking. You may also want to disable hitbox collisions if you don't want this to be able to be moved once it hits the ground.
  • Then, make a separate item for throwable TNT that is just a regular item. With this item, make a procedure that triggers when the player right clicks with that item in their main hand.
  • For this procedure, shrink the itemstack in the player's main hand by one if they aren't in creative mode, and spawn a throwable TNT entity at the player's position, with its velocity set to the player's x/y/z look angle vectors. (This will launch the entity in the direction the player is looking. You can multiply each of these values by decimals or whole numbers to increase or decrease the force with which the entity is thrown.) 
  • Lastly, make an 'On Update Tick' procedure for your throwable TNT entity, that gives it, say, 60 ticks of ambient Unluck, (or any other potion effect), when its y-velocity does not equal zero. Then, if its Y velocity equals zero, and it does not have Unluck, despawn the entity and create an explosion at its position. (This means the potion effect has to run out, and the TNT has to have stopped falling before it explodes, giving the thing a slight fuse. It's important to have some delay, even if it's very short, because otherwise if the TNT is thrown upwards, its y velocity will equal zero right before it starts falling down, and it'll explode in midair.) 

I've made stuff like this before, so I could also send some screenshots if that would be helpful. Good luck!

Last seen on 00:53, 22. Feb 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you want an easy way,…
Thu, 11/02/2023 - 02:22

If you want an easy way, just make a ranged item with dynamite texture --> go to triggers --> add a procedure to when projectile hits block and projectile hits entity --> inthe procedure add explosion level of your choice  

Last seen on 02:42, 5. Nov 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thats really helpful! I don…
Thu, 11/02/2023 - 02:23

Thats really helpful! I don't know how to make it so that it shoots the dynamite out of my hand in survival, because when I did this it just explodes right onto me. How do I fix this?

Last seen on 00:53, 22. Feb 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is pretty much how you…
Thu, 11/02/2023 - 18:27

This is pretty much how you could do it:

1) Create a ranged item:


Mess around with these settings however you want, and you can choose ammo for it if you'd like

 

2) While your ranged item tab is open, create a new item for the projectile texture and call it whatever you want: 


3) Make sure to use the new item as the "texture representing projectile" for your ranged item

 

4) Open the triggers tab of the ranged item, and find the following two triggers (when projectile hits block & when projectile hits living entity):


5) Click + on one of them, and create the following procedure


6) Add the procedure to both triggers


7) Dont forget to save all your elements