Add throwable impact event (#3071)
This commit is contained in:
parent
5eeda79234
commit
f76af6103e
3 changed files with 54 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityThrowable.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityThrowable.java
|
||||
@@ -246,6 +246,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
+ if(!net.minecraftforge.common.ForgeHooks.onThrowableImpact(this, raytraceresult))
|
||||
this.func_70184_a(raytraceresult);
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ import net.minecraft.entity.item.EntityMinecartContainer;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -100,6 +101,7 @@ import net.minecraftforge.event.AnvilUpdateEvent;
|
|||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.ServerChatEvent;
|
||||
import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
|
||||
import net.minecraftforge.event.entity.ThrowableImpactEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
@ -1133,4 +1135,9 @@ public class ForgeHooks
|
|||
//TODO: Some registry to support custom LootEntry types?
|
||||
public static LootEntry deserializeJsonLootEntry(String type, JsonObject json, int weight, int quality, LootCondition[] conditions){ return null; }
|
||||
public static String getLootEntryType(LootEntry entry){ return null; } //Companion to above function
|
||||
|
||||
public static boolean onThrowableImpact(EntityThrowable throwable, RayTraceResult ray)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new ThrowableImpactEvent(throwable, ray));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package net.minecraftforge.event.entity;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
|
||||
/**
|
||||
* This event is fired before an {@link EntityThrowable} calls its {@link EntityThrowable#onImpact} method.
|
||||
* This event is fired via {@link net.minecraftforge.common.ForgeHooks#onThrowableImpact}.
|
||||
* This event is cancelable. When canceled, {@link EntityThrowable#onImpact} will not be called.
|
||||
* Killing or other handling of the entity after event cancellation is up to the modder.
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
|
||||
*/
|
||||
@Cancelable
|
||||
public class ThrowableImpactEvent extends EntityEvent
|
||||
{
|
||||
private final EntityThrowable throwable;
|
||||
private final RayTraceResult ray;
|
||||
|
||||
public ThrowableImpactEvent(EntityThrowable throwable, RayTraceResult ray)
|
||||
{
|
||||
super(throwable);
|
||||
this.throwable = throwable;
|
||||
this.ray = ray;
|
||||
}
|
||||
|
||||
public EntityThrowable getEntityThrowable()
|
||||
{
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public RayTraceResult getRayTraceResult()
|
||||
{
|
||||
return ray;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue