|
@@ -28,6 +28,7 @@ import net.minecraft.server.MinecraftServer;
|
|
|
import net.minecraft.server.management.PlayerList;
|
|
|
import net.minecraft.util.Hand;
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
+import net.minecraft.util.math.EntityRayTraceResult;
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
import net.minecraft.util.text.StringTextComponent;
|
|
@@ -399,19 +400,26 @@ public class ScriptEvents
|
|
|
@SubscribeEvent
|
|
|
public void onProjectileHit(ProjectileImpactEvent e)
|
|
|
{
|
|
|
+ Entity hitEntity;
|
|
|
+ boolean hit;
|
|
|
+
|
|
|
+ if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY && e.getRayTraceResult() instanceof EntityRayTraceResult)
|
|
|
+ {
|
|
|
+ hit = true;
|
|
|
+ hitEntity = ((EntityRayTraceResult) e.getRayTraceResult()).getEntity();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ hit = false;
|
|
|
+ hitEntity = null;
|
|
|
+ }
|
|
|
+
|
|
|
handleEvent(Utils.getPlayerFromProjectile(e.getEntity()), "throw_hit", (sc) ->
|
|
|
{
|
|
|
- if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY && e.getRayTraceResult().hitInfo != null)
|
|
|
- {
|
|
|
- sc.setVar("is_entity_hit", true);
|
|
|
- sc.setVar("entity_hit", e.getRayTraceResult().hitInfo);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sc.setVar("is_entity_hit", false);
|
|
|
- }
|
|
|
+ sc.setVar("is_entity_hit", hit);
|
|
|
+ sc.setVar("entity_hit", hitEntity);
|
|
|
ScriptVars.setEntityVars(sc, e.getEntity());
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public void onEntityItemProjectileHit(EntityItemProjectile ent, PlayerEntity p, ItemStack stack, List<Entity> ents)
|