Skip to content

Commit

Permalink
Fix FarPlace and RotationPlace creative falses
Browse files Browse the repository at this point in the history
  • Loading branch information
SamB440 committed May 28, 2024
1 parent 8a1cc2e commit d19245f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit d19245f

Please sign in to comment.