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
@@ -165,19 +165,21 @@ window.BlockRenderer = class {
let distortZ = 0;
// Attach torch at wall
switch (world.getBlockDataAt(x, y, z)) {
case 1:
distortX = -0.2;
break;
case 2:
distortX = 0.2;
break;
case 3:
distortZ = -0.2;
break;
case 4:
distortZ = 0.2;
break;
if (world != null) {
switch (world.getBlockDataAt(x, y, z)) {
case 1:
distortX = -0.2;
break;
case 2:
distortX = 0.2;
break;
case 3:
distortZ = -0.2;
break;
case 4:
distortZ = 0.2;
break;
}
}
// Model type
@@ -252,6 +254,33 @@ window.BlockRenderer = class {
}
}
renderBlockInHand(group, block, brightness) {
this.tessellator.startDrawing();
// Change brightness
this.tessellator.transformBrightness(brightness);
// Render block
this.renderBlock(null, block, 0, 0, 0);
// Create mesh
let mesh = this.tessellator.draw(group);
mesh.geometry.center();
// Relative position
mesh.position.x = 0;
mesh.position.y = 9;
mesh.position.z = -5;
// Rotation
mesh.rotation.y = Math.PI / 4;
// Scale
mesh.scale.x = 6;
mesh.scale.y = -6;
mesh.scale.z = 6;
}
renderGuiBlock(group, block, x, y, size, brightness) {
this.tessellator.startDrawing();