Add cancelable EntityStructByLightningEvent, Closes #789
This commit is contained in:
parent
96b4fd1da1
commit
2e3d1a3c09
2 changed files with 40 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class EntityStruckByLightningEvent extends EntityEvent
|
||||
{
|
||||
public final EntityLightningBolt lightning;
|
||||
|
||||
public EntityStruckByLightningEvent(Entity entity, EntityLightningBolt lightning)
|
||||
{
|
||||
super(entity);
|
||||
this.lightning = lightning;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
--- ../src_base/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java
|
||||
+++ ../src_work/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java
|
||||
@@ -10,6 +10,8 @@
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
|
||||
public class EntityLightningBolt extends EntityWeatherEffect
|
||||
{
|
||||
@@ -116,7 +118,10 @@
|
||||
for (int l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity = (Entity)list.get(l);
|
||||
- entity.onStruckByLightning(this);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, this)))
|
||||
+ {
|
||||
+ entity.onStruckByLightning(this);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue