Skip to content

Commit

Permalink
Fix more player movement issues
Browse files Browse the repository at this point in the history
Player movement around 0,0 previously had issues, also patch a potential
workaround for clipping hacks.
  • Loading branch information
Samsuik committed Aug 22, 2023
1 parent fe13ae6 commit 967b891
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 15 deletions.
107 changes: 106 additions & 1 deletion patches/server/0004-mc-dev-imports.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 8bbccedebae503573dad32e95cd49387e701b253 Mon Sep 17 00:00:00 2001
From 5d2f6f81f40dce545972f17f804a51cf6eee7199 Mon Sep 17 00:00:00 2001
From: Samsuik <[email protected]>
Date: Tue, 9 May 2023 16:10:11 +0100
Subject: [PATCH] mc dev imports
Expand Down Expand Up @@ -1560,6 +1560,111 @@ index 000000000..d7508df9d
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockLogAbstract.java b/src/main/java/net/minecraft/server/BlockLogAbstract.java
new file mode 100644
index 000000000..cfeaec6dd
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockLogAbstract.java
@@ -0,0 +1,99 @@
+package net.minecraft.server;
+
+import java.util.Iterator;
+
+public abstract class BlockLogAbstract extends BlockRotatable {
+
+ public static final BlockStateEnum<BlockLogAbstract.EnumLogRotation> AXIS = BlockStateEnum.of("axis", BlockLogAbstract.EnumLogRotation.class);
+
+ public BlockLogAbstract() {
+ super(Material.WOOD);
+ this.a(CreativeModeTab.b);
+ this.c(2.0F);
+ this.a(BlockLogAbstract.f);
+ }
+
+ public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ byte b0 = 4;
+ int i = b0 + 1;
+
+ if (world.areChunksLoadedBetween(blockposition.a(-i, -i, -i), blockposition.a(i, i, i))) {
+ Iterator iterator = BlockPosition.a(blockposition.a(-b0, -b0, -b0), blockposition.a(b0, b0, b0)).iterator();
+
+ while (iterator.hasNext()) {
+ BlockPosition blockposition1 = (BlockPosition) iterator.next();
+ IBlockData iblockdata1 = world.getType(blockposition1);
+
+ if (iblockdata1.getBlock().getMaterial() == Material.LEAVES && !((Boolean) iblockdata1.get(BlockLeaves.CHECK_DECAY)).booleanValue()) {
+ world.setTypeAndData(blockposition1, iblockdata1.set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
+ }
+ }
+
+ }
+ }
+
+ public IBlockData getPlacedState(World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) {
+ return super.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityliving).set(BlockLogAbstract.AXIS, BlockLogAbstract.EnumLogRotation.a(enumdirection.k()));
+ }
+
+ static class SyntheticClass_1 {
+
+ static final int[] a = new int[EnumDirection.EnumAxis.values().length];
+
+ static {
+ try {
+ BlockLogAbstract.SyntheticClass_1.a[EnumDirection.EnumAxis.X.ordinal()] = 1;
+ } catch (NoSuchFieldError nosuchfielderror) {
+ ;
+ }
+
+ try {
+ BlockLogAbstract.SyntheticClass_1.a[EnumDirection.EnumAxis.Y.ordinal()] = 2;
+ } catch (NoSuchFieldError nosuchfielderror1) {
+ ;
+ }
+
+ try {
+ BlockLogAbstract.SyntheticClass_1.a[EnumDirection.EnumAxis.Z.ordinal()] = 3;
+ } catch (NoSuchFieldError nosuchfielderror2) {
+ ;
+ }
+
+ }
+ }
+
+ public static enum EnumLogRotation implements INamable {
+
+ X("x"), Y("y"), Z("z"), NONE("none");
+
+ private final String e;
+
+ private EnumLogRotation(String s) {
+ this.e = s;
+ }
+
+ public String toString() {
+ return this.e;
+ }
+
+ public static BlockLogAbstract.EnumLogRotation a(EnumDirection.EnumAxis enumdirection_enumaxis) {
+ switch (BlockLogAbstract.SyntheticClass_1.a[enumdirection_enumaxis.ordinal()]) {
+ case 1:
+ return BlockLogAbstract.EnumLogRotation.X;
+
+ case 2:
+ return BlockLogAbstract.EnumLogRotation.Y;
+
+ case 3:
+ return BlockLogAbstract.EnumLogRotation.Z;
+
+ default:
+ return BlockLogAbstract.EnumLogRotation.NONE;
+ }
+ }
+
+ public String getName() {
+ return this.e;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java
new file mode 100644
index 000000000..922893aed
Expand Down
25 changes: 20 additions & 5 deletions patches/server/0107-Fix-player-movement-issues.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3f76920bbf1fba0a7872f04f89b1f790806c7fd4 Mon Sep 17 00:00:00 2001
From a29e543f3e78a2f6d7cc7ffb12e61ed219e41b15 Mon Sep 17 00:00:00 2001
From: Samsuik <[email protected]>
Date: Tue, 18 Jul 2023 15:54:26 +0100
Subject: [PATCH] Fix player movement issues
Expand Down Expand Up @@ -32,7 +32,7 @@ index 1ec034d5b..b968a1913 100644
+
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 1de413e0b..5d11191b6 100644
index 354ff7252..87b967807 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -637,7 +637,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
Expand All @@ -44,7 +44,7 @@ index 1de413e0b..5d11191b6 100644
PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d11 + ", " + d12 + ", " + d13 + ")");
this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
return;
@@ -650,22 +650,27 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -650,32 +650,50 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.player.bF();
}

