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;