Resize verification cube renders based on verification level

This commit is contained in:
ForestOfLight
2025-06-05 17:57:15 -07:00
Unverified
parent 0fc263157a
commit 709eccef8c
4 changed files with 29 additions and 12 deletions
@@ -15,33 +15,37 @@ export class BlockVerificationLevelRender {
} }
renderBlock() { renderBlock() {
for (const particleLocation of this.getParticleLocations()) { const sizeScalar = this.verificationLevelToSizeScalar();
for (const particle of this.getBlockParticles(sizeScalar)) {
const color = this.getRGBAMolang(); const color = this.getRGBAMolang();
if (!color) if (!color)
return; return;
color.setFloat("lifetime", this.lifetimeSeconds); color.setFloat("lifetime", this.lifetimeSeconds);
color.setFloat("width", 0.5*sizeScalar);
color.setFloat("height", 0.5*sizeScalar);
try { try {
this.dimension.spawnParticle(particleLocation.particleType, particleLocation.location, color); this.dimension.spawnParticle(particle.particleType, particle.location, color);
} catch { } catch {
/* pass */ /* pass */
} }
} }
} }
getParticleLocations() { getBlockParticles(sizeScalar = 1) {
const bottomFace = new Vector(0.5, 0, 0.5); const bottomFace = new Vector(0.5, 0, 0.5);
const topFace = new Vector(0.5, 1, 0.5); const topFace = new Vector(0.5, 1, 0.5);
const leftFace = new Vector(1, 0.5, 0.5); const leftFace = new Vector(1, 0.5, 0.5);
const rightFace = new Vector(0, 0.5, 0.5); const rightFace = new Vector(0, 0.5, 0.5);
const frontFace = new Vector(0.5, 0.5, 1); const frontFace = new Vector(0.5, 0.5, 1);
const backFace = new Vector(0.5, 0.5, 0); const backFace = new Vector(0.5, 0.5, 0);
const center = new Vector(0.5, 0.5, 0.5);
return [ return [
{ particleType: "construct:blockoverlay_xz", location: this.location.add(topFace) }, { particleType: "construct:blockoverlay_xz", location: this.location.add(center).add(topFace.subtract(center).multiply(sizeScalar)) },
{ particleType: "construct:blockoverlay_xz", location: this.location.add(bottomFace) }, { particleType: "construct:blockoverlay_xz", location: this.location.add(center).add(bottomFace.subtract(center).multiply(sizeScalar)) },
{ particleType: "construct:blockoverlay_yz", location: this.location.add(leftFace) }, { particleType: "construct:blockoverlay_yz", location: this.location.add(center).add(leftFace.subtract(center).multiply(sizeScalar)) },
{ particleType: "construct:blockoverlay_yz", location: this.location.add(rightFace) }, { particleType: "construct:blockoverlay_yz", location: this.location.add(center).add(rightFace.subtract(center).multiply(sizeScalar)) },
{ particleType: "construct:blockoverlay_xy", location: this.location.add(frontFace) }, { particleType: "construct:blockoverlay_xy", location: this.location.add(center).add(frontFace.subtract(center).multiply(sizeScalar)) },
{ particleType: "construct:blockoverlay_xy", location: this.location.add(backFace) } { particleType: "construct:blockoverlay_xy", location: this.location.add(center).add(backFace.subtract(center).multiply(sizeScalar)) }
]; ];
} }
@@ -66,4 +70,17 @@ export class BlockVerificationLevelRender {
return void 0; return void 0;
} }
} }
verificationLevelToSizeScalar() {
switch (this.verificationLevel) {
case BlockVerificationLevel.NoMatch:
return 1.01;
case BlockVerificationLevel.TypeMatch:
return 1.01;
case BlockVerificationLevel.Missing:
return 0.90;
default:
return 1.00;
}
}
} }
@@ -20,7 +20,7 @@
"max_lifetime": "variable.lifetime" "max_lifetime": "variable.lifetime"
}, },
"minecraft:particle_appearance_billboard": { "minecraft:particle_appearance_billboard": {
"size": [0.5, 0.5], "size": ["variable.width", "variable.height"],
"facing_camera_mode": "emitter_transform_xy" "facing_camera_mode": "emitter_transform_xy"
}, },
"minecraft:particle_appearance_tinting": { "minecraft:particle_appearance_tinting": {
@@ -20,7 +20,7 @@
"max_lifetime": "variable.lifetime" "max_lifetime": "variable.lifetime"
}, },
"minecraft:particle_appearance_billboard": { "minecraft:particle_appearance_billboard": {
"size": [0.5, 0.5], "size": ["variable.width", "variable.height"],
"facing_camera_mode": "emitter_transform_xz" "facing_camera_mode": "emitter_transform_xz"
}, },
"minecraft:particle_appearance_tinting": { "minecraft:particle_appearance_tinting": {
@@ -20,7 +20,7 @@
"max_lifetime": "variable.lifetime" "max_lifetime": "variable.lifetime"
}, },
"minecraft:particle_appearance_billboard": { "minecraft:particle_appearance_billboard": {
"size": [0.5, 0.5], "size": ["variable.width", "variable.height"],
"facing_camera_mode": "emitter_transform_yz" "facing_camera_mode": "emitter_transform_yz"
}, },
"minecraft:particle_appearance_tinting": { "minecraft:particle_appearance_tinting": {