Skip to content

Commit 7b288fb

Browse files
authored
Merge pull request SkyblockerMod#713 from kevinthegreat1/waypoint
Waypoints
2 parents abd2332 + bd11cc0 commit 7b288fb

24 files changed

+1278
-28
lines changed

Diff for: src/main/java/de/hysky/skyblocker/SkyblockerMod.java

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual;
4848
import de.hysky.skyblocker.skyblock.waypoint.OrderedWaypoints;
4949
import de.hysky.skyblocker.skyblock.waypoint.Relics;
50+
import de.hysky.skyblocker.skyblock.waypoint.Waypoints;
5051
import de.hysky.skyblocker.utils.*;
5152
import de.hysky.skyblocker.utils.chat.ChatMessageListener;
5253
import de.hysky.skyblocker.utils.discord.DiscordRPCManager;
@@ -113,6 +114,7 @@ public void onInitializeClient() {
113114
ItemTooltip.init();
114115
AccessoriesHelper.init();
115116
WikiLookup.init();
117+
Waypoints.init();
116118
FairySouls.init();
117119
Relics.init();
118120
MythologicalRitual.init();

Diff for: src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import de.hysky.skyblocker.config.ConfigUtils;
44
import de.hysky.skyblocker.config.SkyblockerConfig;
55
import de.hysky.skyblocker.skyblock.fancybars.StatusBarsConfigScreen;
6+
import de.hysky.skyblocker.skyblock.waypoint.WaypointsScreen;
67
import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen;
78
import de.hysky.skyblocker.config.configs.UIAndVisualsConfig;
89
import de.hysky.skyblocker.utils.waypoint.Waypoint;
@@ -226,12 +227,17 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
226227
.option(Option.<Waypoint.Type>createBuilder()
227228
.name(Text.translatable("skyblocker.config.uiAndVisuals.waypoints.waypointType"))
228229
.description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.waypoints.waypointType.@Tooltip"),
229-
Text.translatable("skyblocker.config.uiAndVisuals.waypoints.waypointType")))
230+
Text.translatable("skyblocker.config.uiAndVisuals.waypoints.waypointType.generalNote")))
230231
.binding(defaults.uiAndVisuals.waypoints.waypointType,
231232
() -> config.uiAndVisuals.waypoints.waypointType,
232233
newValue -> config.uiAndVisuals.waypoints.waypointType = newValue)
233234
.controller(ConfigUtils::createEnumCyclingListController)
234235
.build())
236+
.option(ButtonOption.createBuilder()
237+
.name(Text.translatable("skyblocker.waypoints.config"))
238+
.text(Text.translatable("text.skyblocker.open"))
239+
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new WaypointsScreen(screen)))
240+
.build())
235241
.build())
236242

237243
//Teleport Overlays
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package de.hysky.skyblocker.mixins.accessors;
2+
3+
import net.minecraft.client.gui.widget.CheckboxWidget;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.gen.Accessor;
6+
7+
@Mixin(CheckboxWidget.class)
8+
public interface CheckboxWidgetAccessor {
9+
@Accessor
10+
void setChecked(boolean checked);
11+
}

Diff for: src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/Room.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private void addCustomWaypoint(SecretWaypoint relativeWaypoint) {
242242
protected void removeCustomWaypoint(CommandContext<FabricClientCommandSource> context, BlockPos pos) {
243243
SecretWaypoint waypoint = removeCustomWaypoint(pos);
244244
if (waypoint != null) {
245-
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.stringifiedTranslatable("skyblocker.dungeons.secrets.customWaypointRemoved", pos.getX(), pos.getY(), pos.getZ(), name, waypoint.secretIndex, waypoint.category, waypoint.name)));
245+
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.dungeons.secrets.customWaypointRemoved", pos.getX(), pos.getY(), pos.getZ(), name, waypoint.secretIndex, waypoint.category.asString(), waypoint.getName())));
246246
} else {
247247
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.dungeons.secrets.customWaypointNotFound", pos.getX(), pos.getY(), pos.getZ(), name)));
248248
}

Diff for: src/main/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypoint.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import com.mojang.serialization.Codec;
66
import com.mojang.serialization.JsonOps;
77
import com.mojang.serialization.codecs.RecordCodecBuilder;
8-
import de.hysky.skyblocker.config.SkyblockerConfig;
98
import de.hysky.skyblocker.config.SkyblockerConfigManager;
109
import de.hysky.skyblocker.config.configs.DungeonsConfig;
1110
import de.hysky.skyblocker.utils.render.RenderHelper;
11+
import de.hysky.skyblocker.utils.waypoint.NamedWaypoint;
1212
import de.hysky.skyblocker.utils.waypoint.Waypoint;
1313
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
1414
import net.minecraft.client.MinecraftClient;
@@ -29,7 +29,7 @@
2929
import java.util.function.Supplier;
3030
import java.util.function.ToDoubleFunction;
3131

