From de635bb709691bb768699e528047f9d7cf3b2ce6 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Tue, 5 Nov 2024 20:43:43 +0100 Subject: [PATCH] Remove unused vertex attributes from laser --- .../actuallyadditions/mod/util/AssetUtil.java | 77 ++++++++----------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index ce18c7b3d..c770ee83a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -26,7 +26,6 @@ import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -254,35 +253,29 @@ public final class AssetUtil { Matrix4f matrix = matrixStack.last().pose(); - TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(FORGE_WHITE); - float minU = sprite.getU0(); - float maxU = sprite.getU1(); - float minV = sprite.getV0(); - float maxV = sprite.getV1(); - //Draw laser tube faces for (int i = 1; i < 4; i++) { float width = beamWidth * (i / 4.0f); //top - builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap); - builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setLight(lightmap); //bottom - builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap); - builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); + builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap); //left - builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setLight(lightmap); //right - builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setLight(lightmap); + builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setLight(lightmap); } @@ -336,35 +329,29 @@ public final class AssetUtil { RenderSystem.setShader(GameRenderer::getPositionColorShader); - TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(FORGE_WHITE); - float minU = sprite.getU0(); - float maxU = sprite.getU1(); - float minV = sprite.getV0(); - float maxV = sprite.getV1(); - //Draw laser tube faces for (int i = 1; i < 4; i++) { float width = beamWidth * (i / 4.0f); //top - builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap); - builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a); + builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a); //bottom - builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap); - builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); + builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a); + builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a); + builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a); //left - builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a); + builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a); //right - builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap); - builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); - builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap); + builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a); + builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a); + builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a); } matrixStack.popPose();