Continue sorting

This commit is contained in:
FlorianMichael 2024-12-30 20:49:45 +01:00
parent e75fddef48
commit bee9e02598
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
24 changed files with 255 additions and 172 deletions

View File

@ -27,7 +27,7 @@ import org.jetbrains.annotations.ApiStatus;
/** /**
* Holder class for the {@link ViaFabricPlusBase} implementation * Holder class for the {@link ViaFabricPlusBase} implementation
*/ */
public class ViaFabricPlus { public final class ViaFabricPlus {
private static ViaFabricPlusBase impl; private static ViaFabricPlusBase impl;
@ -35,7 +35,7 @@ public class ViaFabricPlus {
* Invoked by the internals to set the ViaFabricPlusBase implementation, DO NOT CALL THIS METHOD * Invoked by the internals to set the ViaFabricPlusBase implementation, DO NOT CALL THIS METHOD
*/ */
@ApiStatus.Internal @ApiStatus.Internal
public static void init(ViaFabricPlusBase impl) { public static void init(final ViaFabricPlusBase impl) {
if (ViaFabricPlus.impl != null) { if (ViaFabricPlus.impl != null) {
throw new IllegalStateException("ViaFabricPlus has already been initialized!"); throw new IllegalStateException("ViaFabricPlus has already been initialized!");
} }

View File

@ -23,7 +23,6 @@ package com.viaversion.viafabricplus.features;
import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.api.events.LoadingCycleCallback;
import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.base.Events;
import com.viaversion.viafabricplus.base.sync_tasks.DataCustomPayload;
import com.viaversion.viafabricplus.features.emulation.armor_hud.ArmorHudEmulation1_8; import com.viaversion.viafabricplus.features.emulation.armor_hud.ArmorHudEmulation1_8;
import com.viaversion.viafabricplus.features.block.shape.CollisionShapes; import com.viaversion.viafabricplus.features.block.shape.CollisionShapes;
import com.viaversion.viafabricplus.features.classic.cpe_extension.CPEAdditions; import com.viaversion.viafabricplus.features.classic.cpe_extension.CPEAdditions;
@ -39,25 +38,39 @@ import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion;
public final class FeaturesLoading { public final class FeaturesLoading {
static { static {
// Check if the pack format mappings are correct
ResourcePackHeaderDiff.init(); ResourcePackHeaderDiff.init();
// Register additional CPE features
CPEAdditions.init(); CPEAdditions.init();
DataCustomPayload.init();
// Register the footstep particle
FootStepParticle1_12_2.init(); FootStepParticle1_12_2.init();
Events.LOADING_CYCLE.register(cycle -> { Events.LOADING_CYCLE.register(cycle -> {
if (cycle == LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) { if (cycle == LoadingCycleCallback.LoadingCycle.POST_GAME_LOAD) {
EntityDimensionDiff.init(); // Handle clientside enchantment calculations in <= 1.20.6
EnchantmentAttributesEmulation1_20_6.init(); EnchantmentAttributesEmulation1_20_6.init();
// Handles and updates entity dimension changes in <= 1.17
EntityDimensionDiff.init();
// Ticks the armor hud manually in <= 1.8.x
ArmorHudEmulation1_8.init(); ArmorHudEmulation1_8.init();
} }
}); });
// Reloads some clientside stuff when the protocol version changes
Events.CHANGE_PROTOCOL_VERSION.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> { Events.CHANGE_PROTOCOL_VERSION.register((oldVersion, newVersion) -> MinecraftClient.getInstance().execute(() -> {
// Reloads all bounding boxes of the blocks that we changed
CollisionShapes.reloadBlockShapes(); CollisionShapes.reloadBlockShapes();
// Reloads the clientside recipes
if (newVersion.olderThanOrEqualTo(ProtocolVersion.v1_11_1)) { if (newVersion.olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
Recipes1_11_2.reset(); Recipes1_11_2.reset();
} }
// Reload sound system when switching between 3D Shareware and normal versions
if (oldVersion.equals(AprilFoolsProtocolVersion.s3d_shareware) || newVersion.equals(AprilFoolsProtocolVersion.s3d_shareware)) { if (oldVersion.equals(AprilFoolsProtocolVersion.s3d_shareware) || newVersion.equals(AprilFoolsProtocolVersion.s3d_shareware)) {
MinecraftClient.getInstance().getSoundManager().reloadSounds(); MinecraftClient.getInstance().getSoundManager().reloadSounds();
} }

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.viaversion.viafabricplus.injection.mixin.integration.vialegacy; package com.viaversion.viafabricplus.injection.mixin.base.integration;
import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import com.viaversion.viafabricplus.settings.impl.GeneralSettings;
import net.raphimc.vialegacy.ViaLegacyConfig; import net.raphimc.vialegacy.ViaLegacyConfig;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.viaversion.viafabricplus.injection.mixin.integration.viabedrock; package com.viaversion.viafabricplus.injection.mixin.base.integration.bedrock;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;

View File

@ -19,13 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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.collision;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock; import net.minecraft.block.FenceGateBlock;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -41,15 +40,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List; import java.util.List;
@SuppressWarnings("ConstantValue")
@Mixin(Entity.class) @Mixin(Entity.class)
public abstract class MixinEntity { public abstract class MixinEntity {
@Shadow
private World world;
@Shadow @Shadow
private Vec3d pos; private Vec3d pos;
@Shadow
private World world;
@Shadow @Shadow
public abstract Box getBoundingBox(); public abstract Box getBoundingBox();
@ -74,15 +71,6 @@ public abstract class MixinEntity {
} }
} }
@Redirect(method = "setPitch", at = @At(value = "INVOKE", target = "Ljava/lang/Math;clamp(FFF)F", remap = false))
private float dontClampPitch(float value, float min, float max) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return value;
} else {
return Math.clamp(value, min, max);
}
}
@Inject(method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true) @Inject(method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
private void use1_20_6StepCollisionCalculation(Vec3d movement, CallbackInfoReturnable<Vec3d> cir) { private void use1_20_6StepCollisionCalculation(Vec3d movement, CallbackInfoReturnable<Vec3d> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
@ -133,17 +121,6 @@ public abstract class MixinEntity {
} }
} }
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 9.999999747378752E-6))
private double fixBlockCollisionMargin(double constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return 1E-3;
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return 1E-7;
} else {
return constant;
}
}
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true) @Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
private void modifyVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) { private void modifyVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
final ProtocolVersion target = ProtocolTranslator.getTargetVersion(); final ProtocolVersion target = ProtocolTranslator.getTargetVersion();
@ -153,20 +130,6 @@ public abstract class MixinEntity {
} }
} }
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
private boolean allowInfiniteValues(float f) {
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4));
}
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
private static double fixVelocityEpsilon(double epsilon) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return 1E-4;
} else {
return epsilon;
}
}
@Redirect(method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Ljava/util/List;)Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0)) @Redirect(method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Ljava/util/List;)Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0))
private static double alwaysSortYXZ(double a) { private static double alwaysSortYXZ(double a) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
@ -176,18 +139,4 @@ public abstract class MixinEntity {
} }
} }
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
}
}
@Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true)
private void expandHitBox(CallbackInfoReturnable<Float> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(0.1F);
}
}
} }

