make items darker in pause menu
This commit is contained in:
@@ -158,6 +158,9 @@ window.Minecraft = class {
|
||||
this.window.exitFocus();
|
||||
screen.setup(this, this.window.width, this.window.height);
|
||||
}
|
||||
|
||||
// Update items
|
||||
this.itemRenderer.rebuildAllItems();
|
||||
}
|
||||
|
||||
onTick() {
|
||||
|
||||
@@ -252,7 +252,7 @@ window.BlockRenderer = class {
|
||||
}
|
||||
}
|
||||
|
||||
renderGuiBlock(group, block, x, y, size) {
|
||||
renderGuiBlock(group, block, x, y, size, brightness) {
|
||||
this.tessellator.startDrawing();
|
||||
|
||||
let boundingBox = block.getBoundingBox(null, 0, 0, 0);
|
||||
@@ -269,6 +269,9 @@ window.BlockRenderer = class {
|
||||
break;
|
||||
}
|
||||
|
||||
// Change brightness
|
||||
this.tessellator.transformBrightness(brightness);
|
||||
|
||||
// Create mesh
|
||||
let mesh = this.tessellator.draw(group);
|
||||
mesh.geometry.center();
|
||||
|
||||
@@ -44,6 +44,12 @@ window.Tessellator = class {
|
||||
this.colors.push(this.blue);
|
||||
}
|
||||
|
||||
transformBrightness(brightness) {
|
||||
for (let i in this.colors) {
|
||||
this.colors[i] *= brightness;
|
||||
}
|
||||
}
|
||||
|
||||
draw(group) {
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(this.vertices), 3));
|
||||
|
||||
@@ -53,21 +53,35 @@ window.ItemRenderer = class {
|
||||
if (typeof meta === "undefined") {
|
||||
let meta = {};
|
||||
|
||||
// To make the items darker
|
||||
let paused = this.minecraft.isPaused();
|
||||
|
||||
// Render item
|
||||
let group = new THREE.Group();
|
||||
this.minecraft.worldRenderer.blockRenderer.renderGuiBlock(group, block, x, y, 10);
|
||||
this.minecraft.worldRenderer.blockRenderer.renderGuiBlock(group, block, x, y, 10, paused ? 0.5 : 1);
|
||||
this.scene.add(group);
|
||||
|
||||
// Create meta
|
||||
meta.group = group;
|
||||
meta.typeId = block.getId();
|
||||
meta.x = x;
|
||||
meta.y = y;
|
||||
meta.dirty = false;
|
||||
this.items[renderId] = meta;
|
||||
} else {
|
||||
if (meta.typeId !== block.getId() || meta.x !== x || meta.y !== y) {
|
||||
// Check if rendered item has changed
|
||||
if (meta.dirty || meta.typeId !== block.getId() || meta.x !== x || meta.y !== y) {
|
||||
// Rebuild item
|
||||
this.scene.remove(meta.group);
|
||||
delete this.items[renderId];
|
||||
this.renderItemInGui(renderId, block, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rebuildAllItems() {
|
||||
for (let i in this.items) {
|
||||
this.items[i].dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user