Skip to content

Commit

Permalink
Merge pull request #390 from kevinthegreat1/waypoint
Browse files Browse the repository at this point in the history
Waypoints API & Custom Dungeon Secrets
  • Loading branch information
kevinthegreat1 committed Oct 30, 2023
2 parents 9edc484 + 16467d7 commit ed5957c
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 123 deletions.
22 changes: 2 additions & 20 deletions src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.hysky.skyblocker.skyblock.item.CustomArmorTrims;
import de.hysky.skyblocker.utils.chat.ChatFilterResult;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
Expand Down Expand Up @@ -582,7 +583,7 @@ public static class SecretWaypoints {
public boolean noInitSecretWaypoints = false;

@SerialEntry
public WaypointType waypointType = WaypointType.WAYPOINT;
public Waypoint.Type waypointType = Waypoint.Type.WAYPOINT;

@SerialEntry
public boolean showSecretText = true;
Expand Down Expand Up @@ -623,25 +624,6 @@ public static class SecretWaypoints {
@SerialEntry
public boolean enableDefaultWaypoints = true;
}

public enum WaypointType {
WAYPOINT,
OUTLINED_WAYPOINT,
HIGHLIGHT,
OUTLINED_HIGHLIGHT,
OUTLINE;

@Override
public String toString() {
return switch (this) {
case WAYPOINT -> "Waypoint";
case OUTLINED_WAYPOINT -> "Outlined Waypoint";
case HIGHLIGHT -> "Highlight";
case OUTLINED_HIGHLIGHT -> "Outlined Highlight";
case OUTLINE -> "Outline";
};
}
}

public static class DungeonChestProfit {
@SerialEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfig.WaypointType;
import de.hysky.skyblocker.utils.waypoint.Waypoint.Type;
import dev.isxander.yacl3.api.ButtonOption;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
Expand Down Expand Up @@ -44,7 +44,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.flag(OptionFlag.GAME_RESTART)
.build())
.option(Option.<WaypointType>createBuilder()
.option(Option.<Type>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.secretWaypoints.waypointType.@Tooltip")))
.binding(defaults.locations.dungeons.secretWaypoints.waypointType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class MythologicalRitual {
private static final Map<BlockPos, GriffinBurrow> griffinBurrows = new HashMap<>();
@Nullable
private static BlockPos lastDugBurrowPos;
private static GriffinBurrow previousBurrow = new GriffinBurrow();
private static GriffinBurrow previousBurrow = new GriffinBurrow(BlockPos.ORIGIN);

public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(MythologicalRitual::render);
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void onParticle(ParticleS2CPacket packet) {
if (MinecraftClient.getInstance().world == null || !MinecraftClient.getInstance().world.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) {
return;
}
GriffinBurrow burrow = griffinBurrows.computeIfAbsent(pos, pos1 -> new GriffinBurrow());
GriffinBurrow burrow = griffinBurrows.computeIfAbsent(pos, GriffinBurrow::new);
if (ParticleTypes.CRIT.equals(packet.getParameters().getType())) burrow.critParticle++;
if (ParticleTypes.ENCHANT.equals(packet.getParameters().getType())) burrow.enchantParticle++;
if (burrow.critParticle >= 5 && burrow.enchantParticle >= 5 && burrow.confirmed == TriState.FALSE) {
Expand Down Expand Up @@ -133,10 +134,9 @@ public static void onParticle(ParticleS2CPacket packet) {

public static void render(WorldRenderContext context) {
if (isActive()) {
for (Map.Entry<BlockPos, GriffinBurrow> burrowEntry : griffinBurrows.entrySet()) {
GriffinBurrow burrow = burrowEntry.getValue();
if (burrow.confirmed == TriState.TRUE) {
RenderHelper.renderFilledThroughWallsWithBeaconBeam(context, burrowEntry.getKey(), ORANGE_COLOR_COMPONENTS, 0.25F);
for (GriffinBurrow burrow : griffinBurrows.values()) {
if (burrow.shouldRender()) {
burrow.render(context);
}
if (burrow.confirmed != TriState.FALSE) {
if (burrow.nextBurrowPlane != null) {
Expand Down Expand Up @@ -186,7 +186,7 @@ private static boolean isActive() {
return SkyblockerConfigManager.get().general.mythologicalRitual.enableMythologicalRitualHelper && Utils.getLocationRaw().equals("hub");
}

private static class GriffinBurrow {
private static class GriffinBurrow extends Waypoint {
private int critParticle;
private int enchantParticle;
private TriState confirmed = TriState.FALSE;
Expand All @@ -196,9 +196,18 @@ private static class GriffinBurrow {
private Vec3d[] echoBurrowDirection;
private Vec3d[] echoBurrowPlane;

private GriffinBurrow(BlockPos pos) {
super(pos, Type.WAYPOINT, ORANGE_COLOR_COMPONENTS, 0.25F);
}

private void init() {
confirmed = TriState.TRUE;
regression.clear();
}

@Override
public boolean shouldRender() {
return super.shouldRender() && confirmed == TriState.TRUE;
}
}
}

0 comments on commit ed5957c

Please sign in to comment.