Flying TNT Launch

Discussion in 'Spigot Plugin Development' started by WAS, Apr 18, 2017.

  1. WAS

    WAS

    Has anyone accomplished this? I basically, just like all the other TNT issues. Need to know when TNT is about to be launched by another blast. Like for cannons, or just TNT bunched up and it's physics.

    So TNT goes off. Placed TNT is in a registered location. I want to take that event, and cancel it and spawn in a custom primed TNT and send that flying instead (in the correct direction that it would have gone? Mmm math.). :O

    Additionally I read you can't detect TNT being dispensed from a dispenser. Than how do you detect that? Why is TNT hated so much? Lol I understand lag. But ultimately that's end-user scenario and how they use TNT >.>
     
    #1 WAS, Apr 18, 2017
    Last edited: Apr 18, 2017
  2. You can use PaperSpigot which has an EntityAddToWorldEvent which also fires when primed TNT is spawned by a dispenser.
     
    • Optimistic Optimistic x 1
  3. Or you can use the ItemDispenseEvent and check which item is being dispensed. If it's the item you need, cancel the event and spawn a TNTPrimed entity in front of the dispenser. Then remove the item from the dispenser inventory
     
  4. WAS

    WAS

    Doesn't register for TNT. Blocks only. Projectile fire event also doesn't register for TNT.

    :(
     
  5. Well, the event fire every time an item is being dispensed. So if a TNT is tried to be dispensed, you know a TNTPrime entity will spawn. Since you can't that, cancel the event and spawn a TNTPrime which can be modified using World#spawn
     
  6. Wait I just remembered that I did something like this a while ago..
    Check out DispenserTweaks. It is possible to change what happens when a special item is dispensed by overwriting the registry in the BlockDispenser class which is what I did there. Just overwrite the one for TNT and spawn your custom TNT.
     
  7. I'm not really into NMS, I tried to do that without using it and the method above works fine
     
  8. WAS

    WAS

    Man for some reason Github is just spinning away loading forever. I hope it loads soon cause really want to get this out of the way. So I got it to load. And I notice this all works off a ID. TNTPrimed has no ID. What about those traps people use that launch primed TNT? IE a Entity.Looking through the sources seems like a whole lot to do, most of which I am confused by.

    On a side note. I notice Paper Spigot has an ability to change TNT volume. In Spigot, is there anyway to change the volume of the explosion sound during the explosion event, like for TNT?
     
    #8 WAS, Apr 18, 2017
    Last edited: Apr 18, 2017
  9. WAS

    WAS

    Curious, how do you determine the face of the dispenser? Oh wait, nevermind. :p Be sure to import the right class (Material Dispenser)
     
    #9 WAS, Apr 21, 2017
    Last edited: Apr 21, 2017