No cause / context /source for a TNT that set off another TNT
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);
});
@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?
I'd say make it in the cause.