From d19245f6ad0f3831d1fb56150a7c48a06875b98f Mon Sep 17 00:00:00 2001 From: SamB440 Date: Tue, 28 May 2024 13:10:56 +0100 Subject: [PATCH] Fix FarPlace and RotationPlace creative falses --- .../grimac/checks/impl/scaffolding/FarPlace.java | 4 +--- .../utils/data/packetentity/PacketEntitySelf.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java index e25a8c80b9..8c802a35b7 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java +++ b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java @@ -34,9 +34,7 @@ public void onBlockPlace(final BlockPlace place) { // getPickRange() determines this? // With 1.20.5+ the new attribute determines creative mode reach using a modifier - double maxReach = player.gamemode == GameMode.CREATIVE && !player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_20_5) - ? 6.0 - : player.compensatedEntities.getSelf().getBlockInteractRange(); + double maxReach = player.compensatedEntities.getSelf().getBlockInteractRange(); double threshold = player.getMovementThreshold(); maxReach += Math.hypot(threshold, threshold); diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySelf.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySelf.java index 0405c10c7b..67096816d8 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySelf.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySelf.java @@ -2,7 +2,11 @@ import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; +import com.github.retrooper.packetevents.PacketEvents; +import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; +import com.github.retrooper.packetevents.protocol.player.ClientVersion; +import com.github.retrooper.packetevents.protocol.player.GameMode; import com.github.retrooper.packetevents.protocol.potion.PotionType; import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes; import lombok.Getter; @@ -24,6 +28,17 @@ public class PacketEntitySelf extends PacketEntity { @Setter double breakSpeedMultiplier = 1.0, entityInteractRange = 3, blockInteractRange = 4.5; + public double getBlockInteractRange() { + // Server versions older than 1.20.5 don't send the attribute, if the player is in creative then assume legacy max reach distance. + // Or if they are on a client version older than 1.20.5. + if (player.gamemode == GameMode.CREATIVE + && (player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) + || PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_20_5))) { + return 5.0; + } + return blockInteractRange; + } + public PacketEntitySelf(GrimPlayer player) { super(EntityTypes.PLAYER); this.player = player;