Continue sorting

This commit is contained in:
FlorianMichael 2025-01-02 15:22:37 +01:00
parent ef763be5f0
commit f87774a62b
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
14 changed files with 273 additions and 93 deletions

View File

@ -0,0 +1,49 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2025 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.interaction;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity {
@Shadow
@Final
private PlayerAbilities abilities;
@Inject(method = "canConsume", at = @At("HEAD"), cancellable = true)
private void preventEatingFoodInCreative(boolean ignoreHunger, CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) && this.abilities.invulnerable) {
cir.setReturnValue(false);
}
}
}

View File

@ -57,15 +57,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
super(world, profile);
}
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
private double changeMagnitude(double n) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
return 9.0E-4D;
} else {
return MathHelper.square(n);
}
}
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
private int moveLastPosPacketIncrement(ClientPlayerEntity instance) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.remove_bed_bounce;
package com.viaversion.viafabricplus.injection.mixin.features.movement.collision;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;

View File

@ -45,6 +45,7 @@ public abstract class MixinEntity {
@Shadow
private Vec3d pos;
@Shadow
private World world;

View File

@ -0,0 +1,44 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2025 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.constants;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = ClientPlayerEntity.class, priority = 2000)
public abstract class MixinClientPlayerEntity {
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
private double changeMagnitude(double n) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
return 9.0E-4D;
} else {
return MathHelper.square(n);
}
}
}

View File

@ -47,18 +47,12 @@ import java.util.Optional;
@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends Entity {
@Shadow
protected boolean jumping;
@Shadow
private Optional<BlockPos> climbingPos;
@Shadow
protected abstract boolean canEnterTrapdoor(BlockPos pos, BlockState state);
@Shadow
private int jumpingCooldown;
@Shadow
public abstract boolean hasStatusEffect(RegistryEntry<StatusEffect> effect);
@ -91,11 +85,6 @@ public abstract class MixinLivingEntity extends Entity {
}
}
@Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z"))
private boolean disableJumpOnLadder(LivingEntity self) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && jumping;
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;onLanding()V"))
private void dontResetLevitationFallDistance(LivingEntity instance) {
if (this.hasStatusEffect(StatusEffects.SLOW_FALLING) || ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {
@ -117,13 +106,6 @@ public abstract class MixinLivingEntity extends Entity {
}
}
@Inject(method = "tickMovement", at = @At("HEAD"))
private void removeJumpDelay(CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
this.jumpingCooldown = 0;
}
}
@Inject(method = "isClimbing", at = @At("RETURN"), cancellable = true)
private void allowGappedLadderClimb(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.b1_5tob1_5_2) && !cir.getReturnValueZ() && !this.isSpectator()) {

View File

@ -0,0 +1,56 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2025 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.jump;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.LivingEntity;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity {
@Shadow
protected boolean jumping;
@Shadow
private int jumpingCooldown;
@Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z"))
private boolean disableJumpOnLadder(LivingEntity self) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && jumping;
}
@Inject(method = "tickMovement", at = @At("HEAD"))
private void removeJumpDelay(CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
this.jumpingCooldown = 0;
}
}
}

View File

@ -0,0 +1,47 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2025 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.limitation;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import net.minecraft.entity.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity extends LivingEntity {
protected MixinPlayerEntity(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
}
@Inject(method = "isClimbing", at = @At("HEAD"), cancellable = true)
private void allowClimbingWhileFlying(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21_2)) {
cir.setReturnValue(super.isClimbing());
}
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.slowdown_calculation;
package com.viaversion.viafabricplus.injection.mixin.features.movement.slowdown;
import com.mojang.authlib.GameProfile;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.slowdown_calculation;
package com.viaversion.viafabricplus.injection.mixin.features.movement.slowdown;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.sprinting_sneaking_condition;
package com.viaversion.viafabricplus.injection.mixin.features.movement.sprinting_and_sneaking;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.mojang.authlib.GameProfile;

View File

@ -19,42 +19,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.movement.entity;
package com.viaversion.viafabricplus.injection.mixin.features.movement.sprinting_and_sneaking;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerAbilities;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity extends LivingEntity {
@Shadow
@Final
private PlayerAbilities abilities;
@Unique
public boolean viaFabricPlus$isSprinting;
@ -62,20 +44,6 @@ public abstract class MixinPlayerEntity extends LivingEntity {
super(entityType, world);
}
@Inject(method = "isClimbing", at = @At("HEAD"), cancellable = true)
private void allowClimbingWhileFlying(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21_2)) {
cir.setReturnValue(super.isClimbing());
}
}
@Inject(method = "isLoaded", at = @At("HEAD"), cancellable = true)
private void alwaysLoadPlayer(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21_2)) {
cir.setReturnValue(true);
}
}
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setMovementSpeed(F)V"))
private void storeSprintingState(CallbackInfo ci) {
viaFabricPlus$isSprinting = this.isSprinting();
@ -90,11 +58,4 @@ public abstract class MixinPlayerEntity extends LivingEntity {
}
}
@Inject(method = "canConsume", at = @At("HEAD"), cancellable = true)
private void preventEatingFoodInCreative(boolean ignoreHunger, CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) && this.abilities.invulnerable) {
cir.setReturnValue(false);
}
}
}
}

