-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LivingEntityのパケットによる座標更新時にheadYawとbodyYawも更新する
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
raincoat-fabric/src/main/java/dev/uten2c/raincoat/mixin/entity/MixinLivingEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters