diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java index aeffe9a7..dca80df6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java @@ -17,8 +17,8 @@ */ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; +import net.minecraft.entity.EntityDimensions; import net.raphimc.vialoader.util.VersionEnum; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import net.minecraft.block.BlockState; @@ -34,6 +34,7 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; @@ -61,6 +62,8 @@ public abstract class MixinEntity { public abstract void setVelocity(Vec3d velocity); + @Shadow protected abstract Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor); + @ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7)) private static double injectMovementInputToVelocity(double epsilon) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) { @@ -190,4 +193,13 @@ public abstract class MixinEntity { cir.setReturnValue(blockPos); } } + + @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) + public Vector3f revertStaticRidingOffsetCalculation(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { + return new Vector3f(0.0F, dimensions.height * 0.75F, 0.0F); + } + + return getPassengerAttachmentPos(passenger, dimensions, scaleFactor); + } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index a0667559..39a16ff7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -22,10 +22,7 @@ import de.florianmichael.viafabricplus.base.settings.groups.ExperimentalSettings import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; import net.minecraft.block.BlockState; import net.minecraft.block.TrapdoorBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.*; import net.minecraft.entity.mob.SkeletonHorseEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; @@ -38,6 +35,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.raphimc.vialoader.util.VersionEnum; +import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; @@ -209,4 +207,12 @@ public abstract class MixinLivingEntity extends Entity { } } + @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) + public Vector3f revertStaticRidingOffsetCalculation(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { + return new Vector3f(0.0F, entityDimensions.height * 0.75F, 0.0F); + } + + return getPassengerAttachmentPos(entity, entityDimensions, v); + } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java index c3cdd385..37eb39af 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java @@ -133,4 +133,11 @@ public abstract class MixinPlayerEntity extends LivingEntity { } return instance.isSprinting(); } + + @Inject(method = "getUnscaledRidingOffset", at = @At("HEAD"), cancellable = true) + public void setStaticScale(Entity vehicle, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) { + cir.setReturnValue(-0.35F); + } + } }