PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.99k stars 2.31k forks source link

World#createExplosion does not damage or deal knockback to the explosion cause #11167

Closed EsotericEnderman closed 3 months ago

EsotericEnderman commented 3 months ago

Expected behavior

Explosions created using World#createExplosion should deal damage and knockback to all entities within the range of the explosion, including the entity specified as the explosion cause.

Observed/Actual behavior

Explosions created using World#createExplosion deal the proper damage and knockback to all entities other than the entity specified as the source argument.

Steps/models to reproduce

I encountered this issue while developing my plugin. The instant TNT feature does not work correctly because of this, and functions as described above.

Steps to reproduce:

For example, here is the code used in my plugin:

    private void detonateInstantTnt(@NotNull Block instantTnt, @Nullable Entity cause) {
        instantTnt.setType(Material.AIR);

        float power = (float) plugin.getConfig().getDouble("features.instant-tnt.explosion.power");
        boolean shouldSetFire = plugin.getConfig().getBoolean("features.instant-tnt.explosion.sets-fire");
        boolean shouldBreakBlocks = plugin.getConfig().getBoolean("features.instant-tnt.explosion.breaks-blocks");

        instantTnt.getWorld().createExplosion(BlockUtil.getBlockCenterLocation(instantTnt), power, shouldSetFire, shouldBreakBlocks, cause);

        removeInstantTnt(instantTnt);
    }

My config.yml:

features:
  instant-tnt:
    enabled: true
    # The unit for this variable is meters per second.
    minimum-collision-detonation-speed: 0.75
    explosion:
      power: 2.0
      breaks-blocks: false
      sets-fire: false
      spread-radius-blocks: 8.0
      blocks-per-tick-delay: 0.0

Plugin and Datapack List

Output after doing /plugins:

Server Plugins (1):
Paper Plugins:
 - BadPiggiesPlugin

Output after doing /datapack list:

There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
There are no more data packs available

Paper version

Checking version, please wait...
This server is running Paper version 1.21-109-master@5a5035b (2024-07-23T08:16:30Z) (Implementing API version 1.21-R0.1-SNAPSHOT)\nYou are running the latest version

Other

No response

Doc94 commented 3 months ago

I mean the source is for that use like a source of damage, same than creeper and another things exploding.

lynxplay commented 3 months ago

Yea, this is simply vanilla behaviour. The API could expose a way to pass in a damage source, that way the "source" entity could remain null but the damage source may have an indirect entity, but changing vanilla behaviour here is a no-go.

Closing this as works as intended.