From b0790af3e135605b3531af2e1bf6fed73cfac874 Mon Sep 17 00:00:00 2001 From: SamB440 Date: Sat, 7 Dec 2024 19:42:47 +0000 Subject: [PATCH] Update packetevents --- build.gradle.kts | 3 ++- .../checks/impl/badpackets/BadPacketsT.java | 2 +- .../impl/velocity/ExplosionHandler.java | 1 - .../events/packets/PacketPlayerAttack.java | 2 +- .../ac/grim/grimac/player/GrimPlayer.java | 6 ++--- .../predictionengine/MovementCheckRunner.java | 6 ++--- .../predictionengine/PlayerBaseTick.java | 4 +-- .../predictionengine/UncertaintyHandler.java | 2 +- .../movementtick/MovementTicker.java | 4 +-- .../movementtick/MovementTickerHorse.java | 2 +- .../movementtick/MovementTickerPig.java | 2 +- .../movementtick/MovementTickerStrider.java | 2 +- .../predictions/PredictionEngine.java | 2 +- .../predictions/PredictionEngineElytra.java | 2 +- .../PredictionEngineRideableUtils.java | 2 +- .../utils/anticheat/update/BlockPlace.java | 2 +- .../utils/data/packetentity/PacketEntity.java | 6 ++--- .../data/packetentity/PacketEntityCamel.java | 6 ++--- .../data/packetentity/PacketEntityHorse.java | 12 ++++----- .../packetentity/PacketEntityRideable.java | 4 +-- .../data/packetentity/PacketEntitySelf.java | 26 +++++++++---------- .../grimac/utils/data/tags/SyncedTag.java | 1 - .../utils/latency/CompensatedEntities.java | 4 +-- .../grimac/utils/nmsutil/BlockProperties.java | 4 +-- .../grimac/utils/nmsutil/GetBoundingBox.java | 2 +- .../grim/grimac/utils/nmsutil/JumpPower.java | 2 +- 26 files changed, 55 insertions(+), 56 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0feb35e738..80a9791abb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -55,12 +55,13 @@ repositories { maven("https://repo.opencollab.dev/maven-releases/") // Cumulus (for Floodgate) maven("https://repo.codemc.io/repository/maven-releases/") // PacketEvents maven("https://repo.codemc.io/repository/maven-snapshots/") + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") mavenCentral() // FastUtil, Discord-Webhooks } dependencies { - implementation("com.github.retrooper:packetevents-spigot:2.6.1-SNAPSHOT") + implementation("com.github.retrooper:packetevents-spigot:2.7.0-SNAPSHOT") implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT") implementation("club.minnced:discord-webhooks:0.8.0") // Newer versions include kotlin-stdlib, which leads to incompatibility with plugins that use Kotlin implementation("it.unimi.dsi:fastutil:8.5.15") diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java index 01b8f26680..872682f2e2 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java @@ -49,7 +49,7 @@ public void onPacketReceive(final PacketReceiveEvent event) { // 27/12/2023 - Dynamic values for more than just one entity type? // 28/12/2023 - Player-only is fine // 30/12/2023 - Expansions differ in 1.9+ - final float scale = (float) packetEntity.getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) packetEntity.getAttributeValue(Attributes.SCALE); if (targetVector.y > (minVerticalDisplacement * scale) && targetVector.y < (maxVerticalDisplacement * scale) && Math.abs(targetVector.x) < (maxHorizontalDisplacement * scale) && Math.abs(targetVector.z) < (maxHorizontalDisplacement * scale)) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java index ac295d89a4..c336fe3882 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java @@ -18,7 +18,6 @@ import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes; import com.github.retrooper.packetevents.protocol.world.states.type.StateValue; import com.github.retrooper.packetevents.util.Vector3d; -import com.github.retrooper.packetevents.util.Vector3f; import com.github.retrooper.packetevents.util.Vector3i; import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerExplosion; import lombok.Getter; diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java index 254fe81196..acd22efd1a 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java @@ -77,7 +77,7 @@ public void onPacketReceive(PacketReceiveEvent event) { // 1.9+ players who have attack speed cannot slow themselves twice in one tick because their attack cooldown gets reset on swing. if (player.maxPlayerAttackSlow > 0 && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9) - && player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_ATTACK_SPEED) < 16) { // 16 is a reasonable limit + && player.compensatedEntities.getSelf().getAttributeValue(Attributes.ATTACK_SPEED) < 16) { // 16 is a reasonable limit return; } diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index 112d7adeb9..c2fcc15d91 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -246,7 +246,7 @@ public GrimPlayer(User user) { uncertaintyHandler.collidingEntities.add(0); if (getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_14)) { - final float scale = (float) compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) compensatedEntities.getSelf().getAttributeValue(Attributes.SCALE); possibleEyeHeights[2] = new double[]{0.4 * scale, 1.62 * scale, 1.27 * scale}; // Elytra, standing, sneaking (1.14) possibleEyeHeights[1] = new double[]{1.27 * scale, 1.62 * scale, 0.4 * scale}; // sneaking (1.14), standing, Elytra possibleEyeHeights[0] = new double[]{1.62 * scale, 1.27 * scale, 0.4 * scale}; // standing, sneaking (1.14), Elytra @@ -376,14 +376,14 @@ public void trackBaseTickAddition(Vector vector) { public float getMaxUpStep() { final PacketEntitySelf self = compensatedEntities.getSelf(); final PacketEntity riding = self.getRiding(); - if (riding == null) return (float) self.getAttributeValue(Attributes.GENERIC_STEP_HEIGHT); + if (riding == null) return (float) self.getAttributeValue(Attributes.STEP_HEIGHT); if (riding.isBoat()) { return 0f; } // Pigs, horses, striders, and other vehicles all have 1 stepping height by default - return (float) riding.getAttributeValue(Attributes.GENERIC_STEP_HEIGHT); + return (float) riding.getAttributeValue(Attributes.STEP_HEIGHT); } public void sendTransaction() { diff --git a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java index d7b6ddc8b3..391ca19a6d 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java +++ b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java @@ -188,7 +188,7 @@ private void check(PositionUpdate update) { SimpleCollisionBox interTruePositions = riding.getPossibleCollisionBoxes(); // We shrink the expanded bounding box to what the packet positions can be, for a smaller box - final float scale = (float) riding.getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) riding.getAttributeValue(Attributes.SCALE); float width = BoundingBoxSize.getWidth(player, riding) * scale; float height = BoundingBoxSize.getHeight(player, riding) * scale; interTruePositions.expand(-width, 0, -width); @@ -236,7 +236,7 @@ private void check(PositionUpdate update) { if (player.isInBed) return; if (!player.compensatedEntities.getSelf().inVehicle()) { - player.speed = player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_MOVEMENT_SPEED); + player.speed = player.compensatedEntities.getSelf().getAttributeValue(Attributes.MOVEMENT_SPEED); if (player.hasGravity != player.playerEntityHasGravity) { player.pointThreeEstimator.updatePlayerGravity(); } @@ -441,7 +441,7 @@ private void check(PositionUpdate update) { } else if (riding == null) { wasChecked = true; - player.depthStriderLevel = (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_WATER_MOVEMENT_EFFICIENCY); + player.depthStriderLevel = (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); player.sneakingSpeedMultiplier = (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.PLAYER_SNEAKING_SPEED); // This is wrong and the engine was not designed around stuff like this diff --git a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java index 0dcc9228ab..edb9a2837c 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java @@ -31,7 +31,7 @@ public static boolean canEnterPose(GrimPlayer player, Pose pose, double x, doubl } protected static SimpleCollisionBox getBoundingBoxForPose(GrimPlayer player, Pose pose, double x, double y, double z) { - final float scale = (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.SCALE); final float width = pose.width * scale; final float height = pose.height * scale; float radius = width / 2.0F; @@ -147,7 +147,7 @@ public void updatePowderSnow() { // Pre-1.17 clients don't have powder snow and therefore don't desync if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_16_4)) return; - final ValuedAttribute playerSpeed = player.compensatedEntities.getSelf().getAttribute(Attributes.GENERIC_MOVEMENT_SPEED).get(); + final ValuedAttribute playerSpeed = player.compensatedEntities.getSelf().getAttribute(Attributes.MOVEMENT_SPEED).get(); // Might be null after respawn? final Optional property = playerSpeed.property(); diff --git a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java index beae8f7b92..66e8c0acf9 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java +++ b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java @@ -141,7 +141,7 @@ public void tickFireworksBox() { if (entity == null) continue; SimpleCollisionBox entityBox = entity.getPossibleCollisionBoxes(); - final float scale = (float) entity.getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) entity.getAttributeValue(Attributes.SCALE); float width = BoundingBoxSize.getWidth(player, entity) * scale; float height = BoundingBoxSize.getHeight(player, entity) * scale; diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java index 1020f8c699..c1962c30c5 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java @@ -335,8 +335,8 @@ public void doNormalMove(float blockFriction) { public void livingEntityTravel() { double playerGravity = player.compensatedEntities.getSelf().getRiding() == null - ? player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_GRAVITY) - : player.compensatedEntities.getSelf().getRiding().getAttributeValue(Attributes.GENERIC_GRAVITY); + ? player.compensatedEntities.getSelf().getAttributeValue(Attributes.GRAVITY) + : player.compensatedEntities.getSelf().getRiding().getAttributeValue(Attributes.GRAVITY); boolean isFalling = player.actualMovement.getY() <= 0.0; if (isFalling && player.compensatedEntities.getSlowFallingAmplifier().isPresent()) { diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java index b959c5e25d..c3dbf4990e 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java @@ -16,7 +16,7 @@ public MovementTickerHorse(GrimPlayer player) { if (!horsePacket.hasSaddle) return; - player.speed = horsePacket.getAttributeValue(Attributes.GENERIC_MOVEMENT_SPEED); + player.speed = horsePacket.getAttributeValue(Attributes.MOVEMENT_SPEED); // Setup player inputs float horizInput = player.vehicleData.vehicleHorizontal * 0.5F; diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java index 080b674ed3..102931cbb8 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java @@ -14,6 +14,6 @@ public MovementTickerPig(GrimPlayer player) { @Override public float getSteeringSpeed() { // Vanilla multiples by 0.225f PacketEntityRideable pig = (PacketEntityRideable) player.compensatedEntities.getSelf().getRiding(); - return (float) pig.getAttributeValue(Attributes.GENERIC_MOVEMENT_SPEED) * 0.225f; + return (float) pig.getAttributeValue(Attributes.MOVEMENT_SPEED) * 0.225f; } } diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java index a2f2b4a3f6..2db8e19320 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java @@ -61,7 +61,7 @@ public float getSteeringSpeed() { // Client desyncs the attribute // Again I don't know when this was changed, or whether it always existed, so I will just put it behind 1.20+ - final ValuedAttribute movementSpeedAttr = strider.getAttribute(Attributes.GENERIC_MOVEMENT_SPEED).get(); + final ValuedAttribute movementSpeedAttr = strider.getAttribute(Attributes.MOVEMENT_SPEED).get(); float updatedMovementSpeed = (float) movementSpeedAttr.get(); if (newSpeed) { final WrapperPlayServerUpdateAttributes.Property lastProperty = movementSpeedAttr.property().orElse(null); diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java index 1d72f07a07..97b23246bd 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java @@ -551,7 +551,7 @@ public Vector handleStartingVelocityUncertainty(GrimPlayer player, VectorData ve // We can't simulate the player's Y velocity, unknown number of ticks with a gravity change // Feel free to simulate all 104857600000000000000000000 possibilities! if (!player.pointThreeEstimator.canPredictNextVerticalMovement()) { - minVector.setY(minVector.getY() - player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_GRAVITY)); + minVector.setY(minVector.getY() - player.compensatedEntities.getSelf().getAttributeValue(Attributes.GRAVITY)); } // Hidden slime block bounces by missing idle tick and 0.03 diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java index 54932d1255..be536e2437 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java @@ -45,7 +45,7 @@ public static Vector getElytraMovement(GrimPlayer player, Vector vector, Vector // So we actually use the player's actual movement to get the gravity/slow falling status // However, this is wrong with elytra movement because players can control vertical movement after gravity is calculated // Yeah, slow falling needs a refactor in grim. - double recalculatedGravity = player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_GRAVITY); + double recalculatedGravity = player.compensatedEntities.getSelf().getAttributeValue(Attributes.GRAVITY); if (player.clientVelocity.getY() <= 0 && player.compensatedEntities.getSlowFallingAmplifier().isPresent()) { recalculatedGravity = player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) ? 0.01 : Math.min(recalculatedGravity, 0.01); } diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java index c94a699890..02b8bfc486 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java @@ -32,7 +32,7 @@ public static Set handleJumps(GrimPlayer player, Set pos // // There's a float/double error causing 1e-8 imprecision if anyone wants to debug it if (player.vehicleData.horseJump > 0.0F && !player.vehicleData.horseJumping && player.lastOnGround) { - double d0 = horse.getAttributeValue(Attributes.GENERIC_JUMP_STRENGTH) * player.vehicleData.horseJump * JumpPower.getPlayerJumpFactor(player); + double d0 = horse.getAttributeValue(Attributes.JUMP_STRENGTH) * player.vehicleData.horseJump * JumpPower.getPlayerJumpFactor(player); double d1; // This doesn't even work because vehicle jump boost has (likely) been diff --git a/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java b/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java index b4583fd783..f0c8b38262 100644 --- a/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java +++ b/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java @@ -583,7 +583,7 @@ public void set(Vector3i position, WrappedBlockState state) { for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { SimpleCollisionBox interpBox = entity.getPossibleCollisionBoxes(); - final double scale = entity.getAttributeValue(Attributes.GENERIC_SCALE); + final double scale = entity.getAttributeValue(Attributes.SCALE); double width = BoundingBoxSize.getWidth(player, entity) * scale; double height = BoundingBoxSize.getHeight(player, entity) * scale; double interpWidth = Math.max(interpBox.maxX - interpBox.minX, interpBox.maxZ - interpBox.minZ); diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java index 7f8b9df081..5f7a97e40b 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java @@ -86,11 +86,11 @@ protected void trackAttribute(ValuedAttribute valuedAttribute) { } protected void initAttributes(GrimPlayer player) { - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_SCALE, 1.0, 0.0625, 16) + trackAttribute(ValuedAttribute.ranged(Attributes.SCALE, 1.0, 0.0625, 16) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_STEP_HEIGHT, 0.6f, 0, 10) + trackAttribute(ValuedAttribute.ranged(Attributes.STEP_HEIGHT, 0.6f, 0, 10) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_GRAVITY, 0.08, -1, 1) + trackAttribute(ValuedAttribute.ranged(Attributes.GRAVITY, 0.08, -1, 1) .requiredVersion(player, ClientVersion.V_1_20_5)); } diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityCamel.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityCamel.java index 843c626cb0..6116e83387 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityCamel.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityCamel.java @@ -13,8 +13,8 @@ public class PacketEntityCamel extends PacketEntityHorse { public PacketEntityCamel(GrimPlayer player, UUID uuid, EntityType type, double x, double y, double z, float xRot) { super(player, uuid, type, x, y, z, xRot); - setAttribute(Attributes.GENERIC_JUMP_STRENGTH, 0.42f); - setAttribute(Attributes.GENERIC_MOVEMENT_SPEED, 0.09f); - setAttribute(Attributes.GENERIC_STEP_HEIGHT, 1.5f); + setAttribute(Attributes.JUMP_STRENGTH, 0.42f); + setAttribute(Attributes.MOVEMENT_SPEED, 0.09f); + setAttribute(Attributes.STEP_HEIGHT, 1.5f); } } diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHorse.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHorse.java index f16b4888b4..e41cbe2fd0 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHorse.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHorse.java @@ -19,11 +19,11 @@ public class PacketEntityHorse extends PacketEntityTrackXRot { public PacketEntityHorse(GrimPlayer player, UUID uuid, EntityType type, double x, double y, double z, float xRot) { super(player, uuid, type, x, y, z, xRot); - setAttribute(Attributes.GENERIC_STEP_HEIGHT, 1.0f); + setAttribute(Attributes.STEP_HEIGHT, 1.0f); final boolean preAttribute = player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5); // This was horse.jump_strength pre-attribute - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_JUMP_STRENGTH, 0.7, 0, preAttribute ? 2 : 32) + trackAttribute(ValuedAttribute.ranged(Attributes.JUMP_STRENGTH, 0.7, 0, preAttribute ? 2 : 32) .withSetRewriter((oldValue, newValue) -> { // Seems viabackwards doesn't rewrite this (?) if (preAttribute && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_20_5)) { @@ -32,15 +32,15 @@ public PacketEntityHorse(GrimPlayer player, UUID uuid, EntityType type, double x // Modern player OR an old server setting legacy horse.jump_strength attribute return newValue; })); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_MOVEMENT_SPEED, 0.225f, 0, 1024)); + trackAttribute(ValuedAttribute.ranged(Attributes.MOVEMENT_SPEED, 0.225f, 0, 1024)); if (EntityTypes.isTypeInstanceOf(type, EntityTypes.CHESTED_HORSE)) { - setAttribute(Attributes.GENERIC_JUMP_STRENGTH, 0.5); - setAttribute(Attributes.GENERIC_MOVEMENT_SPEED, 0.175f); + setAttribute(Attributes.JUMP_STRENGTH, 0.5); + setAttribute(Attributes.MOVEMENT_SPEED, 0.175f); } if (type == EntityTypes.ZOMBIE_HORSE || type == EntityTypes.SKELETON_HORSE) { - setAttribute(Attributes.GENERIC_MOVEMENT_SPEED, 0.2f); + setAttribute(Attributes.MOVEMENT_SPEED, 0.2f); } } } diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityRideable.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityRideable.java index 8ea1636f32..bd292571f8 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityRideable.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityRideable.java @@ -15,7 +15,7 @@ public class PacketEntityRideable extends PacketEntity { public PacketEntityRideable(GrimPlayer player, UUID uuid, EntityType type, double x, double y, double z) { super(player, uuid, type, x, y, z); - setAttribute(Attributes.GENERIC_STEP_HEIGHT, 1.0f); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_MOVEMENT_SPEED, 0.1f, 0, 1024)); + setAttribute(Attributes.STEP_HEIGHT, 1.0f); + trackAttribute(ValuedAttribute.ranged(Attributes.MOVEMENT_SPEED, 0.1f, 0, 1024)); } } 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 401ffd3b5c..8ce32d0e45 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 @@ -44,10 +44,10 @@ public PacketEntitySelf(GrimPlayer player, PacketEntitySelf old) { protected void initAttributes(GrimPlayer player) { super.initAttributes(player); if (player.getClientVersion().isOlderThan(ClientVersion.V_1_8)) { - setAttribute(Attributes.GENERIC_STEP_HEIGHT, 0.5f); + setAttribute(Attributes.STEP_HEIGHT, 0.5f); } - getAttribute(Attributes.GENERIC_SCALE).get().withSetRewriter((oldValue, newValue) -> { + getAttribute(Attributes.SCALE).get().withSetRewriter((oldValue, newValue) -> { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_20_5) || (newValue).equals(oldValue)) { return oldValue; } else { @@ -69,22 +69,22 @@ protected void initAttributes(GrimPlayer player) { } }); - final ValuedAttribute movementSpeed = ValuedAttribute.ranged(Attributes.GENERIC_MOVEMENT_SPEED, 0.1f, 0, 1024); + final ValuedAttribute movementSpeed = ValuedAttribute.ranged(Attributes.MOVEMENT_SPEED, 0.1f, 0, 1024); movementSpeed.with(new WrapperPlayServerUpdateAttributes.Property("MOVEMENT_SPEED", 0.1f, new ArrayList<>())); trackAttribute(movementSpeed); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_ATTACK_SPEED, 4, 0, 1024) + trackAttribute(ValuedAttribute.ranged(Attributes.ATTACK_SPEED, 4, 0, 1024) .requiredVersion(player, ClientVersion.V_1_9)); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_JUMP_STRENGTH, 0.42f, 0, 32) + trackAttribute(ValuedAttribute.ranged(Attributes.JUMP_STRENGTH, 0.42f, 0, 32) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_BLOCK_BREAK_SPEED, 1.0, 0, 1024) + trackAttribute(ValuedAttribute.ranged(Attributes.BLOCK_BREAK_SPEED, 1.0, 0, 1024) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_MINING_EFFICIENCY, 0, 0, 1024) + trackAttribute(ValuedAttribute.ranged(Attributes.MINING_EFFICIENCY, 0, 0, 1024) .requiredVersion(player, ClientVersion.V_1_21)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_SUBMERGED_MINING_SPEED, 0.2, 0, 20) + trackAttribute(ValuedAttribute.ranged(Attributes.SUBMERGED_MINING_SPEED, 0.2, 0, 20) .requiredVersion(player, ClientVersion.V_1_21)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_ENTITY_INTERACTION_RANGE, 3, 0, 64) + trackAttribute(ValuedAttribute.ranged(Attributes.ENTITY_INTERACTION_RANGE, 3, 0, 64) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_BLOCK_INTERACTION_RANGE, 4.5, 0, 64) + trackAttribute(ValuedAttribute.ranged(Attributes.BLOCK_INTERACTION_RANGE, 4.5, 0, 64) .withGetRewriter(value -> { // Server versions older than 1.20.5 don't send the attribute, if the player is in creative then assume legacy max reach distance. if (player.gamemode == GameMode.CREATIVE @@ -95,7 +95,7 @@ protected void initAttributes(GrimPlayer player) { return value; }) .requiredVersion(player, ClientVersion.V_1_20_5)); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_WATER_MOVEMENT_EFFICIENCY, 0, 0, 1) + trackAttribute(ValuedAttribute.ranged(Attributes.WATER_MOVEMENT_EFFICIENCY, 0, 0, 1) .withGetRewriter(value -> { // Depth strider was added in 1.8 if (player.getClientVersion().isOlderThan(ClientVersion.V_1_8)) { @@ -118,9 +118,9 @@ protected void initAttributes(GrimPlayer player) { return value; }) .requiredVersion(player, ClientVersion.V_1_21)); - trackAttribute(ValuedAttribute.ranged(Attributes.GENERIC_MOVEMENT_EFFICIENCY, 0, 0, 1) + trackAttribute(ValuedAttribute.ranged(Attributes.MOVEMENT_EFFICIENCY, 0, 0, 1) .requiredVersion(player, ClientVersion.V_1_21)); - trackAttribute(ValuedAttribute.ranged(Attributes.PLAYER_SNEAKING_SPEED, 0.3, 0, 1) + trackAttribute(ValuedAttribute.ranged(Attributes.SNEAKING_SPEED, 0.3, 0, 1) .withGetRewriter(value -> { if (player.getClientVersion().isOlderThan(ClientVersion.V_1_19)) { return (double) 0.3f; diff --git a/src/main/java/ac/grim/grimac/utils/data/tags/SyncedTag.java b/src/main/java/ac/grim/grimac/utils/data/tags/SyncedTag.java index 47bae92d4c..d277f03d3f 100644 --- a/src/main/java/ac/grim/grimac/utils/data/tags/SyncedTag.java +++ b/src/main/java/ac/grim/grimac/utils/data/tags/SyncedTag.java @@ -4,7 +4,6 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerTags; import java.util.Collections; -import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Set; import java.util.function.Function; diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java index fd06ffe719..0606f632d8 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java @@ -105,7 +105,7 @@ public void updateAttributes(int entityID, List modifiers = snapshotWrapper.getModifiers(); @@ -132,7 +132,7 @@ public void updateAttributes(int entityID, List modern equivalent if (attribute == Attributes.HORSE_JUMP_STRENGTH) { - attribute = Attributes.GENERIC_JUMP_STRENGTH; + attribute = Attributes.JUMP_STRENGTH; } final Optional valuedAttribute = entity.getAttribute(attribute); diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java index 107ddc7b31..16917fdec1 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java @@ -36,7 +36,7 @@ public static float getFrictionInfluencedSpeed(float f, GrimPlayer player) { } // Vanilla multiplies by 0.1 to calculate speed - return (float) strider.getAttributeValue(Attributes.GENERIC_MOVEMENT_SPEED) * (strider.isShaking ? 0.66F : 1.0F) * 0.1f; + return (float) strider.getAttributeValue(Attributes.MOVEMENT_SPEED) * (strider.isShaking ? 0.66F : 1.0F) * 0.1f; } } @@ -205,6 +205,6 @@ private static float getBlockSpeedFactor(GrimPlayer player, StateType type) { private static float getModernVelocityMultiplier(GrimPlayer player, float blockSpeedFactor) { if (player.getClientVersion().isOlderThan(ClientVersion.V_1_21)) return blockSpeedFactor; - return (float) GrimMath.lerp((float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_MOVEMENT_EFFICIENCY), blockSpeedFactor, 1.0F); + return (float) GrimMath.lerp((float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.MOVEMENT_EFFICIENCY), blockSpeedFactor, 1.0F); } } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java b/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java index 845ca231a7..aa55801502 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java @@ -35,7 +35,7 @@ public static SimpleCollisionBox getBoundingBoxFromPosAndSize(GrimPlayer player, } public static SimpleCollisionBox getBoundingBoxFromPosAndSize(PacketEntity entity, double centerX, double minY, double centerZ, float width, float height) { - final float scale = (float) entity.getAttributeValue(Attributes.GENERIC_SCALE); + final float scale = (float) entity.getAttributeValue(Attributes.SCALE); return getBoundingBoxFromPosAndSizeRaw(centerX, minY, centerZ, width * scale, height * scale); } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java b/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java index 003124bdd2..42a43f86f3 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java @@ -29,7 +29,7 @@ public static void jumpFromGround(GrimPlayer player, Vector vector) { } public static float getJumpPower(GrimPlayer player) { - return (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.GENERIC_JUMP_STRENGTH) * getPlayerJumpFactor(player); + return (float) player.compensatedEntities.getSelf().getAttributeValue(Attributes.JUMP_STRENGTH) * getPlayerJumpFactor(player); } public static float getPlayerJumpFactor(GrimPlayer player) {