Expand All @@ -67,7 +67,7 @@ index 1de413e0b..5d11191b6 100644

+ // Blossom start
+ double desync = d15 + d12 * d12;
+ if (me.samsuik.blossom.configuration.BlossomConfig.disallowSuspiciousMovements && desync != 0.0) {
+ if (me.samsuik.blossom.configuration.BlossomConfig.disallowSuspiciousMovements && this.player.positionChanged && desync != 0.0) {
+ flag1 = true;
+ }
+ // Blossom end
Expand All @@ -78,7 +78,22 @@ index 1de413e0b..5d11191b6 100644
flag1 = true;
PlayerConnection.c.warn(this.player.getName() + " moved wrongly!");
}
@@ -675,7 +680,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList

+ // Blossom start
+ // Any floating point errors could allow a client to clip inside blocks,
+ // which would mean all the fixes implemented for clipping hacks would go to waste.
+ //
+ // The reason this line of code exists is to keep the server position in sync
+ // with the client, even if there is a difference between servers approximation
+ // of the client's movement and what the client provided in this packet.
+ //
+ // If you need accurate server-side player positions, for example a plugin that tries
+ // to verify player movement, disallowSuspiciousMovements should be disabled.
+ if (!me.samsuik.blossom.configuration.BlossomConfig.disallowSuspiciousMovements) {
this.player.setLocation(d7, d8, d9, f2, f3);
+ }
+ // Blossom end
this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
if (!this.player.noclip) {
boolean flag2 = worldserver.getCubes(this.player, this.player.getBoundingBox().shrink((double) f4, (double) f4, (double) f4)).isEmpty();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 86a314826d78a87afcbff6470236e6e00e69103b Mon Sep 17 00:00:00 2001
From ec948b35d3abc36b6db9afe292af5ca1ce58b82a Mon Sep 17 00:00:00 2001
From: Samsuik <[email protected]>
Date: Tue, 18 Jul 2023 23:32:01 +0100
Subject: [PATCH] Actual Throttle Placement Configuration
Expand All @@ -20,10 +20,10 @@ index be4eb2f5e..3b10b7cc0 100644
+
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 5d11191b6..a7eea8175 100644
index 87b967807..d5c94d4d2 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -949,6 +949,11 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -962,6 +962,11 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.lastInteractedSlot = this.player.inventory.itemInHandIndex;
}
// Blossom end
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0117-Sanitize-BlockEntityTag.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From bc04e2b44d2b7a77784652b2aa744a9af9c2d998 Mon Sep 17 00:00:00 2001
From 66acc46198604390ae8420dab84990d6cf522900 Mon Sep 17 00:00:00 2001
From: Samsuik <[email protected]>
Date: Thu, 20 Jul 2023 20:58:17 +0100
Subject: [PATCH] Sanitize BlockEntityTag


diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a7eea8175..ce6128e3b 100644
index d5c94d4d2..c100ec87a 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2077,9 +2077,24 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -2090,9 +2090,24 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList

if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z")) {
BlockPosition blockposition = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0119-Command-Restrictions.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 64b85d2cd94c68ffe5fa08262f314d201c761ac0 Mon Sep 17 00:00:00 2001
From 997b56ab8d2f53823760eb960cbca62c7196adff Mon Sep 17 00:00:00 2001
From: Samsuik <[email protected]>
Date: Thu, 27 Jul 2023 20:03:36 +0100
Subject: [PATCH] Command Restrictions
Expand Down Expand Up @@ -155,7 +155,7 @@ index 000000000..bcf95ff21
+
+}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 24802c81d..cee2b5e11 100644
index c100ec87a..3816c8027 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -122,6 +122,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
Expand All @@ -166,7 +166,7 @@ index 24802c81d..cee2b5e11 100644

public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
@@ -1466,6 +1467,19 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
@@ -1479,6 +1480,19 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit start - whole method
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
this.c.info(this.player.getName() + " issued server command: " + s);
Expand Down

0 comments on commit 967b891

Please sign in to comment.