Files
RustNotMC/game-fork/src-overlay/net/rustnotmc/client/RsxPlayer.java
T
sasheg dev 9980c1561d Игрок: хитбокс 1.45 в шифте и прыжок с места 1.5
- RsxPlayerTuning: высота при подкрадывании 1.45 (ванилла 1.65), прыжок с
  места 1.5, в движении ванильные 1.25, высота глаз в шифте 1.37.
- RsxPlayer: прыжок по наличию горизонтального ввода, глаза при подкрадывании.
- Патч в EntityPlayer.updateSize: высота при подкрадывании из нашего класса.
- Импульс прыжка считается обратным счетом по физике ваниллы.

AABB: редактор хитбоксов и их отрисовка

- Протокол: Hitbox (имя, зона, min/max, поворот), пакеты Hitboxes,
  HitboxInstances и HitboxesReload.
- Сервер: HitboxRegistry читает JSON-файл (world/hitboxes.json, можно
  указать --hitboxes), перечитывает его по запросу клиента и шлет наборы
  игрокам. Сломанный файл не стирает рабочие коробки, а объясняет причину.
- Клиент: RsxHitboxDebug рисует коробки через RenderGlobal.drawBoundingBox
  с подписями DebugRenderer, красит зоны (голова красная, тело желтое, ноги
  синие). Команды: /rsx hitboxes on|off|reload|list|show NAME.
- Новый модуль rsx-plugin-api с интерфейсом Hitboxes: плагин может
  зарегистрировать свои коробки. У сервера появился скрипт сборки.

Тесты: протокол 34, сервер 80 (было 74). Форк собирается чисто, 3279 классов.
2026-10-21 22:31:16 +03:00

69 lines
2.6 KiB
Java

package net.rustnotmc.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.stats.RecipeBook;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.world.World;
/**
* Our player.
*
* The vanilla player with three things changed: the crouch is low enough to
* squeeze through a hole of one and a half blocks, the hop from a standstill
* is higher than the vanilla jump, and the eyes follow the lower crouch.
* Everything else is the vanilla behaviour, so the player still walks, swims,
* rides, fights and dies the way the game always did.
*
* The class exists so that the numbers of our movement live in our code and
* not in the patches of the vanilla tree: the patches only have to say "the
* player is ours", and everything else is here.
*/
public class RsxPlayer extends EntityPlayerSP {
public RsxPlayer(Minecraft minecraft, World world, NetHandlerPlayClient connection,
StatisticsManager statistics, RecipeBook recipeBook) {
super(minecraft, world, connection, statistics, recipeBook);
this.movementInput = new RsxMovementInput(minecraft.gameSettings);
}
/**
* How high the player jumps.
*
* Jumping on the spot is the Rust-like hop and clears more than the
* vanilla jump does. Jumping while moving keeps the vanilla height, so a
* running jump stays the same as it always was.
*
* The override lives here and not in EntityLivingBase, because the mobs
* have to keep jumping the way they always did.
*/
@Override
protected float getJumpUpwardsMotion() {
if (this.movementInput == null || !isMoving()) {
return RsxPlayerTuning.jumpMotion(RsxPlayerTuning.jumpHeightStanding());
}
return RsxPlayerTuning.jumpMotion(RsxPlayerTuning.jumpHeightMoving());
}
/** True when the player is asking to move sideways or forward. */
private boolean isMoving() {
return this.movementInput.moveStrafe != 0.0F || this.movementInput.moveForward != 0.0F;
}
/**
* Where the eyes are.
*
* The vanilla crouch lowers the player to 1.65 and puts the eyes at 1.54.
* Ours is lower, so the eyes have to come down with it, or they would sit
* above the head.
*/
@Override
public float getEyeHeight() {
if (this.isSneaking() && !this.isPlayerSleeping() && !this.isElytraFlying()) {
return RsxPlayerTuning.crouchHeight() - RsxPlayerTuning.CROUCH_EYE_OFFSET;
}
return super.getEyeHeight();
}
}