implement hotbar

This commit is contained in:
LabyStudio
2022-02-04 12:26:02 +01:00
parent 0cf779936e
commit c2262a43ff
9 changed files with 111 additions and 8 deletions
+18
View File
@@ -39,6 +39,24 @@ window.Gui = class {
stack.restore();
}
renderBlock(stack, texture, block, x, y) {
stack.save();
stack.translate(x + 3, y + 3);
this.renderBlockFace(stack, texture, block, EnumBlockFace.NORTH);
stack.restore();
}
renderBlockFace(stack, texture, block, face) {
// UV Mapping
let textureIndex = block.getTextureForFace(face);
let minU = (textureIndex % 16) / 16.0;
let minV = Math.floor(textureIndex / 16) / 16.0;
stack.save();
this.drawSprite(stack, texture, minU * 256, minV, 16, 16, 0, 0, 16, 16)
stack.restore();
}
static drawSprite(stack, texture, spriteX, spriteY, spriteWidth, spriteHeight, x, y, width, height, alpha = 1.0) {
stack.save();
stack.globalAlpha = alpha;