implement block in hand

(cherry picked from commit 75fd4edd9f67b2cbf5abffc1ea417920106b1353)
This commit is contained in:
LabyStudio
2022-04-14 20:50:18 +02:00
parent 96b287bedc
commit 5c47dd6599
13 changed files with 145 additions and 68 deletions
@@ -5,6 +5,8 @@ window.PlayerEntity = class extends EntityLiving {
constructor(minecraft, world) {
super(minecraft, world);
this.inventory = new Inventory();
this.collision = false;
this.jumpMovementFactor = 0.02;
@@ -124,7 +126,12 @@ window.PlayerEntity = class extends EntityLiving {
}
isHeadInWater() {
return this.world.getBlockAt(this.getBlockPosX(), Math.floor(this.y + this.getEyeHeight() + 0.12), this.getBlockPosZ()) === Block.WATER.getId();
let cameraPosition = this.world.minecraft.worldRenderer.camera.position;
return this.world.getBlockAt(
Math.floor(cameraPosition.x),
Math.floor(cameraPosition.y + 0.12),
Math.floor(cameraPosition.z)
) === Block.WATER.getId()
}
jump() {