Skip to content

Commit

Permalink
fix some movement stuff and make noclip movement better
Browse files Browse the repository at this point in the history
  • Loading branch information
valoeghese committed Dec 12, 2021
1 parent 2807b55 commit cb8d42e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Hotbar(Inventory parent) {
this.parent = parent;

for (int i = 0; i < 10; ++i) {
this.guis.add(new HotbarEntry(0.8f, 0.87f - (0.14f * i)));
this.guis.add(new HotbarEntry(0.8f, 0.75f - (0.14f * i)));
this.update(i, Client2fc.getInstance().getWindowAspect());
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tk/valoeghese/fc0/client/screen/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public void handleKeybinds() {

if (player.isNoClip()) {
if (Keybinds.JUMP.isPressed()) {
player.addVelocity(0.0, 0.02, 0.0);
player.addVelocity(0.0, 0.1, 0.0);
} else if (Keybinds.NO_CLIP_DOWN.isPressed()) {
player.addVelocity(0.0, -0.02, 0.0);
player.addVelocity(0.0, -0.1, 0.0);
}
} else if (Keybinds.JUMP.isPressed()) {
long time = System.currentTimeMillis();
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/tk/valoeghese/fc0/world/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,23 @@ public void tick() {

TilePos below = this.getTilePos().down();

if (!this.noClip && this.world.isInWorld(below)) {
byte tile = this.world.readTile(below);
if (this.noClip) {
this.friction = 0.75;
} else {
if (this.world.isInWorld(below)) {
byte tile = this.world.readTile(below);

if (tile != Tile.AIR.id) {
this.friction = 0.75;
this.friction /= Tile.BY_ID[tile].getFrictionConstant();
this.friction = Math.min(1.0, this.friction);
if (tile != Tile.AIR.id) {
this.friction = 0.75;
this.friction /= Tile.BY_ID[tile].getFrictionConstant();
this.friction = Math.min(1.0, this.friction);
}
}
}

if (!this.noClip) { // -0.01, -0.02 originally
this.velocity.offsetY(this.isSwimming() ? -0.04f : -0.08f);
}

this.velocity.mul(this.friction, this.noClip ? 0.96 : (this.isSwimming() && this.velocity.getY() < 0 ? 0.75 : 0.98), this.friction); // swimming slowfall. also noclip is special bunny
this.velocity.mul(this.friction, this.noClip ? 0.75 : (this.isSwimming() && this.velocity.getY() < 0 ? 0.75 : 0.98), this.friction); // swimming slowfall. also noclip is special bunny
this.move(this.velocity.getX(), 0.0, 0.0);
this.move(0.0, 0.0, this.velocity.getZ());

Expand All @@ -61,6 +63,8 @@ public void tick() {
}

if (!this.move(0.0, this.velocity.getY(), 0.0)) {
if (this.velocity.getY() < 0) this.nextPos.setY(MathsUtils.floor(this.pos.getY()));

this.velocity.setY(0.0);

if (this.falling) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tk/valoeghese/fc0/world/entity/Lifeform.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setMaxHealth(int maxHealth) {
@Override
public void hitGround() {
// set tick offset to delay next sound
this.lastFallTickOffset = (int) Game2fc.getInstance().time & 0x7;
this.lastFallTickOffset = (int) ((Game2fc.getInstance().time - 1) & 0x7);

// play sound
Tile on = Tile.BY_ID[this.world.readTile(new TilePos(this.pos).down())];
Expand Down

0 comments on commit cb8d42e

Please sign in to comment.