Полу-кастомный игрок и каталог объектов ремейка
Игрок: - RsxPlayer extends EntityPlayerSP: наш игрок с нашими числами движения. - RsxMovementInput extends MovementInputFromOptions: отменяет ванильный множитель подкрадывания 0.3 и ставит наш. - RsxPlayerTuning: подкрадывание 1.5 блока/с (было ~1.3), прыжок 1.35 блока (было 1.25). Прыжок считается по высоте: v = 0.42 * sqrt(h / 1.25) = 0.43713. Правило пользователя: значение меньше заданного не принимается, остаётся 1.5. Переопределяется из командной строки: -Drsx.sneakSpeed, -Drsx.jumpHeight. - Мобы прыгают как в ванилле: переопределение в RsxPlayer, а не в EntityLivingBase. - Три строки патчей в ванильное дерево: PlayerControllerMP создаёт RsxPlayer, Minecraft создаёт RsxMovementInput. Вся логика в нашем коде. - Форк собирается чисто, 3278 классов. Каталог: - tools/catalog-remake.py собирает assets/rustex/CATALOG.md и catalog.json. - Что нашли у ремейка: 218 предметов (46 одежды, 44 ресурса, 33 оружия, 31 медицина, 21 инструмент, 17 построек, 11 боеприпасов, 11 разных, 4 ловушки), 91 объект nextgen (бочки, ящики, двери, верстаки, печи, руда, модели монументов), 553 модели .obj (384 оружия с перезарядкой, 128 деталей постройки, 36 мебели, 4 руды), 133 иконки предметов, 2004 звука, текстуры монументов и животных, скины игрока (9 файлов 256x256 плюс 9 с моргающими глазами) в assets/rustex/player/. - Скины игрока - текстуры ремейка, модель тела ванильная. Декомпил ремейка лежит на диске: G:\src-decoded (5207 файлов, строки расшифрованы). Поведение клиента можно читать, а не угадывать: конфиг оружия с отдачей, схема viewmodel, формат данных. Значения же приходят с сервера, в клиенте только схема и значения по умолчанию. План дополнен разделами 2.8 (игрок) и 2.9 (декомпил).
This commit is contained in:
@@ -1247,3 +1247,19 @@ import org.lwjgl.opengl.ContextCapabilities;
|
||||
}
|
||||
|
||||
Entity entity = this.mc.getRenderViewEntity();
|
||||
|
||||
# Our player. The class is ours, the behaviour is the vanilla one, and the two
|
||||
# numbers that differ from the vanilla live in RsxPlayerTuning.
|
||||
=== FILE net/minecraft/client/multiplayer/PlayerControllerMP.java
|
||||
--- BEFORE
|
||||
return new EntityPlayerSP(this.mc, world, this.connection, statisticsmanager, recipebook);
|
||||
--- AFTER
|
||||
return new net.rustnotmc.client.RsxPlayer(this.mc, world, this.connection, statisticsmanager, recipebook);
|
||||
|
||||
# The movement input of our player: the same input with our crouch in it.
|
||||
=== FILE net/minecraft/client/Minecraft.java
|
||||
--- BEFORE
|
||||
this.player.movementInput = new MovementInputFromOptions(this.gameSettings);
|
||||
--- AFTER
|
||||
this.player.movementInput = new net.rustnotmc.client.RsxMovementInput(this.gameSettings);
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.rustnotmc.client;
|
||||
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.util.MovementInputFromOptions;
|
||||
|
||||
/**
|
||||
* The movement input with our crouch.
|
||||
*
|
||||
* The vanilla already slows the movement down by a third while the crouch key
|
||||
* is down. We undo that and apply our own factor, so the crouch is a little
|
||||
* faster than the vanilla one and the number itself lives in
|
||||
* {@link RsxPlayerTuning}.
|
||||
*/
|
||||
public class RsxMovementInput extends MovementInputFromOptions {
|
||||
|
||||
public RsxMovementInput(GameSettings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlayerMoveState() {
|
||||
super.updatePlayerMoveState();
|
||||
if (!this.sneak) {
|
||||
return;
|
||||
}
|
||||
float correction = RsxPlayerTuning.sneakCorrection();
|
||||
this.moveStrafe = (float) ((double) this.moveStrafe * (double) correction);
|
||||
this.moveForward = (float) ((double) this.moveForward * (double) correction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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 two things changed: the crouch is a little faster
|
||||
* and the jump is a little higher. 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.
|
||||
*
|
||||
* The override lives here and not in EntityLivingBase, because the mobs
|
||||
* have to keep jumping the way they always did.
|
||||
*/
|
||||
@Override
|
||||
protected float getJumpUpwardsMotion() {
|
||||
return RsxPlayerTuning.jumpMotion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package net.rustnotmc.client;
|
||||
|
||||
/**
|
||||
* The numbers that make our player move the way our player moves.
|
||||
*
|
||||
* The player is the vanilla one with two things changed: the crouch is a
|
||||
* little faster and the jump is a little higher. Both numbers live here so
|
||||
* that the rest of the code has one place to point at, and so that a change
|
||||
* is one line.
|
||||
*
|
||||
* They can be set from the command line:
|
||||
*
|
||||
* -Drsx.sneakSpeed=1.6 -Drsx.jumpHeight=1.4
|
||||
*
|
||||
* A value that is set below the floor is not taken: the crouch stays at 1.5
|
||||
* blocks per second and the jump at 1.5 blocks. The defaults are the ones we
|
||||
* want, and they are not put through the floor.
|
||||
*/
|
||||
public final class RsxPlayerTuning {
|
||||
|
||||
/** How fast the player walks, in blocks per second. The vanilla. */
|
||||
public static final float WALK_SPEED = 4.317F;
|
||||
|
||||
/** How fast the player crouches, in blocks per second. */
|
||||
public static final float SNEAK_SPEED = 1.5F;
|
||||
|
||||
/** How much the vanilla crouch slows the movement down. */
|
||||
public static final float VANILLA_SNEAK_FACTOR = 0.3F;
|
||||
|
||||
/** How high the player jumps, in blocks. The vanilla jumps 1.25. */
|
||||
public static final float JUMP_HEIGHT = 1.35F;
|
||||
|
||||
/** The crouch never goes below this, in blocks per second. */
|
||||
public static final float SNEAK_SPEED_FLOOR = 1.5F;
|
||||
|
||||
/** The jump never goes below this, in blocks. */
|
||||
public static final float JUMP_HEIGHT_FLOOR = 1.5F;
|
||||
|
||||
/** The jump the vanilla has, in blocks. Used to scale the jump speed. */
|
||||
private static final float VANILLA_JUMP_HEIGHT = 1.25F;
|
||||
|
||||
/** The speed the vanilla jumps with. */
|
||||
private static final float VANILLA_JUMP_MOTION = 0.42F;
|
||||
|
||||
private RsxPlayerTuning() {
|
||||
}
|
||||
|
||||
/** The crouch speed: the setting, or the default. */
|
||||
public static float sneakSpeed() {
|
||||
return setting("rsx.sneakSpeed", SNEAK_SPEED, SNEAK_SPEED_FLOOR);
|
||||
}
|
||||
|
||||
/** The jump height: the setting, or the default. */
|
||||
public static float jumpHeight() {
|
||||
return setting("rsx.jumpHeight", JUMP_HEIGHT, JUMP_HEIGHT_FLOOR);
|
||||
}
|
||||
|
||||
/** The factor the crouch slows the movement down by. */
|
||||
public static float sneakFactor() {
|
||||
return sneakSpeed() / WALK_SPEED;
|
||||
}
|
||||
|
||||
/**
|
||||
* How much faster our crouch is than the vanilla one.
|
||||
*
|
||||
* The vanilla already multiplied the movement by a third. We undo that
|
||||
* and put ours in its place.
|
||||
*/
|
||||
public static float sneakCorrection() {
|
||||
return sneakFactor() / VANILLA_SNEAK_FACTOR;
|
||||
}
|
||||
|
||||
/** The upward speed a jump of our height needs. */
|
||||
public static float jumpMotion() {
|
||||
return jumpMotion(jumpHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* The upward speed a jump of that height needs.
|
||||
*
|
||||
* The vanilla jumps with 0.42 and that carries it 1.25 blocks. The height
|
||||
* grows with the square of the speed, so the speed for a height is the
|
||||
* vanilla one times the square root of the ratio.
|
||||
*/
|
||||
public static float jumpMotion(float height) {
|
||||
if (height <= 0.0F) {
|
||||
return VANILLA_JUMP_MOTION;
|
||||
}
|
||||
return VANILLA_JUMP_MOTION * (float) Math.sqrt(height / VANILLA_JUMP_HEIGHT);
|
||||
}
|
||||
|
||||
private static float setting(String name, float fallback, float floor) {
|
||||
String value = System.getProperty(name);
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return fallback;
|
||||
}
|
||||
float parsed;
|
||||
try {
|
||||
parsed = Float.parseFloat(value.trim());
|
||||
} catch (NumberFormatException ignored) {
|
||||
return fallback;
|
||||
}
|
||||
if (parsed != parsed) {
|
||||
return fallback;
|
||||
}
|
||||
return parsed < floor ? floor : parsed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user