Sponge icon indicating copy to clipboard operation
Sponge copied to clipboard

No cause / context /source for a TNT that set off another TNT

Open Blayyke opened this issue 7 years ago • 2 comments

I am currently running

  • SpongeVanilla version: 1.12.2-7.1.0-BETA-66
  • Java version: 1.8.0_171
  • Operating System: Windows 10 x64
  • Plugins/Mods: Minecraft, Mod Coder Pack, SpongeAPI, SpongeVanilla, EconomyLite, FoxCore, FoxGuard, GWMAutoResetMine, GWMLibrary, LuckPerms, Nucleus, PlotSquared, Rankup, WorldEdit, XTntNerf, pm

Issue Description There is no way to track an explosion event's source back to another TNT entity / block. For instance: Say I set off one TNT in the vicinity of another. The second will blow up as normal, however it will not have any references to the first one, only to the player that the first one had.

-- First block that went off through a player ignition CAUSES:: net.minecraft.entity.item.EntityTNTPrimed -- EntityTNTPrimed['Block of TNT'/7386, l='mines', x=-364.68, y=4.00, z=-631.60] SOURCE::net.minecraft.entity.item.EntityTNTPrimed -- EntityTNTPrimed['Block of TNT'/7386, l='mines', x=-364.68, y=4.00, z=-631.60] CONTEXT::Owner - sponge:owner - org.spongepowered.api.entity.living.player.User - SpongeEventContextKey{id=sponge:owner} CONTEXT::net.minecraft.entity.player.EntityPlayerMP -- EntityPlayerMP['xA5'/328, l='mines', x=-362.08, y=4.00, z=-629.56]

-- Block that was blown up by the first CAUSES:: net.minecraft.entity.item.EntityTNTPrimed -- EntityTNTPrimed['Block of TNT'/8831, l='mines', x=-364.64, y=3.76, z=-630.38] SOURCE::net.minecraft.entity.item.EntityTNTPrimed -- EntityTNTPrimed['Block of TNT'/8831, l='mines', x=-364.64, y=3.76, z=-630.38] CONTEXT::Owner - sponge:owner - org.spongepowered.api.entity.living.player.User - SpongeEventContextKey{id=sponge:owner} CONTEXT::net.minecraft.entity.player.EntityPlayerMP -- EntityPlayerMP['xA5'/328, l='mines', x=-360.84, y=4.00, z=-628.59]

The above lines were printed with the following code (to try debugging):

        System.out.println("CAUSES::");
        for (Object o : event.getCause().all()) {
            System.out.println(o.getClass().getName() + " -- " + o);
        }
        System.out.println("SOURCE::" + event.getSource().getClass().getName() + " -- " + event.getSource());
        event.getContext().asMap().forEach((eventContextKey, o) -> {
            System.out.println("CONTEXT::" + eventContextKey.getName() + " - " + eventContextKey.getId() + " - " + eventContextKey.getAllowedType().getCanonicalName() + " - " + eventContextKey);
            System.out.println("CONTEXT::" + o.getClass().getName() + " -- " + o);
        });

Blayyke avatar Jun 18 '18 10:06 Blayyke

@gabizou: Unfortunately, it seems that we can't use EventContextKeys.IGNITER here, since it only applies to Living (which PrimedTnt is not). Should we add it directly to the cause, or make a breaking change in bleeding?

Aaron1011 avatar Jun 19 '18 22:06 Aaron1011

I'd say make it in the cause.

gabizou avatar Jun 22 '18 15:06 gabizou