1- From b89daad06bf8ec8773b2fd4a9ec0c26e51858c23 Mon Sep 17 00:00:00 2001
1+ From 3ca21945c5261cd73374a049b511cdd32211ddd5 Mon Sep 17 00:00:00 2001
22From: RoccoDev <
[email protected] >
33Date: Tue, 4 Oct 2022 21:58:58 +0200
44Subject: [PATCH] Extend hit recalculation to intangible entities
55
66
77diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
8- index 1aa0d226..b6c35462 100644
8+ index 1aa0d226c..ae2307612 100644
99--- a/src/main/java/net/minecraft/server/PlayerConnection.java
1010+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
1111@@ -1,5 +1,6 @@
@@ -15,15 +15,15 @@ index 1aa0d226..b6c35462 100644
1515 import com.google.common.collect.Lists;
1616 import com.google.common.primitives.Doubles;
1717 import com.google.common.primitives.Floats;
18- @@ -1344,39 +1345,36 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
18+ @@ -1344,39 +1345,39 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
1919
2020 this.player.resetIdleTimer();
2121 if (entity != null) {
2222- // KigPaper start - allow hitting the vehicle when hitboxes collide / allow the player to hit others if they are being ridden by something
23- + // KigPaper start - recalculate hit when hitboxes collide
2423- if(PaperSpigotConfig.betterVehicleHitboxes) {
25- + if (PaperSpigotConfig.betterVehicleHitboxes && packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
2624- if (entity instanceof EntityPlayer && entity.vehicle != null && !((EntityPlayer) entity).collidesWithEntities) {
25+ + // KigPaper start - recalculate hit when hitboxes collide
26+ + if (PaperSpigotConfig.betterVehicleHitboxes && packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
2727+ Predicate<? super Entity> recalcHitPredicate = null;
2828+ if (entity == player.passenger) {
2929+ // Player hit own passenger. This shouldn't be possible, so it's likely that the hit was meant
@@ -65,6 +65,9 @@ index 1aa0d226..b6c35462 100644
6565+ player.locZ);
6666 Vec3D maxDistLook = eyePos.add(look.a * maxDist, look.b * maxDist, look.c * maxDist);
6767- Entity passenger = entity.passenger;
68+ + Predicate<? super Entity> finalRecalcHitPredicate = recalcHitPredicate;
69+ + recalcHitPredicate = e -> finalRecalcHitPredicate.apply(e) && !(e instanceof EntityItem)
70+ + && !(e instanceof EntityExperienceOrb) && !(e instanceof EntityArrow) && e != player;
6871 List<Entity> collisions = worldserver.a(player, player.getBoundingBox()
6972 .a(look.a * maxDist, look.b * maxDist, look.c * maxDist) // add coords
7073- .grow(1D, 1D, 1D), e -> e != passenger); // Don't include passenger
@@ -77,5 +80,5 @@ index 1aa0d226..b6c35462 100644
7780 entity = match;
7881 break;
7982- -
80- 2.37.2
83+ 2.51.0
8184
0 commit comments