Yatopia/patches/server/0023-EMC-SnowmanThrowSnowballEvent.patch

51 lines
2.2 KiB
Diff
Raw Normal View History

2020-02-26 20:12:29 +01:00
From 5d33e4d03846423ec25dc25e398e089d9625d0fd Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 21 Dec 2015 13:33:00 -0500
Subject: [PATCH] EMC SnowmanThrowSnowballEvent
---
.../net/minecraft/server/EntitySnowman.java | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java
index 07ca1a49..15b0ca94 100644
--- a/src/main/java/net/minecraft/server/EntitySnowman.java
+++ b/src/main/java/net/minecraft/server/EntitySnowman.java
@@ -10,6 +10,25 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a);
+ // EMC start
+ public static boolean fireEvent(EntitySnowman snowman, EntitySnowball snowball, EntityLiving target) {
+ org.bukkit.entity.Snowman bukkitSnowman = (org.bukkit.entity.Snowman) snowman.getBukkitEntity();
+ org.bukkit.entity.Snowball bukkitSnowball = (org.bukkit.entity.Snowball) snowball.getBukkitEntity();
+ snowball.projectileSource = bukkitSnowman;
+
+ if (!(new org.bukkit.event.entity.ProjectileLaunchEvent(bukkitSnowball).callEvent())) {
+ return false;
+ }
+
+ com.empireminecraft.customevents.SnowmanThrowSnowballEvent event = new com.empireminecraft.customevents.SnowmanThrowSnowballEvent(
+ bukkitSnowman,
+ bukkitSnowball,
+ target.getBukkitLivingEntity()
+ );
+ return event.callEvent();
+ }
+ // EMC end
+
public EntitySnowman(EntityTypes<? extends EntitySnowman> entitytypes, World world) {
super(entitytypes, world);
}
@@ -99,6 +118,7 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
float f1 = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
entitysnowball.shoot(d1, d2 + (double) f1, d3, 1.6F, 12.0F);
+ if (!fireEvent(this, entitysnowball, entityliving)) return; // EMC
this.a(SoundEffects.ENTITY_SNOW_GOLEM_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
this.world.addEntity(entitysnowball);
}
--
2.25.1.windows.1