32-
public class SecretWaypoint extends Waypoint {
32+
public class SecretWaypoint extends NamedWaypoint {
3333
private static final Logger LOGGER = LoggerFactory.getLogger(SecretWaypoint.class);
3434
public static final Codec<SecretWaypoint> CODEC = RecordCodecBuilder.create(instance -> instance.group(
3535
Codec.INT.fieldOf("secretIndex").forGetter(secretWaypoint -> secretWaypoint.secretIndex),
@@ -43,8 +43,6 @@ public class SecretWaypoint extends Waypoint {
4343
static final Supplier<Type> TYPE_SUPPLIER = () -> CONFIG.get().waypointType;
4444
final int secretIndex;
4545
final Category category;
46-
final Text name;
47-
private final Vec3d centerPos;
4846

4947
SecretWaypoint(int secretIndex, JsonObject waypoint, String name, BlockPos pos) {
5048
this(secretIndex, Category.get(waypoint), name, pos);
@@ -55,11 +53,9 @@ public class SecretWaypoint extends Waypoint {
5553
}
5654

5755
SecretWaypoint(int secretIndex, Category category, Text name, BlockPos pos) {
58-
super(pos, TYPE_SUPPLIER, category.colorComponents);
56+
super(pos, name, TYPE_SUPPLIER, category.colorComponents);
5957
this.secretIndex = secretIndex;
6058
this.category = category;
61-
this.name = name;
62-
this.centerPos = pos.toCenterPos();
6359
}
6460

6561
static ToDoubleFunction<SecretWaypoint> getSquaredDistanceToFunction(Entity entity) {
@@ -96,6 +92,11 @@ public boolean equals(Object obj) {
9692
return super.equals(obj) || obj instanceof SecretWaypoint other && secretIndex == other.secretIndex && category == other.category && name.equals(other.name) && pos.equals(other.pos);
9793
}
9894

95+
@Override
96+
protected boolean shouldRenderName() {
97+
return CONFIG.get().showSecretText;
98+
}
99+
99100
/**
100101
* Renders the secret waypoint, including a waypoint through {@link Waypoint#render(WorldRenderContext)}, the name, and the distance from the player.
101102
*/
@@ -106,7 +107,6 @@ public void render(WorldRenderContext context) {
106107

107108
if (CONFIG.get().showSecretText) {
108109
Vec3d posUp = centerPos.add(0, 1, 0);
109-
RenderHelper.renderText(context, name, posUp, true);
110110
double distance = context.camera().getPos().distanceTo(centerPos);
111111
RenderHelper.renderText(context, Text.literal(Math.round(distance) + "m").formatted(Formatting.YELLOW), posUp, 1, MinecraftClient.getInstance().textRenderer.fontHeight + 1, true);
112112
}

Diff for: src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package de.hysky.skyblocker.skyblock.shortcut;
22

3+
import de.hysky.skyblocker.debug.Debug;
34
import net.minecraft.client.MinecraftClient;
45
import net.minecraft.client.gui.DrawContext;
56
import net.minecraft.client.gui.Element;
@@ -76,6 +77,11 @@ protected void updatePositions() {
7677
}
7778
}
7879

80+
@Override
81+
protected boolean isSelectedEntry(int index) {
82+
return Debug.debugEnabled() ? Objects.equals(getSelectedOrNull(), children().get(index)) : super.isSelectedEntry(index);
83+
}
84+
7985
@Override
8086
protected boolean removeEntry(AbstractShortcutEntry entry) {
8187
return super.removeEntry(entry);

Diff for: src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigScreen.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import net.minecraft.text.Text;
1212

1313
public class ShortcutsConfigScreen extends Screen {
14-
1514
private ShortcutsConfigListWidget shortcutsConfigListWidget;
1615
private ButtonWidget buttonDelete;
1716
private ButtonWidget buttonNew;
@@ -41,14 +40,14 @@ protected void init() {
4140
shortcutsConfigListWidget.setDimensions(width, height - 96);
4241
shortcutsConfigListWidget.updatePositions();
4342
} else {
44-
shortcutsConfigListWidget = new ShortcutsConfigListWidget(client, this, width, height - 96, 32, 25);
43+
shortcutsConfigListWidget = new ShortcutsConfigListWidget(client, this, width, height - 96, 32, 24);
4544
initialized = true;
4645
}
4746
addDrawableChild(shortcutsConfigListWidget);
4847
GridWidget gridWidget = new GridWidget();
4948
gridWidget.getMainPositioner().marginX(5).marginY(2);
5049
GridWidget.Adder adder = gridWidget.createAdder(2);
51-
buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.delete"), button -> {
50+
buttonDelete = ButtonWidget.builder(Text.translatable("selectServer.deleteButton"), button -> {
5251
if (client != null && shortcutsConfigListWidget.getSelectedOrNull() instanceof ShortcutsConfigListWidget.ShortcutEntry shortcutEntry) {
5352
scrollAmount = shortcutsConfigListWidget.getScrollAmount();
5453
client.setScreen(new ConfirmScreen(this::deleteEntry, Text.translatable("skyblocker.shortcuts.deleteQuestion"), Text.stringifiedTranslatable("skyblocker.shortcuts.deleteWarning", shortcutEntry), Text.translatable("selectServer.deleteButton"), ScreenTexts.CANCEL));
@@ -57,16 +56,10 @@ protected void init() {
5756
adder.add(buttonDelete);
5857
buttonNew = ButtonWidget.builder(Text.translatable("skyblocker.shortcuts.new"), buttonNew -> shortcutsConfigListWidget.addShortcutAfterSelected()).build();
5958
adder.add(buttonNew);
60-
adder.add(ButtonWidget.builder(ScreenTexts.CANCEL, button -> {
61-
if (client != null) {
62-
close();
63-
}
64-
}).build());
59+
adder.add(ButtonWidget.builder(ScreenTexts.CANCEL, button -> close()).build());
6560
buttonDone = ButtonWidget.builder(ScreenTexts.DONE, button -> {
6661
shortcutsConfigListWidget.saveShortcuts();
67-
if (client != null) {
68-
close();
69-
}
62+
close();
7063
}).tooltip(Tooltip.of(Text.translatable("skyblocker.shortcuts.commandSuggestionTooltip"))).build();
7164
adder.add(buttonDone);
7265
gridWidget.refreshPositions();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package de.hysky.skyblocker.skyblock.waypoint;
2+
3+
import com.google.common.collect.Multimap;
4+
import com.google.common.collect.MultimapBuilder;
5+
import de.hysky.skyblocker.utils.Location;
6+
import de.hysky.skyblocker.utils.Utils;
7+
import de.hysky.skyblocker.utils.waypoint.NamedWaypoint;
8+
import de.hysky.skyblocker.utils.waypoint.WaypointCategory;
9+
import net.minecraft.client.gui.screen.Screen;
10+
import net.minecraft.text.Text;
11+
12+
import java.util.Arrays;
13+
14+
public abstract class AbstractWaypointsScreen<T extends Screen> extends Screen {
15+
protected final T parent;
16+
protected final Multimap<String, WaypointCategory> waypoints;
17+
protected String island;
18+
protected WaypointsListWidget waypointsListWidget;
19+
protected DropdownWidget<Location> islandWidget;
20+
21+
public AbstractWaypointsScreen(Text title, T parent) {
22+
this(title, parent, MultimapBuilder.hashKeys().arrayListValues().build());
23+
}
24+
25+
public AbstractWaypointsScreen(Text title, T parent, Multimap<String, WaypointCategory> waypoints) {
26+
this(title, parent, waypoints, Utils.getLocationRaw());
27+
}
28+
29+
public AbstractWaypointsScreen(Text title, T parent, Multimap<String, WaypointCategory> waypoints, String island) {
30+
super(title);
31+
this.parent = parent;
32+
this.waypoints = waypoints;
33+
this.island = island;
34+
}
35+
36+
@Override
37+
protected void init() {
38+
super.init();
39+
waypointsListWidget = addDrawableChild(new WaypointsListWidget(client, this, width, height - 96, 32, 24));
40+
islandWidget = addDrawableChild(new DropdownWidget<>(client, width - 160, 8, 150, height - 8, Arrays.asList(Location.values()), this::islandChanged, Location.from(island)));
41+
}
42+
43+
@Override
44+
public boolean mouseClicked(double mouseX, double mouseY, int button) {
45+
if (islandWidget.mouseClicked(mouseX, mouseY, button)) {
46+
return true;
47+
}
48+
boolean mouseClicked = super.mouseClicked(mouseX, mouseY, button);
49+
updateButtons();
50+
return mouseClicked;
51+
}
52+
53+
@Override
54+
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
55+
if (islandWidget.isMouseOver(mouseX, mouseY) && islandWidget.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount)) {
56+
return true;
57+
}
58+
return super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
59+
}
60+
61+
protected void islandChanged(Location location) {
62+
island = location.id();
63+
waypointsListWidget.setIsland(island);
64+
}
65+
66+
protected abstract boolean isEnabled(NamedWaypoint waypoint);
67+
68+
protected abstract void enabledChanged(NamedWaypoint waypoint, boolean enabled);
69+
70+
protected void updateButtons() {
71+
waypointsListWidget.updateButtons();
72+
}
73+
}

0 commit comments

Comments
 (0)