跳到主内容
paste
bin
.ca
type · paste · share
⌘
K
系列
bin 系列
pastebin.ca
中心
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.
文档
登录
?
← 返回文本
›
编辑 / 分支
Custom Player Body Yaw Code (Bypass yBodyRot bugs)
#6B5VVuabJZ
unlisted / public
新版本
匿名
已创建 7 hours ago
过期于 3 months
2.2 KB
语法:
javascript
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
新版本
你的更改会创建一个链接到此文本的新文本 — 原始文本不变。
标题(可选)
文件名
语法
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
可见性
未列出
访问
public
过期
90 天
10 分钟
1 小时
1 天
7 天
30 天
90 天
自定义…
自定义过期
变更备注
(可选)
创建新版本
取消
粘贴或输入…
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); }