saltar al contenido principal
paste
bin
.ca
type · paste · share
⌘
K
Familia
La familia bin
pastebin.ca
centro
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
Iniciar sesión
?
← volver a la publicación
›
Editar / bifurcar
Custom Player Body Yaw Code (Bypass yBodyRot bugs)
#6B5VVuabJZ
unlisted / public
nueva versión
anónimo
creado 7 hours ago
Caduca en 3 months
2.2 KB
sintaxis:
javascript
Tus cambios crean una nueva publicación enlazada a esta — la original no se toca.
nueva versión
Tus cambios crean una nueva publicación enlazada a esta — la original no se toca.
Título (opcional)
Nombre de archivo
Sintaxis
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
Visibilidad
Sin listar
Acceso
public
Caduca
90 días
10 min
1 hora
1 día
7 días
30 días
90 días
personalizada…
Caducidad personalizada
Nota de cambio
(opcional)
Crear nueva versión
Cancelar
Pegar o escribir…
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); }