Posted March 14, 201510 yr How can I tell when/where a lightning bolt strikes? I've tried basically all of the events relating to entity spawning, and none work. The only even relating to lightning seems to be when entities are struck by it. Does anybody have any idea of what I could do? Thanks in advance.
March 15, 201510 yr EntityLightningBolt extends EntityWeatherEffect extends Entity public EntityLightningBolt(World worldIn, double posX, double posY, double posZ) { super(worldIn); this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F); Ligtning entity has x,y,z you can easily get it from EntityJoinWorldEvent with checking if entity is lightning (and ofc. side). EDIT: Whoa (post below) - I didn't know that, sry OP. 1.7.10 is no longer supported by forge, you are on your own.
March 15, 201510 yr Hi I'm not sure there's an easy way to do this; although EntityLightningBolt is an "Entity", it isn't treated the same as other entities. It gets "spawned" into its own list of weather effects. The code is in WorldServer:: this.theProfiler.endStartSection("thunder"); int i1; BlockPos blockpos; if (this.provider.canDoLightning(chunk) && this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering()) { this.updateLCG = this.updateLCG * 3 + 1013904223; i1 = this.updateLCG >> 2; blockpos = this.func_175736_a(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15))); if (this.func_175727_C(blockpos)) { this.addWeatherEffect(new EntityLightningBolt(this, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ())); } } There is also client-side code (see S2CPacketSpawnGlobalEntity.processPacket() but I don't think it will help either. I think you will probably need to use ASM+Reflection to insert your own hook in there. That's a pretty advanced technique. -TGG
March 15, 201510 yr Author Oooooohh boy. That kinda sucks for me, just started modding a couple days ago. I guess I'll just have to make it so entities hit by lightning drop my item. Almost never happens, but hey, that's what I gotta do I guess. Thanks guys.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.