Skip to content

Commit

Permalink
generic.jump_strength attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
j0code committed Mar 1, 2024
1 parent 1266231 commit 1ada21a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/AttributeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { type ArrayElement, type HasData } from "./util/interfaces";

const AttributeNames = [
"generic.movement_speed",
"generic.jump_strength",
"player.block_interaction_range",
"player.entity_interaction_range"
] as const
] as const satisfies `${string}.${string}`[]

export type AttributeName = ArrayElement<typeof AttributeNames>

Expand Down
3 changes: 3 additions & 0 deletions src/defs/PlayerDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default class PlayerDef extends EntityDef {
attributes: [{
name: "generic.movement_speed",
base: 1
}, {
name: "generic.jump_strength",
base: 0.35
}, {
name: "player.block_interaction_range",
base: 4.5
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function getTexture(path: string) {
function tick() {
if (input.keyPressed("Space")) {
if (player.inFluid) player.motion.y = Entity.TERMINAL_FLUID_VELOCITY
else if (player.onGround) player.motion.y = 0.35
else if (player.onGround) player.motion.y = player.attributes.get("generic.jump_strength") || 0.35
}

player.motion.x = (Number(input.keyPressed("KeyD")) - Number(input.keyPressed("KeyA"))) * 0.15
Expand Down

0 comments on commit 1ada21a

Please sign in to comment.