Skip to content

Commit

Permalink
LivingEntityのパケットによる座標更新時にheadYawとbodyYawも更新する
Browse files Browse the repository at this point in the history
  • Loading branch information
uTen2c committed Oct 1, 2023
1 parent 794e5a6 commit 59073b4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package dev.uten2c.raincoat.mixin.entity;

import dev.uten2c.raincoat.States;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.World;
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.CallbackInfo;

@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends Entity {
@Shadow
public float prevHeadYaw;

@Shadow
public float headYaw;

@Shadow
public float bodyYaw;

@Shadow
public float prevBodyYaw;

public MixinLivingEntity(EntityType<?> type, World world) {
super(type, world);
}

@Inject(method = "updateTrackedHeadRotation", at = @At("TAIL"))
private void updatePrevHeadYaw(float yaw, int interpolationSteps, CallbackInfo ci) {
if (!States.isOnServer()) {
return;
}
prevHeadYaw = yaw;
}

@Override
public void updatePositionAndAngles(double x, double y, double z, float yaw, float pitch) {
super.updatePositionAndAngles(x, y, z, yaw, pitch);
if (!States.isOnServer()) {
return;
}
headYaw = yaw;
prevHeadYaw = yaw;
bodyYaw = yaw;
prevBodyYaw = yaw;
}
}
1 change: 1 addition & 0 deletions raincoat-fabric/src/main/resources/raincoat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"block.entity.MixinHangingSignBlockEntity",
"block.entity.MixinSignBlockEntity",
"block.entity.MixinWallHangingSignBlock",
"entity.MixinLivingEntity",
"item.MixinItemGroups"
],
"injectors": {
Expand Down

0 comments on commit 59073b4

Please sign in to comment.