improve mojang lightning

This commit is contained in:
LabyStudio
2022-02-03 01:18:22 +01:00
parent 9a70a3cc37
commit 0a16cb9721
9 changed files with 167 additions and 112 deletions
+23 -12
View File
@@ -42,22 +42,33 @@ window.Player = class {
this.prevFovModifier = 0;
this.fovModifier = 0;
this.timeFovChanged = 0;
this.resetPos();
}
resetPos() {
this.setPos(0, 80, 0);
respawn() {
let spawnY = this.world.getHeightAt(0, 0);
this.setPosition(0, spawnY + 8, 0);
}
setPos(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
setPosition(x, y, z) {
let width = 0.3;
let height = 0.9;
this.boundingBox = new BoundingBox(
x - width,
y - height,
z - width,
x + width,
y + height,
z + width
);
let w = 0.3;
let h = 0.9;
this.boundingBox = new BoundingBox(x - w, y - h, z - w, x + w, y + h, z + w);
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
// Update position
this.x = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0;
this.y = this.boundingBox.minY;
this.z = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0;
}
turn(motionX, motionY) {
@@ -299,7 +310,7 @@ window.Player = class {
let sneaking = false;
if (Keyboard.isKeyDown("KeyR")) { // R
this.resetPos();
this.respawn();
}
if (Keyboard.isKeyDown("KeyW")) { // W
moveForward++;