Skip to content

Commit

Permalink
Fixed edge editor gui text alignment, Fixes #55
Browse files Browse the repository at this point in the history
Localized facing direction in the edge editor gui.
  • Loading branch information
Flanks255 committed Jan 2, 2025
1 parent 85e325d commit 6afba0a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.5.1+mc1.21.1
* Localized the facing direction in the Edge light editor gui.
* Merged updated Japanese translation.

# 1.5.0+mc1.21.1
* Added color variations to Bulbs, Rods, Fixtures, Columns and Edge lights.
* Added CTM textures for Illuminant Blocks in a disabled by default built-in optional resource pack.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ publishMods {
file = jar.archiveFile
changelog = createChangelog().trim()
modLoaders.add("NeoForge")
type = BETA
type = STABLE
additionalFiles.from sourcesJar.archiveFile

curseforge {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mod_version=1.5.0
mod_version=1.5.1
minecraft_version=1.21.1
loader_version=[4,)
neo_version=21.1.89
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/com/flanks255/simplylight/gui/EdgeEditorGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -61,10 +62,28 @@ public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, flo
Player player = Minecraft.getInstance().player;
if (player == null)
return;
Component string = Component.translatable("simplylight.gui.facing");
int x = guiLeft + xSize - font.width(string) - 4;
guiGraphics.drawString(font, string, x, guiTop + 8, 0x404040, false);
guiGraphics.drawString(font, player.getNearestViewDirection().toString(), x, guiTop + 18, 0x404040, false);
Component facing = Component.translatable("simplylight.gui.facing");
Component direction = getDirectionText(getNearestHorizontal(player));
int x = (guiLeft + xSize - 4) - Math.max(font.width(facing), font.width(direction));
guiGraphics.drawString(font, facing, x, guiTop + 8, 0x404040, false);
guiGraphics.drawString(font, direction, x, guiTop + 18, 0x404040, false);
}

private Direction getNearestHorizontal(Player player) {
for (Direction direction : Direction.orderedByNearest(player)) {
if (direction.getAxis().isHorizontal())
return direction;
}
return Direction.NORTH;
}

private Component getDirectionText(Direction direction) {
return switch(direction) {
case EAST -> Component.translatable("simplylight.gui.east");
case SOUTH -> Component.translatable("simplylight.gui.south");
case WEST -> Component.translatable("simplylight.gui.west");
default -> Component.translatable("simplylight.gui.north");
};
}

private void button(Button button) {
Expand Down

0 comments on commit 6afba0a

Please sign in to comment.