View File

@ -0,0 +1,42 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2025 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viafabricplus.injection.mixin.features.networking.keep_player_loaded;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity {
@Inject(method = "isLoaded", at = @At("HEAD"), cancellable = true)
private void alwaysLoadPlayer(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21_2)) {
cir.setReturnValue(true);
}
}
}

View File

@ -52,6 +52,7 @@
"features.block.interaction.MixinNoteBlock",
"features.block.mining_calculation.MixinAbstractBlock",
"features.block.mining_calculation.MixinAbstractBlock_AbstractBlockState",
"features.block.mining_calculation.MixinPlayerEntity",
"features.block.shape.MixinAbstractRailBlock",
"features.block.shape.MixinAnvilBlock",
"features.block.shape.MixinBedBlock",
@ -129,6 +130,7 @@
"features.footstep_particle.MixinRegistrySyncManager",
"features.interaction.MixinAbstractClientPlayerEntity",
"features.interaction.attack_cooldown.MixinMinecraftClient",
"features.interaction.attack_cooldown.MixinPlayerEntity",
"features.interaction.container_clicking.MixinAbstractFurnaceScreenHandler",
"features.interaction.container_clicking.MixinClientPlayerInteractionManager",
"features.interaction.container_clicking.MixinCraftingScreenHandler",
@ -179,21 +181,27 @@
"features.mouse_sensitivity.MixinMouseOptionsScreen",
"features.movement.MixinClientPlayerEntity",
"features.movement.collision.MixinAbstractBoatEntity",
"features.movement.collision.MixinBedBlock",
"features.movement.collision.MixinEntity",
"features.movement.collision.MixinHoneyBlock",
"features.movement.collision.MixinSoulSandBlock",
"features.movement.constants.MixinClientPlayerEntity",
"features.movement.constants.MixinEntity",
"features.movement.constants.MixinLivingEntity",
"features.movement.constants.MixinPlayerEntity",
"features.movement.constants.MixinPlayerEntityRenderer",
"features.movement.elytra.MixinClientPlayerEntity",
"features.movement.elytra.MixinFireworkRocketItem",
"features.movement.elytra.MixinLivingEntity",
"features.movement.elytra.MixinPlayerEntity",
"features.movement.entity.MixinLivingEntity",
"features.movement.entity.MixinPlayerEntity",
"features.movement.limitation.MixinPlayerEntity",
"features.movement.jump.MixinClientPlayerEntity",
"features.movement.remove_bed_bounce.MixinBedBlock",
"features.movement.slowdown_calculation.MixinClientPlayerEntity",
"features.movement.slowdown_calculation.MixinEnderEyeItem",
"features.movement.sprinting_sneaking_condition.MixinClientPlayerEntity",
"features.movement.limitation.rotation.MixinEntity",
"features.movement.limitation.rotation.MixinPlayerEntity",
"features.movement.slowdown.MixinClientPlayerEntity",
"features.movement.slowdown.MixinEnderEyeItem",
"features.movement.sprinting_and_sneaking.MixinClientPlayerEntity",
"features.movement.vehicle.MixinClientPlayerEntity",
"features.movement.water.MixinClientPlayerEntity",
"features.movement.water.MixinEntity",
@ -242,25 +250,24 @@
"features.skin_loading.MixinPlayerListEntry",
"features.swinging.MixinInventoryTracker1_16",
"features.swinging.MixinMinecraftClient",
"features.swinging.MixinPlayerEntity",
"features.world.always_tick_entities.MixinClientWorld",
"features.world.always_tick_entities.MixinEntity",
"features.world.disable_sequencing.MixinClientWorld",
"features.world.item_picking.MixinClientPlayerInteractionManager",
"features.world.item_picking.MixinMinecraftClient",
"features.world.remove_server_view_distance.MixinGameOptions",
"features.block.mining_calculation.MixinPlayerEntity",
"features.interaction.attack_cooldown.MixinPlayerEntity",
"features.movement.constants.MixinEntity",
"features.movement.constants.MixinLivingEntity",
"features.movement.constants.MixinPlayerEntity",
"features.movement.limitation.rotation.MixinEntity",
"features.movement.limitation.rotation.MixinPlayerEntity",
"features.swinging.MixinPlayerEntity"
"features.world.remove_server_view_distance.MixinGameOptions"
],
"injectors": {
"defaultRequire": 1
},
"overwrites": {
"requireAnnotations": true
}
},
"mixins": [
"features.interaction.MixinPlayerEntity",
"features.movement.jump.MixinLivingEntity",
"features.movement.sprinting_and_sneaking.MixinPlayerEntity",
"features.networking.keep_player_loaded.MixinPlayerEntity"
]
}