Skip to content

Commit

Permalink
Check via config for prevent-collision
Browse files Browse the repository at this point in the history
  • Loading branch information
SamB440 committed Aug 10, 2024
1 parent f495125 commit 04bcf96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ public void onPacketSend(PacketSendEvent event) {
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedEntities.updateEntityMetadata(entityMetadata.getEntityId(), entityMetadata.getEntityMetadata()));
}

// Updating
// todo: legacy support
// 1.19.3+
if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_UPDATE) {
WrapperPlayServerPlayerInfoUpdate info = new WrapperPlayServerPlayerInfoUpdate(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.util.Vector3d;
import com.viaversion.viaversion.api.Via;
import io.github.retrooper.packetevents.util.viaversion.ViaVersionUtil;
import org.bukkit.util.Vector;

public class MovementTicker {
Expand All @@ -32,8 +34,9 @@ public MovementTicker(GrimPlayer player) {
public static void handleEntityCollisions(GrimPlayer player) {
// 1.7 and 1.8 do not have player collision
if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)
// Assume that ViaVersion disables all collisions on a 1.8 server for 1.9+ clients
|| PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_9)) return;
// Check that ViaVersion disables all collisions on a 1.8 server for 1.9+ clients
|| (PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_9)
&& (!ViaVersionUtil.isAvailable() || Via.getConfig().isPreventCollision()))) return;

int possibleCollidingEntities = 0;

Expand All @@ -50,7 +53,9 @@ public static void handleEntityCollisions(GrimPlayer player) {
if (!entity.isPushable())
continue;

if (!EntityPredicates.canBePushedBy(player, entity, teamHandler).test(player)) continue;
// 1.9+ player on 1.8- server with ViaVersion prevent-collision disabled.
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThan(ServerVersion.V_1_8)
&& !EntityPredicates.canBePushedBy(player, entity, teamHandler).test(player)) continue;

SimpleCollisionBox entityBox = entity.getPossibleCollisionBoxes();

Expand Down

0 comments on commit 04bcf96

Please sign in to comment.