Skip to content

Commit 1ea0238

Browse files
committed
patch: fix recalculated hits attacking invalid entities
Fixes players being kicked for 'attacking an invalid entity'
1 parent 0abbeb6 commit 1ea0238

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

Spigot-Server-Patches/0235-Extend-hit-recalculation-to-intangible-entities.patch

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
From b89daad06bf8ec8773b2fd4a9ec0c26e51858c23 Mon Sep 17 00:00:00 2001
1+
From 3ca21945c5261cd73374a049b511cdd32211ddd5 Mon Sep 17 00:00:00 2001
22
From: RoccoDev <[email protected]>
33
Date: Tue, 4 Oct 2022 21:58:58 +0200
44
Subject: [PATCH] Extend hit recalculation to intangible entities
55

66

77
diff --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

Spigot-Server-Patches/0243-Disable-kick-for-tab-complete-packet-spam.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
From 9219bd632cfcff6d269a083a00bb20c3f7838c1e Mon Sep 17 00:00:00 2001
1+
From 21577a5f6e98991a9925549a2a8084a3efaaedca Mon Sep 17 00:00:00 2001
22
From: RoccoDev <[email protected]>
33
Date: Sun, 14 Jul 2024 23:18:21 +0200
44
Subject: [PATCH] Disable kick for tab complete packet spam
55

66
Newer versions send tab complete packets while typing the command/arguments. This also separates the chat/command and tab-complete spam counters so that they don't affect each other.
77

88
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
9-
index b6c35462b..2a045195f 100644
9+
index ae2307612..faee58d45 100644
1010
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
1111
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
1212
@@ -83,7 +83,11 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -31,7 +31,7 @@ index b6c35462b..2a045195f 100644
3131
/* Use thread-safe field access instead
3232
if (this.chatThrottle > 0) {
3333
--this.chatThrottle;
34-
@@ -2019,8 +2026,16 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
34+
@@ -2022,8 +2029,16 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
3535
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
3636
PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.u());
3737
// CraftBukkit start
@@ -74,5 +74,5 @@ index 26b936404..5fa3aa5b5 100644
7474
// KigPaper end
7575
}
7676
--
77-
2.45.2
77+
2.51.0
7878

0 commit comments

Comments
 (0)