aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch
blob: 0d280ee620d0a3d78f53d29a44f523aee65ca96d (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
72
73
74
75
76
77
78
79
80
81
82
83
84
--- a/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
+++ b/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
@@ -16,11 +16,14 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.phys.HitResult;
 import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
 
 public abstract class AbstractHurtingProjectile extends Projectile {
     public double xPower;
     public double yPower;
     public double zPower;
+    public float bukkitYield = 1; // CraftBukkit
+    public boolean isIncendiary = true; // CraftBukkit
 
     protected AbstractHurtingProjectile(EntityType<? extends AbstractHurtingProjectile> entityType, Level level) {
         super(entityType, level);
@@ -37,11 +39,18 @@
         this(entityType, level);
         this.moveTo(x, y, z, this.getYRot(), this.getXRot());
         this.reapplyPosition();
-        double squareRoot = Math.sqrt(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ);
-        if (squareRoot != 0.0) {
-            this.xPower = offsetX / squareRoot * 0.1;
-            this.yPower = offsetY / squareRoot * 0.1;
-            this.zPower = offsetZ / squareRoot * 0.1;
+        // CraftBukkit start - Added setDirection method
+        this.setDirection(d3, z, d5);
+    }
+
+    public void setDirection(double d3, double d4, double d5) {
+        // CraftBukkit end
+        double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
+
+        if (d6 != 0.0D) {
+            this.xPower = d3 / d6 * 0.1D;
+            this.yPower = d4 / d6 * 0.1D;
+            this.zPower = d5 / d6 * 0.1D;
         }
     }
 
@@ -81,9 +92,16 @@
                 this.setSecondsOnFire(1);
             }
 
-            HitResult hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType());
-            if (hitResultOnMoveVector.getType() != HitResult.Type.MISS) {
-                this.onHit(hitResultOnMoveVector);
+            HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType());
+
+            if (movingobjectposition.getType() != HitResult.EnumMovingObjectType.MISS) {
+                this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
+
+                // CraftBukkit start - Fire ProjectileHitEvent
+                if (this.isRemoved()) {
+                    CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
+                }
+                // CraftBukkit end
             }
 
             this.checkInsideBlocks();
@@ -185,11 +199,17 @@
             Entity entity = source.getEntity();
             if (entity != null) {
                 if (!this.level().isClientSide) {
-                    Vec3 lookAngle = entity.getLookAngle();
-                    this.setDeltaMovement(lookAngle);
-                    this.xPower = lookAngle.x * 0.1;
-                    this.yPower = lookAngle.y * 0.1;
-                    this.zPower = lookAngle.z * 0.1;
+                    // CraftBukkit start
+                    if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, amount, false)) {
+                        return false;
+                    }
+                    // CraftBukkit end
+                    Vec3 vec3d = entity.getLookAngle();
+
+                    this.setDeltaMovement(vec3d);
+                    this.xPower = vec3d.x * 0.1D;
+                    this.yPower = vec3d.y * 0.1D;
+                    this.zPower = vec3d.z * 0.1D;
                     this.setOwner(entity);
                 }