@Inject( method = "onUpdate", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/effect/EntityLightningBolt;setDead()V")) public void onSetDead(CallbackInfo ci) { if (this.isDead) { return; } World world = (World) this.worldObj; LightningEvent.Strike strike = SpongeEventFactory.createLightningEventStrike( this.cause, this.struckEntities, this.struckEntitySnapshots, world, this.struckBlocks); Sponge.getEventManager().post(strike); if (!strike.isCancelled()) { for (Transaction<BlockSnapshot> bt : strike.getTransactions()) { if (bt.isValid()) { BlockSnapshot bs = bt.getFinal(); world.setBlock(bs.getPosition(), bs.getState()); } } for (Entity e : strike.getEntities()) { ((net.minecraft.entity.Entity) e).onStruckByLightning((EntityLightningBolt) (Object) this); } SpongeImpl.postEvent(SpongeEventFactory.createLightningEventPost(this.cause)); } }
public void revertActiveVisual(Player player) { if (this.visualRevertTask != null) { this.visualRevertTask.cancel(); } if (this.visualClaimId != null) { Claim claim = GriefPrevention.instance.dataStore.getClaim(this.worldProperties, this.visualClaimId); if (claim != null) { claim.playersWatching.remove(this.playerID); } } this.visualClaimId = null; if (this.visualBlocks == null || !player .getWorld() .equals(this.visualBlocks.get(0).getFinal().getLocation().get().getExtent())) { return; } for (int i = 0; i < this.visualBlocks.size(); i++) { BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal(); player.sendBlockChange(snapshot.getPosition(), snapshot.getState()); } }