View File

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

View File

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

View File

@ -0,0 +1,64 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 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.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public abstract class MixinEntity {
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 9.999999747378752E-6))
private double fixBlockCollisionMargin(double constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return 1E-3;
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return 1E-7;
} else {
return constant;
}
}
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
private static double fixVelocityEpsilon(double epsilon) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return 1E-4;
} else {
return epsilon;
}
}
@Inject(method = "getTargetingMargin", at = @At("HEAD"), cancellable = true)
private void expandHitBox(CallbackInfoReturnable<Float> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(0.1F);
}
}
}

View File

@ -0,0 +1,43 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 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.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity {
@ModifyConstant(method = "isSpaceAroundPlayerEmpty", constant = @Constant(doubleValue = 9.999999747378752E-6 /* 1.0E-5F */))
private double removeOffsetWhenCheckingSneakingCollision(double constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_3)) {
return 0;
} else {
return constant;
}
}
}

View File

@ -91,15 +91,6 @@ public abstract class MixinPlayerEntity extends LivingEntity {
} }
} }
@ModifyConstant(method = "isSpaceAroundPlayerEmpty", constant = @Constant(doubleValue = 9.999999747378752E-6 /* 1.0E-5F */))
private double removeOffsetWhenCheckingSneakingCollision(double constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_3)) {
return 0;
} else {
return constant;
}
}
@Redirect(method = "getMaxRelativeHeadRotation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isBlocking()Z")) @Redirect(method = "getMaxRelativeHeadRotation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isBlocking()Z"))
private boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) { private boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20_2) && instance.isBlocking(); return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20_2) && instance.isBlocking();

View File

@ -0,0 +1,59 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 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.rotation;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public abstract class MixinEntity {
@Redirect(method = "setPitch", at = @At(value = "INVOKE", target = "Ljava/lang/Math;clamp(FFF)F", remap = false))
private float dontClampPitch(float value, float min, float max) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return value;
} else {
return Math.clamp(value, min, max);
}
}
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
private boolean allowInfiniteValues(float f) {
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4));
}
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
}
}
}

