Added ProjectileImpactEvent.FireworkRocket (#6758)
This commit is contained in:
parent
fd9bf64d53
commit
45b90a0d45
3 changed files with 37 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
--- a/net/minecraft/entity/item/FireworkRocketEntity.java
|
||||
+++ b/net/minecraft/entity/item/FireworkRocketEntity.java
|
||||
@@ -187,6 +187,7 @@
|
||||
}
|
||||
|
||||
protected void func_213892_a(RayTraceResult p_213892_1_) {
|
||||
+ if(p_213892_1_.func_216346_c() != RayTraceResult.Type.MISS && net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, p_213892_1_)) return;
|
||||
if (p_213892_1_.func_216346_c() == RayTraceResult.Type.ENTITY && !this.field_70170_p.field_72995_K) {
|
||||
this.func_213893_k();
|
||||
} else if (this.field_70132_H) {
|
|
@ -36,6 +36,7 @@ import net.minecraft.entity.SpawnReason;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.effect.LightningBoltEntity;
|
||||
import net.minecraft.entity.item.FireworkRocketEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.monster.ZombieEntity;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
|
@ -630,6 +631,11 @@ public class ForgeEventFactory
|
|||
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray));
|
||||
}
|
||||
|
||||
public static boolean onProjectileImpact(FireworkRocketEntity fireworkRocket, RayTraceResult ray)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.FireworkRocket(fireworkRocket, ray));
|
||||
}
|
||||
|
||||
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
|
||||
{
|
||||
LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.FireworkRocketEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.projectile.DamagingProjectileEntity;
|
||||
import net.minecraft.entity.projectile.ThrowableEntity;
|
||||
|
@ -104,4 +105,24 @@ public class ProjectileImpactEvent extends EntityEvent
|
|||
return throwable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event is cancellable, causes firework to ignore the current hit and continue on its journey.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class FireworkRocket extends ProjectileImpactEvent
|
||||
{
|
||||
private final FireworkRocketEntity fireworkRocket;
|
||||
|
||||
public FireworkRocket(FireworkRocketEntity fireworkRocket, RayTraceResult ray)
|
||||
{
|
||||
super(fireworkRocket, ray);
|
||||
this.fireworkRocket = fireworkRocket;
|
||||
}
|
||||
|
||||
public FireworkRocketEntity getFireworkRocket()
|
||||
{
|
||||
return fireworkRocket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue