Skip to content

Commit 80e8ea7

Browse files
committed
Some skybox debug screen changes
1 parent 406fd02 commit 80e8ea7

File tree

17 files changed

+103
-67
lines changed

17 files changed

+103
-67
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ end_of_line = lf
33
charset = utf-8
44
trim_trailing_whitespace = true
55

6-
[*.json]
6+
[{*.json,*.mcmeta}]
77
indent_style = tab
88
indent_size = 4

src/main/java/btw/lowercase/skyboxify/screen/SkyLayerInfoScreen.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,26 @@ protected void init() {
4747
.centered()
4848
.build(this.font));
4949

50-
addLine(Text.builder("Rotate: " + this.skyLayer.rotate()).centered().build(this.font));
51-
addLine(Text.builder("Axis: " + this.skyLayer.axis()).centered().build(this.font));
52-
addLine(Text.builder("Blend: " + this.skyLayer.blend()).centered().build(this.font));
53-
addLine(Text.builder("Speed: " + this.skyLayer.speed()).centered().build(this.font));
54-
addLine(Text.builder("Transition: " + this.skyLayer.transition()).centered().build(this.font));
55-
addLine(Text.builder("Fade: " + this.skyLayer.fade()).centered().build(this.font));
56-
addLine(Text.builder("Loop: " + this.skyLayer.loop()).centered().build(this.font));
57-
addLine(Text.builder("Biomes: " + this.skyLayer.biomes()).centered().build(this.font));
58-
addLine(Text.builder("Heights: " + this.skyLayer.heights()).centered().build(this.font));
59-
addLine(Text.builder("Weather Conditions: " + this.skyLayer.weatherConditions()).centered().build(this.font));
50+
addLine("Rotate: " + this.skyLayer.rotate());
51+
addLine("Axis: " + this.skyLayer.axis());
52+
addLine("Blend: " + this.skyLayer.blend());
53+
addLine("Speed: " + this.skyLayer.speed());
54+
addLine("Transition: " + this.skyLayer.transition());
55+
addLine("Fade: " + this.skyLayer.fade());
56+
addLine("Loop: " + this.skyLayer.loop());
57+
addLine("Biomes: " + this.skyLayer.biomes());
58+
addLine("Heights: " + this.skyLayer.heights());
59+
addLine("Weather Conditions: " + this.skyLayer.weatherConditions());
6060

6161
this.gidgets.add(SimpleButton.builder(CommonComponents.GUI_BACK, button -> this.onClose())
6262
.position((this.width / 2) - (SimpleButton.DEFAULT_WIDTH / 2), this.height - SimpleButton.DEFAULT_HEIGHT - 4)
6363
.build());
6464
}
6565

66-
private void addLine(final Text text) {
67-
text.move(this.width / 2, 12 + (this.font.lineHeight * 3) + ((this.font.lineHeight + 2) * (this.gidgets.size() - 1)));
68-
text.setText(Component.literal(" " + text.getText().getString()));
69-
this.gidgets.add(text);
66+
private void addLine(final String text) {
67+
this.gidgets.add(Text.builder(text)
68+
.centered()
69+
.position(this.width / 2, 12 + (this.font.lineHeight * 3) + ((this.font.lineHeight + 2) * (this.gidgets.size() - 1)))
70+
.build(this.font));
7071
}
7172
}

src/main/java/btw/lowercase/skyboxify/screen/SkyboxListScreen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.minecraft.network.chat.CommonComponents;
3333
import net.minecraft.network.chat.Component;
3434
import net.minecraft.util.ARGB;
35+
import net.minecraft.util.StringUtil;
3536

3637
import java.util.ArrayList;
3738
import java.util.List;
@@ -55,9 +56,8 @@ protected void init() {
5556

5657
final List<Gidget> gidgets = new ArrayList<>();
5758
for (final Skybox skybox : this.skyboxes) {
58-
final Component name = Component.literal(skybox.getWorldKey().location().toString())
59-
.withColor(skybox.isActive() ? ARGB.color(155, 0x00FF00) : ARGB.color(155, 0xFF0000));
60-
gidgets.add(SimpleButton.builder(name,button -> this.minecraft.setScreen(new SkyLayerListScreen(this, skybox))).build());
59+
final Component name = Component.literal(StringUtil.stripColor(skybox.getPackName())).withColor(skybox.isActive() ? ARGB.color(155, 0x00FF00) : ARGB.color(155, 0xFF0000));
60+
gidgets.add(SimpleButton.builder(name, button -> this.minecraft.setScreen(new SkyLayerListScreen(this, skybox))).build());
6161
}
6262

6363
final int pad = 20 + this.font.lineHeight;

src/main/java/btw/lowercase/skyboxify/screen/widget/Gidget.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,17 @@
2424
package btw.lowercase.skyboxify.screen.widget;
2525

2626
import btw.lowercase.skyboxify.screen.widget.components.Box;
27+
import lombok.RequiredArgsConstructor;
2728
import net.minecraft.client.gui.GuiGraphics;
2829
import net.minecraft.resources.ResourceLocation;
2930
import net.minecraft.util.ARGB;
3031

3132
import java.util.HashMap;
3233
import java.util.Map;
3334

35+
@RequiredArgsConstructor
3436
public abstract class Gidget {
35-
private final Box box;
36-
private final Map<ResourceLocation, Object> data;
37-
38-
public Gidget(Box box) {
39-
this.box = box;
40-
this.data = new HashMap<>();
41-
}
37+
protected final Box box;
4238

4339
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) {
4440
this.renderBackground(guiGraphics, mouseX, mouseY);
@@ -77,18 +73,6 @@ public void resize(int width, int height) {
7773
this.box.resize(width, height);
7874
}
7975

80-
public void store(ResourceLocation location, Object data) {
81-
this.data.put(location, data);
82-
}
83-
84-
public boolean contains(ResourceLocation location) {
85-
return this.data.containsKey(location);
86-
}
87-
88-
public <T> T get(ResourceLocation location) {
89-
return (T) this.data.get(location);
90-
}
91-
9276
public Box box() {
9377
return this.box;
9478
}

src/main/java/btw/lowercase/skyboxify/screen/widget/ScrollableList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ScrollableList extends Gidget {
3737
public ScrollableList(List<Gidget> gidgets, int x, int y, int width, int height) {
3838
super(new Box(x, y, width, height));
3939
this.gidgets = gidgets;
40-
this.scrollbar = new Scrollbar(width - Scrollbar.DEFAULT_WIDTH - 8, y, height);
40+
this.scrollbar = new Scrollbar(width - Scrollbar.DEFAULT_WIDTH - 8, y + 1, height - 1);
4141
this.updateGidgetsPosition();
4242
}
4343

src/main/java/btw/lowercase/skyboxify/screen/widget/SimpleButton.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package btw.lowercase.skyboxify.screen.widget;
2525

2626
import btw.lowercase.skyboxify.screen.widget.components.Box;
27+
import com.mojang.blaze3d.platform.cursor.CursorTypes;
2728
import net.minecraft.client.Minecraft;
2829
import net.minecraft.client.gui.GuiGraphics;
2930
import net.minecraft.network.chat.Component;
@@ -42,10 +43,10 @@ public class SimpleButton extends Gidget {
4243
public SimpleButton(Component text, int x, int y, Consumer<? super SimpleButton> onClick) {
4344
super(new Box(x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT));
4445
this.text = Text.builder(text)
45-
.position(this.box().left() + (this.box().width() / 2), this.box().top() + (this.box().height() / 2))
46+
.position(this.box.left() + (this.box.width() / 2), this.box.top() + (this.box.height() / 2))
4647
.aligned(Text.Alignment.BOTH)
4748
.build(Minecraft.getInstance().font);
48-
this.resize(Math.max(this.text.box().width() + DEFAULT_PADDING, DEFAULT_WIDTH), this.box().height());
49+
this.resize(Math.max(this.text.box().width() + DEFAULT_PADDING, DEFAULT_WIDTH), this.box.height());
4950
this.onClick = onClick;
5051
}
5152

@@ -56,8 +57,11 @@ public static Builder builder(final Component text, final Consumer<SimpleButton>
5657
@Override
5758
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) {
5859
super.render(guiGraphics, mouseX, mouseY);
59-
text.setColor(this.box().contains(mouseX, mouseY) ? ARGB.color(255, 0xFFFFA0) : ARGB.color(255, 0xE0E0E0));
60-
text.render(guiGraphics, mouseX, mouseY);
60+
this.text.setColor(this.box().contains(mouseX, mouseY) ? ARGB.color(255, 0xFFFFA0) : ARGB.color(255, 0xE0E0E0));
61+
this.text.render(guiGraphics, mouseX, mouseY);
62+
if (this.box().contains(mouseX, mouseY)) {
63+
guiGraphics.requestCursor(CursorTypes.POINTING_HAND);
64+
}
6165
}
6266

6367
@Override

src/main/java/btw/lowercase/skyboxify/screen/widget/Text.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package btw.lowercase.skyboxify.screen.widget;
2525

2626
import btw.lowercase.skyboxify.screen.widget.components.Box;
27+
import com.mojang.blaze3d.platform.cursor.CursorTypes;
2728
import lombok.Getter;
2829
import lombok.Setter;
2930
import net.minecraft.client.gui.Font;
@@ -74,6 +75,9 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) {
7475
}
7576

7677
guiGraphics.drawString(this.font, this.text, finalX, finalY, this.color, this.shadow);
78+
if (new Box(finalX, finalY, this.box.width(), this.box.height()).contains(mouseX, mouseY)) {
79+
guiGraphics.requestCursor(CursorTypes.IBEAM);
80+
}
7781
}
7882

7983
public Builder builder() {

src/main/java/btw/lowercase/skyboxify/screen/widget/components/Scrollbar.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@
2323

2424
package btw.lowercase.skyboxify.screen.widget.components;
2525

26+
import btw.lowercase.skyboxify.Skyboxify;
2627
import btw.lowercase.skyboxify.screen.widget.Gidget;
28+
import com.mojang.blaze3d.platform.cursor.CursorType;
29+
import com.mojang.blaze3d.platform.cursor.CursorTypes;
2730
import lombok.Getter;
2831
import net.minecraft.client.gui.GuiGraphics;
32+
import net.minecraft.client.renderer.RenderPipelines;
33+
import net.minecraft.resources.ResourceLocation;
2934
import net.minecraft.util.ARGB;
3035

3136
public class Scrollbar extends Gidget {
37+
public static final ResourceLocation BAR_TEXTURE = Skyboxify.locationOrNull("widget/scrollbar/bar");
38+
3239
public static final int DEFAULT_WIDTH = 10;
3340
private final Knob knob;
3441
@Getter
@@ -44,11 +51,14 @@ public Scrollbar(int x, int y, int height) {
4451
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) {
4552
super.render(guiGraphics, mouseX, mouseY);
4653
this.knob.render(guiGraphics, mouseX, mouseY);
54+
if (this.box().contains(mouseX, mouseY) && !this.knob.box().contains(mouseX, mouseY)) {
55+
guiGraphics.requestCursor(CursorTypes.RESIZE_NS);
56+
}
4757
}
4858

4959
@Override
5060
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY) {
51-
guiGraphics.fill(this.box().left(), this.box().top(), this.box().right(), this.box().bottom(), ARGB.color(128, 0x00FF95));
61+
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, BAR_TEXTURE, this.box().left(), this.box().top(), this.box().width(), this.box().height(), ARGB.color(128, 0xFFFFFF));
5262
}
5363

5464
public void setScrollY(double scrollY) {
@@ -65,6 +75,7 @@ public void setScrollY(double scrollY) {
6575
}
6676

6777
private class Knob extends Gidget {
78+
public static final ResourceLocation KNOB_TEXTURE = Skyboxify.locationOrNull("widget/scrollbar/knob");
6879
public static final int DEFAULT_HEIGHT = 30;
6980

7081
public Knob(int x, int y, int height) {
@@ -75,9 +86,17 @@ public void setY(int y) {
7586
this.move(this.box().left(), y);
7687
}
7788

89+
@Override
90+
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY) {
91+
super.render(guiGraphics, mouseX, mouseY);
92+
if (this.box().contains(mouseX, mouseY)) {
93+
guiGraphics.requestCursor(CursorTypes.RESIZE_ALL);
94+
}
95+
}
96+
7897
@Override
7998
public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY) {
80-
guiGraphics.fill(this.box().left(), this.box().top(), this.box().right(), this.box().bottom(), ARGB.color(255, 0xAAFE00));
99+
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, KNOB_TEXTURE, this.box().left(), this.box().top(), this.box().width(), this.box().height());
81100
}
82101
}
83102
}