View File

@ -1,64 +0,0 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com>
* - RK_01/RaphiMC
* Copyright (C) 2023-2024 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.replace_boat_movement;
import com.mojang.authlib.GameProfile;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.vehicle.BoatEntity;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = ClientPlayerEntity.class, priority = 2000)
public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
super(world, profile);
}
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 0))
private boolean removeVehicleRequirement(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20) && instance.hasVehicle();
}
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
private boolean removeVehicleCheck(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.hasVehicle();
}
@Inject(method = "startRiding", at = @At("RETURN"))
private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
this.prevYaw = entity.getYaw();
this.setYaw(entity.getYaw());
this.setHeadYaw(entity.getYaw());
}
}
}

View File

@ -19,17 +19,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.viaversion.viafabricplus.injection.mixin.features.movement.r1_5_2_vehicle_movement; package com.viaversion.viafabricplus.injection.mixin.features.movement.vehicle;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.viaversion.viafabricplus.injection.access.base.IClientConnection; import com.viaversion.viafabricplus.injection.access.base.IClientConnection;
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.Protocolr1_5_2Tor1_6_1; import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.Protocolr1_5_2Tor1_6_1;
@ -38,10 +41,12 @@ import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; 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.Redirect;
import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ClientPlayerEntity.class) @Mixin(value = ClientPlayerEntity.class, priority = 2000)
public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity { public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
@Shadow @Shadow
@ -52,6 +57,25 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
super(world, profile); super(world, profile);
} }
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 0))
private boolean removeVehicleRequirement(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20) && instance.hasVehicle();
}
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
private boolean removeVehicleCheck(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_19_3) && instance.hasVehicle();
}
@Inject(method = "startRiding", at = @At("RETURN"))
private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) {
this.prevYaw = entity.getYaw();
this.setYaw(entity.getYaw());
this.setHeadYaw(entity.getYaw());
}
}
@Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0)) @Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0))
private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet<?> packet) { private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet<?> packet) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_5_2)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_5_2)) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.viaversion.viafabricplus.injection.mixin.features.networking.remove_nbt_limitation; package com.viaversion.viafabricplus.injection.mixin.features.networking.limitation.nbt;
import com.viaversion.nbt.limiter.TagLimiter; import com.viaversion.nbt.limiter.TagLimiter;
import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType; import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.viaversion.viafabricplus.injection.mixin.features.networking.remove_nbt_limitation; package com.viaversion.viafabricplus.injection.mixin.features.networking.limitation.nbt;
import com.viaversion.nbt.limiter.TagLimiter; import com.viaversion.nbt.limiter.TagLimiter;
import com.viaversion.viaversion.api.type.types.misc.TagType; import com.viaversion.viaversion.api.type.types.misc.TagType;

View File

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

View File

