From c46ae91e99021c92469455a1564b12d88e1f6127 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 28 Jan 2023 20:29:15 +0100 Subject: [PATCH] Created icon sheet. --- .../requios/effortlessbuilding/AllIcons.java | 144 ++++++++++++++++++ .../create/foundation/gui/AllIcons.java | 2 +- .../gui/buildmodifier/ArrayEntry.java | 21 +-- .../buildmodifier/ModifiersScreenList.java | 5 + .../textures/gui/create_icons.png | Bin 0 -> 2048 bytes .../effortlessbuilding/textures/gui/icons.png | Bin 2048 -> 4207 bytes 6 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 src/main/java/nl/requios/effortlessbuilding/AllIcons.java create mode 100644 src/main/resources/assets/effortlessbuilding/textures/gui/create_icons.png diff --git a/src/main/java/nl/requios/effortlessbuilding/AllIcons.java b/src/main/java/nl/requios/effortlessbuilding/AllIcons.java new file mode 100644 index 0000000..3805ed8 --- /dev/null +++ b/src/main/java/nl/requios/effortlessbuilding/AllIcons.java @@ -0,0 +1,144 @@ +package nl.requios.effortlessbuilding; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Matrix4f; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import nl.requios.effortlessbuilding.create.Create; +import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement; +import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement; +import nl.requios.effortlessbuilding.create.foundation.utility.Color; + +public class AllIcons implements ScreenElement { + + public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png"); + public static final int ICON_ATLAS_SIZE = 256; + private static int x = 0, y = -1; + private int iconX; + private int iconY; + + public static final AllIcons + I_SETTINGS = newRow(), + I_UNDO = next(), + I_REDO = next(), + I_REPLACE = next(); + + public static final AllIcons + I_DISABLE = newRow(), + I_SINGLE = next(), + I_LINE = next(), + I_WALL = next(), + I_FLOOR = next(), + I_CUBE = next(), + I_DIAGONAL_LINE = next(), + I_DIAGONAL_WALL = next(), + I_SLOPED_FLOOR = next(), + I_CIRCLE = next(), + I_CYLINDER = next(), + I_SPHERE = next(), + I_PYRAMID = next(), + I_CONE = next(), + I_DOME = next(); + + public static final AllIcons + I_NORMAL_SPEED = newRow(), + I_FAST_SPEED = next(), + I_FILLED = next(), + I_HOLLOW = next(), + I_CUBE_FILLED = next(), + I_CUBE_HOLLOW = next(), + I_CUBE_SKELETON = next(), + I_SHORT_EDGE = next(), + I_LONG_EDGE = next(), + I_CIRCLE_START_CORNER = next(), + I_CIRCLE_START_CENTER = next(), + I_THICKNESS_1 = next(), + I_THICKNESS_3 = next(), + I_THICKNESS_5 = next(); + + public static final AllIcons + I_PLAYER = newRow(), + I_BLOCK_CENTER = next(), + I_BLOCK_CORNER = next(), + I_HIDE_LINES = next(), + I_SHOW_LINES = next(), + I_HIDE_AREAS = next(), + I_SHOW_AREAS = next(); + + + public AllIcons(int x, int y) { + iconX = x * 16; + iconY = y * 16; + } + + private static AllIcons next() { + return new AllIcons(++x, y); + } + + private static AllIcons newRow() { + return new AllIcons(x = 0, ++y); + } + + @OnlyIn(Dist.CLIENT) + public void bind() { + RenderSystem.setShaderTexture(0, ICON_ATLAS); + } + + @OnlyIn(Dist.CLIENT) + @Override + public void render(PoseStack matrixStack, int x, int y) { + bind(); + GuiComponent.blit(matrixStack, x, y, 0, iconX, iconY, 16, 16, 256, 256); + } + + @OnlyIn(Dist.CLIENT) + public void render(PoseStack matrixStack, int x, int y, GuiComponent component) { + bind(); + component.blit(matrixStack, x, y, iconX, iconY, 16, 16); + } + + @OnlyIn(Dist.CLIENT) + public void render(PoseStack ms, MultiBufferSource buffer, int color) { + VertexConsumer builder = buffer.getBuffer(RenderType.textSeeThrough(ICON_ATLAS)); + Matrix4f matrix = ms.last().pose(); + Color rgb = new Color(color); + int light = LightTexture.FULL_BRIGHT; + + Vec3 vec1 = new Vec3(0, 0, 0); + Vec3 vec2 = new Vec3(0, 1, 0); + Vec3 vec3 = new Vec3(1, 1, 0); + Vec3 vec4 = new Vec3(1, 0, 0); + + float u1 = iconX * 1f / ICON_ATLAS_SIZE; + float u2 = (iconX + 16) * 1f / ICON_ATLAS_SIZE; + float v1 = iconY * 1f / ICON_ATLAS_SIZE; + float v2 = (iconY + 16) * 1f / ICON_ATLAS_SIZE; + + vertex(builder, matrix, vec1, rgb, u1, v1, light); + vertex(builder, matrix, vec2, rgb, u1, v2, light); + vertex(builder, matrix, vec3, rgb, u2, v2, light); + vertex(builder, matrix, vec4, rgb, u2, v1, light); + } + + @OnlyIn(Dist.CLIENT) + private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) { + builder.vertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z) + .color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255) + .uv(u, v) + .uv2(light) + .endVertex(); + } + + @OnlyIn(Dist.CLIENT) + public DelegatedStencilElement asStencil() { + return new DelegatedStencilElement().withStencilRenderer((ms, w, h, alpha) -> this.render(ms, 0, 0)).withBounds(16, 16); + } +} diff --git a/src/main/java/nl/requios/effortlessbuilding/create/foundation/gui/AllIcons.java b/src/main/java/nl/requios/effortlessbuilding/create/foundation/gui/AllIcons.java index f97f8fa..3b14501 100644 --- a/src/main/java/nl/requios/effortlessbuilding/create/foundation/gui/AllIcons.java +++ b/src/main/java/nl/requios/effortlessbuilding/create/foundation/gui/AllIcons.java @@ -19,7 +19,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class AllIcons implements ScreenElement { - public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png"); + public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/create_icons.png"); public static final int ICON_ATLAS_SIZE = 256; private static int x = 0, y = -1; diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArrayEntry.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArrayEntry.java index 7ef3f81..c113e02 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArrayEntry.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ArrayEntry.java @@ -17,6 +17,7 @@ import nl.requios.effortlessbuilding.create.foundation.gui.AbstractSimiScreen; import nl.requios.effortlessbuilding.create.foundation.gui.widget.Label; import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput; import nl.requios.effortlessbuilding.create.foundation.utility.Components; +import nl.requios.effortlessbuilding.create.foundation.utility.FontHelper; import nl.requios.effortlessbuilding.gui.elements.GuiCheckBoxFixed; import nl.requios.effortlessbuilding.gui.elements.GuiNumberField; import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane; @@ -100,31 +101,31 @@ public class ArrayEntry extends BaseModifierEntry { //draw offset labels for (int i = 0; i < 3; i++) { - offsetLabels.get(i).x = x + 75 + 20 * i; - offsetLabels.get(i).y = y + 24; + offsetLabels.get(i).x = x + 65 + 20 * i - getFont().width(offsetLabels.get(i).text) / 2; + offsetLabels.get(i).y = y + 23; offsetLabels.get(i).render(ms, mouseX, mouseY, partialTicks); } //draw offset inputs for (int i = 0; i < 3; i++) { - offsetInputs.get(i).x = x + 75 + 20 * i; - offsetInputs.get(i).y = y + 24; + offsetInputs.get(i).x = x + 65 + 20 * i; + offsetInputs.get(i).y = y + 23; offsetInputs.get(i).render(ms, mouseX, mouseY, partialTicks); } //draw count label - countLabel.x = x + 140; - countLabel.y = y + 24; + countLabel.x = x + 65; + countLabel.y = y + 45; countLabel.render(ms, mouseX, mouseY, partialTicks); //draw count input - countInput.x = x + 140; - countInput.y = y + 24; + countInput.x = x + 65; + countInput.y = y + 45; countInput.render(ms, mouseX, mouseY, partialTicks); //draw reach label reachLabel.x = x + width - 125; - reachLabel.y = y + 40; + reachLabel.y = y + 23; reachLabel.render(ms, mouseX, mouseY, partialTicks); } @@ -135,7 +136,7 @@ public class ArrayEntry extends BaseModifierEntry { int currentReach = Math.max(-1, getArrayReach()); int maxReach = ReachHelper.getMaxReach(Minecraft.getInstance().player); ChatFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? ChatFormatting.GRAY : ChatFormatting.RED; - var reachText = "Reach: " + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach; + var reachText = "" + reachColor + currentReach + ChatFormatting.GRAY + "/" + ChatFormatting.GRAY + maxReach; reachLabel.text = Component.literal(reachText); } diff --git a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifiersScreenList.java b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifiersScreenList.java index 31ba404..143fea1 100644 --- a/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifiersScreenList.java +++ b/src/main/java/nl/requios/effortlessbuilding/gui/buildmodifier/ModifiersScreenList.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.network.chat.Component; @@ -150,5 +151,9 @@ public class ModifiersScreenList extends ObjectSelectionListgwv{<>lhy;?mO6%*@QOv9XqxmX3~&fPjE~eSLR#cTP@DOiWB5F8iDS0004WQchC< zK<3zH000M1Nkl{efKlyOOxE%kxB<`jrY0Idod72Yd`q z3Q0N*UKESKahD%5U{IfUlZ4)OEG+{PNJhTVE>Zzl(w%Fa(51vZGZxEuT#;M@q{Yb0 z3AjpqEGr;u1rGEjQ7TeU%IBivMcc5Sx7-tOhk-y^pfb{pRVK=qEQ<1tkyqFRM9f_6 zav0Q$a9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