pular para o conteúdo principal
paste
bin
.ca
type · paste · share
⌘
K
Família
A família bin
pastebin.ca
central
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
Entrar
?
← voltar para a publicação
›
Editar / bifurcar
Custom Player Body Yaw Code (Bypass yBodyRot bugs)
#6B5VVuabJZ
unlisted / public
nova versão
anônimo
criado 7 hours ago
Expira em 3 months
2.2 KB
sintaxe:
javascript
Suas alterações criam uma nova publicação vinculada a esta — a original não é alterada.
nova versão
Suas alterações criam uma nova publicação vinculada a esta — a original não é alterada.
Título (opcional)
Nome do arquivo
Sintaxe
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
Visibilidade
Não listada
Acesso
public
Expira
90 dias
10 min
1 hora
1 dia
7 dias
30 dias
90 dias
personalizada…
Expiração personalizada
Nota da alteração
(opcional)
Criar nova versão
Cancelar
Cole ou digite…
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); }