src/main/java/btw/lowercase/skyboxify/skybox/SkyLayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ public float getPositionBrightness(Level level, float conditionAlpha) {
106106
}
107107

108108
public boolean isActive(long dayTime, int clampedTimeOfDay) {
109-
if (!this.fade.alwaysOn() && CommonUtils.isInTimeInterval(clampedTimeOfDay, this.fade.endFadeOut(), this.fade.startFadeIn())) {
109+
if (!this.fade.alwaysOn() && CommonUtils.isInTimeInterval(clampedTimeOfDay, this.fade.endOut(), this.fade.startIn())) {
110110
return false;
111111
} else if (this.loop.ranges() != null) {
112-
long adjustedTime = dayTime - (long) this.fade.startFadeIn();
112+
long adjustedTime = dayTime - (long) this.fade.startIn();
113113
while (adjustedTime < 0L) {
114114
adjustedTime += 24000L * this.loop.days();
115115
}

src/main/java/btw/lowercase/skyboxify/skybox/Skybox.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939

4040
public class Skybox {
4141
public static final Codec<Skybox> CODEC = RecordCodecBuilder.create(instance -> instance.group(
42+
Codec.STRING.fieldOf("pack").forGetter(Skybox::getPackName),
4243
Level.RESOURCE_KEY_CODEC.fieldOf("world").forGetter(Skybox::getWorldKey),
4344
SkyLayer.CODEC.listOf().fieldOf("layers").forGetter(Skybox::getLayers)
4445
).apply(instance, Skybox::new));
4546

47+
@Getter
48+
private final String packName;
4649
@Getter
4750
private final List<SkyLayer> layers;
4851
@Getter
@@ -51,7 +54,8 @@ public class Skybox {
5154
@Getter
5255
private boolean active = true;
5356

54-
public Skybox(final ResourceKey<@NotNull Level> worldKey, final List<SkyLayer> layers) {
57+
public Skybox(final String packName, final ResourceKey<@NotNull Level> worldKey, final List<SkyLayer> layers) {
58+
this.packName = packName;
5559
this.worldKey = worldKey;
5660
this.layers = layers;
5761
}

0 commit comments

Comments
 (0)