How to cancel block destroy with TNT?

Discussion in 'Plugin Development' started by Etsijä, May 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Etsijä

    I'm positive this has been asked many times, but here goes: is there a way to let TNT damage entities and break blocks, but not destroy them? So, detonations would work as usual, but without destroying completely some of the broken blocks? So that all blocks detonated could be gathered from the place of detonation.
     
  2. Offline

    ZeusAllMighty11

    You can't half break a block?

    I don't understand the question
     
    afistofirony likes this.
  3. Offline

    Pink__Slime

    Etsijä TheGreenGamerHD
    I understand... When TNT explodes, a percentage of the blocks broken in the explosion are permanently destroyed and can't be picked up. I think what the OP wants is a way to stop the blocks from permanently being destroyed.
     
  4. Offline

    ZeusAllMighty11

    Pink__Slime

    So, like, they destroy then come back?
     
  5. Offline

    Pink__Slime

    TheGreenGamerHD
    So all the blocks are there.

    Example:
    Player sets off tnt. 100 blocks are broken in the explosion. Only 75 of them are available to pick up because the other 25 where destroyed. Etsijä wants it so all 100 blocks are available to pick up.
     
  6. Offline

    ZeusAllMighty11

    You are wording too hard for me to understand, excuse my bad english...

    Do you mean block or item drop?
     
  7. Offline

    Etsijä

    My point exactly.
     
  8. Offline

    Pink__Slime

    TheGreenGamerHD
    Sorry, I'll try to explain a little easier.
    100 blocks were broken in a TNT explosion. 75 blocks had their items dropped. The other 25 didn't drop items.
    OP wants all 100 blocks to drop their respective items when broken in a TNT explosion.
     
  9. Offline

    ZeusAllMighty11

    Oh, I was correct, you guys were mixing up the terms 'block' and 'itemstack'.

    To do this, when the explosion is called, grab all the blocks affected by it, and store the count of the material dropped.

    Then if there were 100 blocks of GRASS but only 64 in your storage, drop an extra 36
     
  10. Offline

    Etsijä

    No, I think you are the one who misunderstood, as you are talking about a completely different situation. My question has nothing to do with players getting killed by TNT and dropping items.

    I don't know how I could put this simpler than this: is there a way to prevent TNT "eating up" blocks when it detonates? So that when I detonate a TNT, it leaves on the ground exactly all of those blocks it broke when detonating.

    In Tekkit, there is IndustrialTNT, which destroys far less blocks in detonations:
    http://thetekkit.wikia.com/wiki/Industrial_TNT

    But it still destroys about 10% of them (compared to roughly 70% in vanilla Minecraft). And, we are not using Tekkit (and won't be doing that ever on our server). I want an option that the TNT wouldn't destroy ("eat up") ANY blocks.
     
  11. Offline

    lenis0012

    use the EntityExplodeEvent and check if the entity is an instance of PrimedTNT

    Then use event.getBlocks().clear() or something
     
  12. Offline

    ZeusAllMighty11


    Actually I didn't misunderstand.

    An item on the ground is an entity. When picked up, it is an itemstack.

    You kept saying


    A block represents a physical 3 dimensional object placed in the world at a set of coordinates with corresponding material data and (sometimes) metadata. Block != entity , Block != itemstack

    Please, be more clear and don't blame me for misunderstanding when you had mixed them up.



    You are referring to the TNT destroying the block drop entities.
     
  13. Offline

    lolwel21

    Is there a way to make it not even break the blocks in the first place? That would be helpful for pvp if you don't want anything to get messed up.
     
  14. Offline

    Etsijä

    Yes, that would be very useful, and far easier to do than "cleaning up / rewinding" afterwards.
     
  15. Offline

    lolwel21

    I just found out... if you can override the EntityExplode event for TNT, then make an explosion that doesn't break blocks by using world.createExplosion(float x, float y, float z, float power, boolean setFire, boolean breakBlocks); It should work: it didn't throw any errors.
     
  16. Offline

    Windy Day

    I'm not sure if this would work or not, but it is an idea on how to do it never the less. Maybe you could listen for block break events and if it is damaged by an explosion then cancel the drop, get the block's id (the destroyed one) and create a time stack out of it, then drop that instead? If it works it would drop 100% of the items and ores would be the actual ore blocks but... maybe it would work.
     
  17. Offline

    Technius

    Etsijä
    Code:
    event.setYield(1);
    
     
Thread Status:
Not open for further replies.

Share This Page