@ -21,8 +21,10 @@
"base.integration.MixinMultiplayerServerListPinger_1", "base.integration.MixinMultiplayerServerListPinger_1",
"base.integration.MixinServerInfo", "base.integration.MixinServerInfo",
"base.integration.MixinUserConnectionImpl", "base.integration.MixinUserConnectionImpl",
"base.integration.MixinViaLegacyConfig",
"base.integration.bedrock.MixinConfirmScreen", "base.integration.bedrock.MixinConfirmScreen",
"base.integration.bedrock.MixinConnectScreen_1", "base.integration.bedrock.MixinConnectScreen_1",
"base.integration.bedrock.MixinJoinPackets",
"base.integration.bedrock.MixinMultiplayerServerListPinger", "base.integration.bedrock.MixinMultiplayerServerListPinger",
"base.integration.event.MixinMinecraftClient", "base.integration.event.MixinMinecraftClient",
"base.integration.sync_tasks.MixinClientCommonNetworkHandler", "base.integration.sync_tasks.MixinClientCommonNetworkHandler",
@ -84,6 +86,9 @@
"features.classic.world_height.MixinEntityPacketRewriter1_17", "features.classic.world_height.MixinEntityPacketRewriter1_17",
"features.classic.world_height.MixinWorldPacketRewriter1_16_2", "features.classic.world_height.MixinWorldPacketRewriter1_16_2",
"features.classic.world_height.MixinWorldPacketRewriter1_17", "features.classic.world_height.MixinWorldPacketRewriter1_17",
"features.emulation.recipe.MixinCraftingScreenHandler",
"features.emulation.recipe.MixinEntityPacketRewriter1_12",
"features.emulation.recipe.MixinPlayerScreenHandler",
"features.entity.allow_duplicated_uuid.MixinEntityIndex", "features.entity.allow_duplicated_uuid.MixinEntityIndex",
"features.entity.attribute.MixinEntityPacketRewriter1_20_5", "features.entity.attribute.MixinEntityPacketRewriter1_20_5",
"features.entity.attribute.MixinLivingEntity", "features.entity.attribute.MixinLivingEntity",
@ -173,30 +178,29 @@
"features.mouse_sensitivity.MixinMouse", "features.mouse_sensitivity.MixinMouse",
"features.mouse_sensitivity.MixinMouseOptionsScreen", "features.mouse_sensitivity.MixinMouseOptionsScreen",
"features.movement.MixinClientPlayerEntity", "features.movement.MixinClientPlayerEntity",
"features.movement.change_honey_slowness.MixinHoneyBlock",
"features.movement.collision.MixinAbstractBoatEntity", "features.movement.collision.MixinAbstractBoatEntity",
"features.movement.collision.MixinEntity",
"features.movement.collision.MixinHoneyBlock",
"features.movement.collision.MixinSoulSandBlock",
"features.movement.elytra.MixinClientPlayerEntity", "features.movement.elytra.MixinClientPlayerEntity",
"features.movement.elytra.MixinFireworkRocketItem", "features.movement.elytra.MixinFireworkRocketItem",
"features.movement.elytra.MixinLivingEntity", "features.movement.elytra.MixinLivingEntity",
"features.movement.elytra.MixinPlayerEntity", "features.movement.elytra.MixinPlayerEntity",
"features.movement.entity.MixinEntity",
"features.movement.entity.MixinLivingEntity", "features.movement.entity.MixinLivingEntity",
"features.movement.entity.MixinPlayerEntity", "features.movement.entity.MixinPlayerEntity",
"features.movement.entity.MixinPlayerEntityRenderer", "features.movement.entity.MixinPlayerEntityRenderer",
"features.movement.handle_slowness_on_collision.MixinSoulSandBlock",
"features.movement.jump.MixinClientPlayerEntity", "features.movement.jump.MixinClientPlayerEntity",
"features.movement.r1_5_2_vehicle_movement.MixinClientPlayerEntity",
"features.movement.remove_bed_bounce.MixinBedBlock", "features.movement.remove_bed_bounce.MixinBedBlock",
"features.movement.replace_boat_movement.MixinClientPlayerEntity",
"features.movement.slowdown_calculation.MixinClientPlayerEntity", "features.movement.slowdown_calculation.MixinClientPlayerEntity",
"features.movement.slowdown_calculation.MixinEnderEyeItem", "features.movement.slowdown_calculation.MixinEnderEyeItem",
"features.movement.sprinting_sneaking_condition.MixinClientPlayerEntity", "features.movement.sprinting_sneaking_condition.MixinClientPlayerEntity",
"features.movement.water_movement.MixinClientPlayerEntity", "features.movement.vehicle.MixinClientPlayerEntity",
"features.movement.water_movement.MixinEntity", "features.movement.water.MixinClientPlayerEntity",
"features.movement.water_movement.MixinFlowableFluid", "features.movement.water.MixinEntity",
"features.movement.water_movement.MixinItemEntity", "features.movement.water.MixinFlowableFluid",
"features.movement.water_movement.MixinLivingEntity", "features.movement.water.MixinItemEntity",
"features.movement.water_movement.MixinSkeletonHorseEntity", "features.movement.water.MixinLivingEntity",
"features.movement.water.MixinSkeletonHorseEntity",
"features.networking.config_state.MixinClientConfigurationNetworkHandler", "features.networking.config_state.MixinClientConfigurationNetworkHandler",
"features.networking.config_state.MixinClientPlayNetworkHandler", "features.networking.config_state.MixinClientPlayNetworkHandler",
"features.networking.config_state.MixinNetworkStateTransitionHandler", "features.networking.config_state.MixinNetworkStateTransitionHandler",
@ -210,9 +214,11 @@
"features.networking.legacy_chat_signature.MixinPlayerPublicKey_PublicKeyData", "features.networking.legacy_chat_signature.MixinPlayerPublicKey_PublicKeyData",
"features.networking.legacy_chat_signature.MixinProfileKeysImpl", "features.networking.legacy_chat_signature.MixinProfileKeysImpl",
"features.networking.legacy_chat_signature.MixinYggdrasilUserApiService", "features.networking.legacy_chat_signature.MixinYggdrasilUserApiService",
"features.networking.limitation.MixinClientLoginNetworkHandler",
"features.networking.limitation.nbt.MixinNamedCompoundTagType",
"features.networking.limitation.nbt.MixinTagType",
"features.networking.open_inventory_packet.MixinMinecraftClient", "features.networking.open_inventory_packet.MixinMinecraftClient",
"features.networking.packet_handling.MixinClientCommonNetworkHandler", "features.networking.packet_handling.MixinClientCommonNetworkHandler",
"features.networking.packet_handling.MixinClientLoginNetworkHandler",
"features.networking.packet_handling.MixinClientPlayNetworkHandler", "features.networking.packet_handling.MixinClientPlayNetworkHandler",
"features.networking.packet_handling.MixinEntityPacketRewriter1_19_4", "features.networking.packet_handling.MixinEntityPacketRewriter1_19_4",
"features.networking.packet_handling.MixinEntityPacketRewriter1_20_3", "features.networking.packet_handling.MixinEntityPacketRewriter1_20_3",
@ -220,8 +226,6 @@
"features.networking.registry_validation.MixinRegistryEntryList_Named", "features.networking.registry_validation.MixinRegistryEntryList_Named",
"features.networking.registry_validation.MixinRegistryEntryListCodec", "features.networking.registry_validation.MixinRegistryEntryListCodec",
"features.networking.remove_legacy_pinger.MixinMultiplayerServerListPinger", "features.networking.remove_legacy_pinger.MixinMultiplayerServerListPinger",
"features.networking.remove_nbt_limitation.MixinNamedCompoundTagType",
"features.networking.remove_nbt_limitation.MixinTagType",
"features.networking.remove_signed_commands.MixinClientPlayNetworkHandler", "features.networking.remove_signed_commands.MixinClientPlayNetworkHandler",
"features.networking.remove_signed_commands.MixinProtocol1_20_3To1_20_5", "features.networking.remove_signed_commands.MixinProtocol1_20_3To1_20_5",
"features.networking.resource_pack_header.MixinServerResourcePackLoader_4", "features.networking.resource_pack_header.MixinServerResourcePackLoader_4",
@ -229,14 +233,11 @@
"features.networking.srv_resolving.MixinConnectScreen_1", "features.networking.srv_resolving.MixinConnectScreen_1",
"features.networking.srv_resolving.MixinRedirectResolver", "features.networking.srv_resolving.MixinRedirectResolver",
"features.networking.srv_resolving.MixinServerAddress", "features.networking.srv_resolving.MixinServerAddress",
"features.emulation.recipe.MixinCraftingScreenHandler",
"features.emulation.recipe.MixinEntityPacketRewriter1_12",
"features.emulation.recipe.MixinPlayerScreenHandler",
"features.remove_newer_screen_features.MixinCommandBlockScreen", "features.remove_newer_screen_features.MixinCommandBlockScreen",
"features.remove_newer_screen_features.MixinJigsawBlockScreen", "features.remove_newer_screen_features.MixinJigsawBlockScreen",
"features.remove_newer_screen_features.MixinStructureBlockScreen_1", "features.remove_newer_screen_features.MixinStructureBlockScreen_1",
"features.replace_blank_glyph.MixinFontStorage", "features.replace_blank_glyph.MixinFontStorage",
"features.run_command_action_handling.MixinScreen", "features.run_command_action.MixinScreen",
"features.sign_editor_reach.MixinAbstractSignEditScreen", "features.sign_editor_reach.MixinAbstractSignEditScreen",
"features.skin_loading.MixinPlayerListEntry", "features.skin_loading.MixinPlayerListEntry",
"features.swinging.MixinInventoryTracker1_16", "features.swinging.MixinInventoryTracker1_16",
@ -246,14 +247,17 @@
"features.world.disable_sequencing.MixinClientWorld", "features.world.disable_sequencing.MixinClientWorld",
"features.world.item_picking.MixinClientPlayerInteractionManager", "features.world.item_picking.MixinClientPlayerInteractionManager",
"features.world.item_picking.MixinMinecraftClient", "features.world.item_picking.MixinMinecraftClient",
"features.world.remove_server_view_distance.MixinGameOptions", "features.world.remove_server_view_distance.MixinGameOptions"
"integration.viabedrock.MixinJoinPackets",
"integration.vialegacy.MixinViaLegacyConfig"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
}, },
"overwrites": { "overwrites": {
"requireAnnotations": true "requireAnnotations": true
} },
"mixins": [
"features.movement.constants.MixinEntity",
"features.movement.constants.MixinPlayerEntity",
"features.movement.limitation.rotation.MixinEntity"
]
} }