skip to main content
paste
bin
.ca
type · paste · share
⌘
K
Family
The bin family
pastebin.ca
hub
Share text and code with expiry and privacy controls.
imagebin.ca
Upload and share images with direct links.
filebin.ca
Drop a file and get a shareable link.
notebin.ca
Write Markdown notes with durable links.
turl.ca
Short, reputation-checked links.
attn.ca
Notifications and alerts for your services.
voicebin.ca
Record and share short voice clips.
dnsbin.ca
Inspect DNS and debug records.
Docs
Sign in
?
← back to paste
›
Edit / fork
Custom Player Body Yaw Code (Bypass yBodyRot bugs)
#6B5VVuabJZ
unlisted / public
new version
anonymous
created 6 hours ago
Expires in 3 months
2.2 KB
syntax:
javascript
Your changes create a new paste linked to this one — the original is untouched.
new version
Your changes create a new paste linked to this one — the original is untouched.
Title (optional)
Filename
Syntax
javascript
text
bash
c
cpp
css
diff
dockerfile
go
html
ini
java
javascript
json
kotlin
lua
makefile
markdown
nginx
php
python
ruby
rust
shellscript
sql
swift
toml
typescript
xml
yaml
Visibility
Unlisted
Access
public
Expires
90 days
10 min
1 hour
1 day
7 days
30 days
90 days
custom…
Custom expiry
Change note
(optional)
Create new version
Cancel
Paste or type…
if (entity instanceof net.minecraft.world.entity.player.Player player) { net.mcreator.[yourmodname].network.YourModVariables.PlayerVariables vars = player.getCapability(net.mcreator.[yourmodname].network.YourModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new net.mcreator.[yourmodname].network.YourModVariables.PlayerVariables()); float currentBodyYaw = (float) [global_bodyYaw]; if (currentBodyYaw == 0.0f && player.getYRot() != 0.0f) { currentBodyYaw = player.getYRot(); } float headYaw = player.getYRot(); double dx = player.getX() - [global_lastX]; double dz = player.getZ() - [global_lastZ]; int moveGrace = player.getPersistentData().getInt("move_grace"); if (dx * dx + dz * dz > 0.001) { moveGrace = 5; float moveYaw = (float)(Math.atan2(-dx, dz) * (180.0 / Math.PI)); float relativeYaw = net.minecraft.util.Mth.wrapDegrees(moveYaw - headYaw); player.getPersistentData().putFloat("last_rel_yaw", relativeYaw); [global_lastX] = player.getX(); [global_lastZ] = player.getZ(); } else if (moveGrace > 0) { moveGrace--; } player.getPersistentData().putInt("move_grace", moveGrace); boolean isMoving = moveGrace > 0; float idealBodyYaw = headYaw; if (isMoving) { float relYaw = player.getPersistentData().getFloat("last_rel_yaw"); if (Math.abs(relYaw) < 135.0f) { if (relYaw > 50.0f) relYaw = 50.0f; if (relYaw < -50.0f) relYaw = -50.0f; idealBodyYaw = headYaw + relYaw; } } float diffIdeal = net.minecraft.util.Mth.wrapDegrees(idealBodyYaw - currentBodyYaw); boolean isInteracting = player.swinging || player.isUsingItem(); if (isInteracting) { currentBodyYaw += diffIdeal * 0.4f; } else if (isMoving) { currentBodyYaw += diffIdeal * 0.4f; } float diffHeadBody = net.minecraft.util.Mth.wrapDegrees(headYaw - currentBodyYaw); if (diffHeadBody > 50.0f) { currentBodyYaw = headYaw - 50.0f; } else if (diffHeadBody < -50.0f) { currentBodyYaw = headYaw + 50.0f; } [global_bodyYaw] = (double) net.minecraft.util.Mth.wrapDegrees(currentBodyYaw); vars.syncPlayerVariables(player); }