summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityFireball.patch
blob: b236dc4b6dce05b096b00c04acb2d37ee27f7508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--- a/net/minecraft/server/EntityFireball.java
+++ b/net/minecraft/server/EntityFireball.java
@@ -1,5 +1,7 @@
 package net.minecraft.server;
 
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
 public abstract class EntityFireball extends Entity {
 
     public EntityLiving shooter;
@@ -8,6 +10,8 @@
     public double dirX;
     public double dirY;
     public double dirZ;
+    public float bukkitYield = 1; // CraftBukkit
+    public boolean isIncendiary = true; // CraftBukkit
 
     protected EntityFireball(EntityTypes<?> entitytypes, World world, float f, float f1) {
         super(entitytypes, world);
@@ -28,11 +32,18 @@
     public EntityFireball(EntityTypes<?> entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world, float f, float f1) {
         this(entitytypes, world, f, f1);
         this.shooter = entityliving;
+        this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
         this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
         this.setPosition(this.locX, this.locY, this.locZ);
         this.motX = 0.0D;
         this.motY = 0.0D;
         this.motZ = 0.0D;
+        // CraftBukkit start - Added setDirection method
+        this.setDirection(d0, d1, d2);
+    }
+
+    public void setDirection(double d0, double d1, double d2) {
+        // CraftBukkit end
         d0 += this.random.nextGaussian() * 0.4D;
         d1 += this.random.nextGaussian() * 0.4D;
         d2 += this.random.nextGaussian() * 0.4D;
@@ -59,6 +70,12 @@
 
             if (movingobjectposition != null) {
                 this.a(movingobjectposition);
+
+                // CraftBukkit start - Fire ProjectileHitEvent
+                if (this.dead) {
+                    CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
+                }
+                // CraftBukkit end
             }
 
             this.locX += this.motX;
@@ -146,6 +163,11 @@
         } else {
             this.aA();
             if (damagesource.getEntity() != null) {
+                // CraftBukkit start
+                if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+                    return false;
+                }
+                // CraftBukkit end
                 Vec3D vec3d = damagesource.getEntity().aN();
 
                 if (vec3d != null) {
@@ -159,6 +181,7 @@
 
                 if (damagesource.getEntity() instanceof EntityLiving) {
                     this.shooter = (EntityLiving) damagesource.getEntity();
+                    this.projectileSource = (org.bukkit.projectiles.ProjectileSource) this.shooter.getBukkitEntity();
                 }
 
                 return true;