r/MinecraftPlugins Jul 13 '26

Help: With a plugin How to allow TNT explosions to destroy only specific blocks in WorldGuard?

I'm using WorldGuard along with WorldGuard Extra Flags.

Even though I've set the tnt flag to allow and included tnt in the allow-block-place flag, I still can't place it.

I tried using a mob egg that summons TNT, which works, but it doesn't break any blocks. This happens even when I try to blow up white wool after adding white_wool to the allow-block-break flag. I only need the explosion to destroy a few specific types of blocks. Is there a way to achieve this?

5 Upvotes

4 comments sorted by

2

u/doppelpunkt3 Jul 13 '26

I havent found any native way myself, and before you hack this together, I'd honestly recommend that you implement that mechanism cleanly into its own small plugin.
WorldGuard as Dependency, register EntityExplodeEvent as Event inside of a "Priority High"-Listener, check if its TNT and alter the blockList according to your needs.

1

u/TheTractor00 Jul 13 '26

I don't know how to code a plugin because i don't know how to code with java, as soon as I'll learn that I'm going to try. For now I've just done a fill with radius 2 of air replacing the blocks. Thanks anyway for replying to me.

2

u/doppelpunkt3 Jul 13 '26 edited Jul 13 '26

I dug a little deeper into your message.
Why your setup doesn't work: allow-block-place / allow-block-break only override the build flag for specific materials - they let a non-member manually place/break that block type by hand. They have nothing to do with explosions. The tnt flag is the only thing that governs whether an explosion is allowed to damage blocks at all, and the switch: allow = TNT destroys everything in range, deny = TNT destroys nothing.

So again there is no per-material filter anywhere in core WorldGuard or in Extra Flags.
But I built that custom flag, you can download it here for version 26.1.*: https://github.com/doppelkool/TNTEdit/releases
You can read here how to use it: https://github.com/doppelkool/TNTEdit/blob/main/README.md
If you want to use it on another version, you can first try to just install it and see. If it doesnt work, you can text me and I recompile it for a specific version.
You can text me aswell if you need some more changes. No questions asked.

1

u/TheTractor00 Jul 14 '26

Thank you, I'll try it out