Skip to content

Commit

Permalink
Implement better resource checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ekulxam authored Nov 11, 2024
1 parent 5f2edc3 commit 4913a4f
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import net.minecraft.util.math.RotationAxis;
import org.joml.Vector3f;

import java.io.FileNotFoundException;

public record SpriteBlockEntityRenderer(BlockEntityRendererFactory.Context context) implements BlockEntityRenderer<SpriteBlockEntity> {
private static final Vector3f[] vertices = new Vector3f[] {
new Vector3f(-0.5F, -0.5F, 0.0F),
Expand Down Expand Up @@ -45,11 +43,10 @@ public void render(SpriteBlockEntity entity, float f, MatrixStack matrices, Vert
} else {
TextureManager textureManager = MinecraftClient.getInstance().getTextureManager();
ResourceManager resourceManager = ((TextureManagerAccessor) textureManager).glowcase$getResourceManager();
try {
resourceManager.getResourceOrThrow(identifier);
} catch (FileNotFoundException ignored) {
/* if the texture (file) does not exist, just replace it.
this happens a lot when edit a sprite block, so I'm adding it to avoid log spam
if (resourceManager.getResource(identifier).isEmpty()) {
/*
If the texture (file) does not exist, just replace it.
This happens a lot when editing a sprite block, so I'm adding it to avoid log spam
- SkyNotTheLimit
*/
identifier = Glowcase.id("textures/sprite/invalid.png");
Expand All @@ -66,8 +63,7 @@ public void render(SpriteBlockEntity entity, float f, MatrixStack matrices, Vert
}

private void vertex(
MatrixStack.Entry matrix, VertexConsumer vertexConsumer, Vector3f vertex, float u, float v,
int color) {
MatrixStack.Entry matrix, VertexConsumer vertexConsumer, Vector3f vertex, float u, float v, int color) {
vertexConsumer.vertex(matrix, vertex.x(), vertex.y(), vertex.z())
.color(color)
.texture(u, v)
Expand Down

0 comments on commit 4913a4f

Please sign in to comment.