use 2d items for hotbar

This commit is contained in:
LabyStudio
2022-02-04 22:45:12 +01:00
parent 317a70dfd4
commit 28b761d1be
2 changed files with 11 additions and 2 deletions
@@ -38,12 +38,19 @@ window.IngameOverlay = class extends Gui {
let typeId = this.minecraft.inventory.getItemInSlot(i); let typeId = this.minecraft.inventory.getItemInSlot(i);
if (typeId !== 0) { if (typeId !== 0) {
this.renderBlock( /*this.renderBlock(
stack, stack,
this.textureTerrain, Block.getById(typeId), this.textureTerrain, Block.getById(typeId),
x + i * 20 + 11, x + i * 20 + 11,
y + 9 y + 9
); );*/
// UV Mapping
let textureIndex = Block.getById(typeId).getTextureForFace(EnumBlockFace.NORTH);
let minU = (textureIndex % 16) / 16.0;
let minV = Math.floor(textureIndex / 16) / 16.0;
this.drawSprite(stack, this.textureTerrain, minU * 256, minV, 16, 16, x + 3, y + 3, 16, 16)
} }
} }
} }
+2
View File
@@ -4,10 +4,12 @@ window.Keyboard = class {
static create() { static create() {
window.addEventListener('keydown', function (event) { window.addEventListener('keydown', function (event) {
event.preventDefault();
Keyboard.state[event.code] = true; Keyboard.state[event.code] = true;
//console.log("Key " + event.code + " down"); //console.log("Key " + event.code + " down");
}); });
window.addEventListener('keyup', function (event) { window.addEventListener('keyup', function (event) {
event.preventDefault();
delete Keyboard.state[event.code]; delete Keyboard.state[event.code];
//console.log("Key " + event.code + " up"); //console.log("Key " + event.code + " up");
}); });