Skip to content

Commit 032d9a3

Browse files
authored
[no ci] Merge pull request #314 from TonimatasDEV/1.20.1
Fix onHit mixins
2 parents 55257b4 + c6bfaea commit 032d9a3

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

patches/minecraft/net/minecraft/world/entity/projectile/AbstractArrow.java.patch

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
this.clearFire();
3131
}
3232

33-
@@ -186,9 +_,28 @@
33+
@@ -186,9 +_,34 @@
3434
}
3535
}
3636

@@ -42,6 +42,9 @@
4242
+ case SKIP_ENTITY:
4343
+ if (hitresult.getType() != HitResult.Type.ENTITY) { // If there is no entity, we just return default behaviour
4444
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
45+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
46+
+ this.onHit(hitresult);
47+
+ }
4548
+ this.hasImpulse = true;
4649
+ break;
4750
+ }
@@ -56,6 +59,9 @@
5659
+ this.setPierceLevel((byte) 0);
5760
+ case DEFAULT:
5861
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
62+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
63+
+ this.onHit(hitresult);
64+
+ }
5965
+ this.hasImpulse = true;
6066
+ break;
6167
+ }

patches/minecraft/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java.patch

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
double d0 = Math.sqrt(p_36821_ * p_36821_ + p_36822_ * p_36822_ + p_36823_ * p_36823_);
2323
if (d0 != 0.0D) {
2424
this.xPower = p_36821_ / d0 * 0.1D;
25-
@@ -65,8 +_,14 @@
25+
@@ -65,8 +_,17 @@
2626
}
2727

2828
HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
2929
- if (hitresult.getType() != HitResult.Type.MISS) {
3030
- this.onHit(hitresult);
3131
+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) {
3232
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
33+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
34+
+ this.onHit(hitresult);
35+
+ }
3336
+
3437
+ // CraftBukkit start - Fire ProjectileHitEvent
3538
+ if (this.isRemoved()) {

patches/minecraft/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323
protected void defineSynchedData() {
2424
this.entityData.define(DATA_ID_FIREWORKS_ITEM, ItemStack.EMPTY);
2525
this.entityData.define(DATA_ATTACHED_TO_TARGET, OptionalInt.empty());
26-
@@ -130,7 +_,7 @@
26+
@@ -130,7 +_,10 @@
2727

2828
HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
2929
if (!this.noPhysics) {
3030
- this.onHit(hitresult);
3131
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
32+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
33+
+ this.onHit(hitresult);
34+
+ }
3235
this.hasImpulse = true;
3336
}
3437

patches/minecraft/net/minecraft/world/entity/projectile/FishingHook.java.patch

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@
2929
if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0D)) {
3030
return false;
3131
} else {
32-
@@ -241,7 +_,7 @@
32+
@@ -241,7 +_,12 @@
3333

3434
private void checkCollision() {
3535
HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
3636
- this.onHit(hitresult);
37-
+ if (hitresult.getType() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) this.preOnHit(hitresult); // CraftBukkit - projectile hit event
37+
+ if (hitresult.getType() == HitResult.Type.MISS || !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) {
38+
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
39+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
40+
+ this.onHit(hitresult);
41+
+ }
42+
+ }
3843
}
3944

4045
protected boolean canHitEntity(Entity p_37135_) {
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
--- a/net/minecraft/world/entity/projectile/LlamaSpit.java
22
+++ b/net/minecraft/world/entity/projectile/LlamaSpit.java
3-
@@ -29,7 +_,8 @@
3+
@@ -29,7 +_,12 @@
44
super.tick();
55
Vec3 vec3 = this.getDeltaMovement();
66
HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
77
- this.onHit(hitresult);
8-
+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult))
9-
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
8+
+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) {
9+
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
10+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
11+
+ this.onHit(hitresult);
12+
+ }
13+
+ }
1014
double d0 = this.getX() + vec3.x;
1115
double d1 = this.getY() + vec3.y;
1216
double d2 = this.getZ() + vec3.z;

patches/minecraft/net/minecraft/world/entity/projectile/Projectile.java.patch

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@
1919
}
2020

2121
@Nullable
22-
@@ -132,6 +_,16 @@
22+
@@ -132,6 +_,15 @@
2323
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, p_37252_.onGround() ? 0.0D : vec3.y, vec3.z));
2424
}
2525

26+
+ protected boolean ketting$preOnHitResult;
2627
+ // CraftBukkit start - call projectile hit event
2728
+ protected void preOnHit(HitResult hitResult) {
2829
+ org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callProjectileHitEvent(this, hitResult);
2930
+ this.hitCancelled = event != null && event.isCancelled();
30-
+ if (hitResult.getType() == HitResult.Type.BLOCK || !this.hitCancelled) {
31-
+ this.onHit(hitResult);
32-
+ }
31+
+ ketting$preOnHitResult = hitResult.getType() == HitResult.Type.BLOCK || !this.hitCancelled;
3332
+ }
3433
+ // CraftBukkit end
3534
+

patches/minecraft/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222

2323
public SoundSource getSoundSource() {
2424
return SoundSource.HOSTILE;
25-
@@ -212,8 +_,8 @@
25+
@@ -212,8 +_,11 @@
2626
}
2727

2828
HitResult hitresult = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
2929
- if (hitresult.getType() != HitResult.Type.MISS) {
3030
- this.onHit(hitresult);
3131
+ if (hitresult.getType() != HitResult.Type.MISS && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) {
3232
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
33+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
34+
+ this.onHit(hitresult);
35+
+ }
3336
}
3437
}
3538

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
--- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java
22
+++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java
3-
@@ -58,8 +_,8 @@
3+
@@ -58,8 +_,11 @@
44
}
55
}
66

77
- if (hitresult.getType() != HitResult.Type.MISS && !flag) {
88
- this.onHit(hitresult);
99
+ if (hitresult.getType() != HitResult.Type.MISS && !flag && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, hitresult)) {
1010
+ this.preOnHit(hitresult); // CraftBukkit - projectile hit event
11+
+ if (this.ketting$preOnHitResult) { // Ketting - Fix mixin errors
12+
+ this.onHit(hitresult);
13+
+ }
1114
}
1215

1316
this.checkInsideBlocks();

0 commit comments

Comments
 (0)