diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
15 files changed, 259 insertions, 74 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/BasePlaceholderScreen.java b/src/main/java/de/hysky/skyblocker/utils/BasePlaceholderScreen.java new file mode 100644 index 00000000..b362dcb7 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/BasePlaceholderScreen.java @@ -0,0 +1,19 @@ +package de.hysky.skyblocker.utils; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.Text; + +public abstract class BasePlaceholderScreen extends Screen { + public BasePlaceholderScreen(Text title) { + super(title); + } + + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + } + + @Override + public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index ed46677d..880ebe76 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -1,45 +1,49 @@ package de.hysky.skyblocker.utils; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import de.hysky.skyblocker.mixin.accessor.ItemStackAccessor; import it.unimi.dsi.fastutil.ints.IntIntPair; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.item.TooltipContext; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.StringNbtReader; import net.minecraft.text.Text; +import net.minecraft.text.Texts; import net.minecraft.util.Formatting; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.*; import java.util.function.Predicate; import java.util.regex.Pattern; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + public class ItemUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtils.class); public static final String EXTRA_ATTRIBUTES = "ExtraAttributes"; public static final String ID = "id"; public static final String UUID = "uuid"; + private static final DateTimeFormatter OBTAINED_DATE_FORMATTER = DateTimeFormatter.ofPattern("MMMM d, yyyy").withZone(ZoneId.systemDefault()).localizedBy(Locale.ENGLISH); + private static final SimpleDateFormat OLD_OBTAINED_DATE_FORMAT = new SimpleDateFormat("MM/dd/yy"); public static final Pattern NOT_DURABILITY = Pattern.compile("[^0-9 /]"); public static final Predicate<String> FUEL_PREDICATE = line -> line.contains("Fuel: "); - public static List<Text> getTooltips(ItemStack item) { - MinecraftClient client = MinecraftClient.getInstance(); - return client.player == null || item == null ? Collections.emptyList() : item.getTooltip(client.player, TooltipContext.Default.BASIC); - } - - @Nullable - public static String getTooltip(ItemStack item, Predicate<String> predicate) { - for (Text line : getTooltips(item)) { - String string = line.getString(); - if (predicate.test(string)) { - return string; - } - } - - return null; + public static LiteralArgumentBuilder<FabricClientCommandSource> dumpHeldItemNbtCommand() { + return literal("dumpHeldItemNbt").executes(context -> { + context.getSource().sendFeedback(Text.literal("[Skyblocker Debug] Held Item Nbt: " + context.getSource().getPlayer().getMainHandStack().writeNbt(new NbtCompound()))); + return Command.SINGLE_SUCCESS; + }); } /** @@ -105,6 +109,44 @@ public class ItemUtils { return extraAttributes != null ? extraAttributes.getString(UUID) : ""; } + /** + * This method converts the "timestamp" variable into the same date format as Hypixel represents it in the museum. + * Currently, there are two types of string timestamps the legacy which is built like this + * "dd/MM/yy hh:mm" ("25/04/20 16:38") and the current which is built like this + * "MM/dd/yy hh:mm aa" ("12/24/20 11:08 PM"). Since Hypixel transforms the two formats into one format without + * taking into account of their formats, we do the same. The final result looks like this + * "MMMM dd, yyyy" (December 24, 2020). + * Since the legacy format has a 25 as "month" SimpleDateFormat converts the 25 into 2 years and 1 month and makes + * "25/04/20 16:38" -> "January 04, 2022" instead of "April 25, 2020". + * This causes the museum rank to be much worse than it should be. + * <p> + * This also handles the long timestamp format introduced in January 2024 where the timestamp is in epoch milliseconds. + * + * @param stack the item under the pointer + * @return if the item have a "Timestamp" it will be shown formated on the tooltip + */ + public static String getTimestamp(ItemStack stack) { + NbtCompound ea = getExtraAttributes(stack); + + if (ea != null && ea.contains("timestamp", NbtElement.LONG_TYPE)) { + Instant date = Instant.ofEpochMilli(ea.getLong("timestamp")); + + return OBTAINED_DATE_FORMATTER.format(date); + } + + if (ea != null && ea.contains("timestamp", NbtElement.STRING_TYPE)) { + try { + Instant date = OLD_OBTAINED_DATE_FORMAT.parse(ea.getString("timestamp")).toInstant(); + + return OBTAINED_DATE_FORMATTER.format(date); + } catch (ParseException e) { + LOGGER.warn("[Skyblocker Item Utils] Encountered an unknown exception while parsing time stamp of item {} with extra attributes {}", stack, ea, e); + } + } + + return ""; + } + public static boolean hasCustomDurability(@NotNull ItemStack stack) { NbtCompound extraAttributes = getExtraAttributes(stack); return extraAttributes != null && (extraAttributes.contains("drill_fuel") || extraAttributes.getString(ID).equals("PICKONIMBUS")); @@ -123,7 +165,7 @@ public class ItemUtils { return IntIntPair.of(pickonimbusDurability, 5000); } - String drillFuel = Formatting.strip(getTooltip(stack, FUEL_PREDICATE)); + String drillFuel = Formatting.strip(getNbtTooltip(stack, FUEL_PREDICATE)); if (drillFuel != null) { String[] drillFuelStrings = NOT_DURABILITY.matcher(drillFuel).replaceAll("").trim().split("/"); return IntIntPair.of(Integer.parseInt(drillFuelStrings[0]), Integer.parseInt(drillFuelStrings[1]) * 1000); @@ -132,6 +174,27 @@ public class ItemUtils { return null; } + @Nullable + public static String getNbtTooltip(ItemStack item, Predicate<String> predicate) { + for (Text line : getNbtTooltips(item)) { + String string = line.getString(); + if (predicate.test(string)) { + return string; + } + } + + return null; + } + + public static List<Text> getNbtTooltips(ItemStack item) { + NbtCompound displayNbt = item.getSubNbt("display"); + if (displayNbt == null || !displayNbt.contains("Lore", NbtElement.LIST_TYPE)) { + return Collections.emptyList(); + } + + return displayNbt.getList("Lore", NbtElement.STRING_TYPE).stream().map(NbtElement::asString).map(Text.Serialization::fromJson).filter(Objects::nonNull).map(text -> Texts.setStyleIfAbsent(text, ItemStackAccessor.getLORE_STYLE())).map(Text.class::cast).toList(); + } + public static ItemStack getSkyblockerStack() { try { return ItemStack.fromNbt(StringNbtReader.parse("{id:\"minecraft:player_head\",Count:1,tag:{SkullOwner:{Id:[I;-300151517,-631415889,-1193921967,-1821784279],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}}}}")); diff --git a/src/main/java/de/hysky/skyblocker/utils/JoinWorldPlaceholderScreen.java b/src/main/java/de/hysky/skyblocker/utils/JoinWorldPlaceholderScreen.java new file mode 100644 index 00000000..f64bcf6c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/JoinWorldPlaceholderScreen.java @@ -0,0 +1,9 @@ +package de.hysky.skyblocker.utils; + +import net.minecraft.text.Text; + +public final class JoinWorldPlaceholderScreen extends BasePlaceholderScreen { + public JoinWorldPlaceholderScreen() { + super(Text.translatable("connect.joining")); + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/ReconfiguringPlaceholderScreen.java b/src/main/java/de/hysky/skyblocker/utils/ReconfiguringPlaceholderScreen.java new file mode 100644 index 00000000..4d415615 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/ReconfiguringPlaceholderScreen.java @@ -0,0 +1,22 @@ +package de.hysky.skyblocker.utils; + +import net.minecraft.network.ClientConnection; +import net.minecraft.text.Text; + +public final class ReconfiguringPlaceholderScreen extends BasePlaceholderScreen { + private final ClientConnection connection; + + public ReconfiguringPlaceholderScreen(final ClientConnection connection) { + super(Text.translatable("connect.reconfiguring")); + this.connection = connection; + } + + @Override + public void tick() { + if (this.connection.isOpen()) { + this.connection.tick(); + } else { + this.connection.handleDisconnection(); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/Tickable.java b/src/main/java/de/hysky/skyblocker/utils/Tickable.java new file mode 100644 index 00000000..dff34e19 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/Tickable.java @@ -0,0 +1,7 @@ +package de.hysky.skyblocker.utils; + +import net.minecraft.client.MinecraftClient; + +public interface Tickable { + void tick(MinecraftClient client); +} diff --git a/src/main/java/de/hysky/skyblocker/utils/chat/ChatMessageListener.java b/src/main/java/de/hysky/skyblocker/utils/chat/ChatMessageListener.java index 2c75ef0a..ebdb6f09 100644 --- a/src/main/java/de/hysky/skyblocker/utils/chat/ChatMessageListener.java +++ b/src/main/java/de/hysky/skyblocker/utils/chat/ChatMessageListener.java @@ -5,8 +5,8 @@ import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.skyblock.barn.HungryHiker; import de.hysky.skyblocker.skyblock.barn.TreasureHunter; import de.hysky.skyblocker.skyblock.dungeon.Reparty; -import de.hysky.skyblocker.skyblock.dungeon.ThreeWeirdos; -import de.hysky.skyblocker.skyblock.dungeon.Trivia; +import de.hysky.skyblocker.skyblock.dungeon.puzzle.ThreeWeirdos; +import de.hysky.skyblocker.skyblock.dungeon.puzzle.Trivia; import de.hysky.skyblocker.skyblock.dwarven.Fetchur; import de.hysky.skyblocker.skyblock.dwarven.Puzzler; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -53,7 +53,8 @@ public interface ChatMessageListener { new MoltenWaveFilter(), new TeleportPadFilter(), new AutopetFilter(), - new ShowOffFilter() + new ShowOffFilter(), + new ToggleSkyMallFilter() }; // Register all listeners to EVENT for (ChatMessageListener listener : listeners) { diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index 0f73df16..05514d02 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -60,7 +60,7 @@ public class RenderHelper { renderFilled(context, Vec3d.of(pos), dimensions, colorComponents, alpha, true); } } else { - if (OcclusionCulling.isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + dimensions.x, pos.getY() + dimensions.y, pos.getZ() + dimensions.z)) { + if (OcclusionCulling.getRegularCuller().isVisible(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + dimensions.x, pos.getY() + dimensions.y, pos.getZ() + dimensions.z)) { renderFilled(context, Vec3d.of(pos), dimensions, colorComponents, alpha, false); } } @@ -140,8 +140,9 @@ public class RenderHelper { * @param colorComponents An array of R, G and B color components * @param alpha The alpha of the lines * @param lineWidth The width of the lines + * @param throughWalls Whether to render through walls or not */ - public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, float lineWidth) { + public static void renderLinesFromPoints(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls) { Vec3d camera = context.camera().getPos(); MatrixStack matrices = context.matrixStack(); @@ -163,6 +164,7 @@ public class RenderHelper { RenderSystem.defaultBlendFunc(); RenderSystem.disableCull(); RenderSystem.enableDepthTest(); + RenderSystem.depthFunc(throughWalls ? GL11.GL_ALWAYS : GL11.GL_LEQUAL); buffer.begin(DrawMode.LINE_STRIP, VertexFormats.LINES); @@ -182,6 +184,7 @@ public class RenderHelper { GL11.glDisable(GL11.GL_LINE_SMOOTH); RenderSystem.lineWidth(1f); RenderSystem.enableCull(); + RenderSystem.depthFunc(GL11.GL_LEQUAL); } public static void renderQuad(WorldRenderContext context, Vec3d[] points, float[] colorComponents, float alpha, boolean throughWalls) { diff --git a/src/main/java/de/hysky/skyblocker/utils/render/Renderable.java b/src/main/java/de/hysky/skyblocker/utils/render/Renderable.java new file mode 100644 index 00000000..b7743153 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/Renderable.java @@ -0,0 +1,7 @@ +package de.hysky.skyblocker.utils.render; + +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; + +public interface Renderable { + void render(WorldRenderContext context); +} diff --git a/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCuller.java b/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCuller.java new file mode 100644 index 00000000..3c48a47e --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCuller.java @@ -0,0 +1,45 @@ +package de.hysky.skyblocker.utils.render.culling; + +import com.logisticscraft.occlusionculling.OcclusionCullingInstance; +import com.logisticscraft.occlusionculling.cache.ArrayOcclusionCache; +import com.logisticscraft.occlusionculling.util.Vec3d; + +import de.hysky.skyblocker.utils.render.FrustumUtils; +import net.minecraft.client.MinecraftClient; + +public class OcclusionCuller { + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + + private final OcclusionCullingInstance instance; + + // Reused objects to reduce allocation overhead + private final Vec3d cameraPos = new Vec3d(0, 0, 0); + private final Vec3d min = new Vec3d(0, 0, 0); + private final Vec3d max = new Vec3d(0, 0, 0); + + OcclusionCuller(int tracingDistance, WorldProvider worldProvider, double aabbExpansion) { + this.instance = new OcclusionCullingInstance(tracingDistance, worldProvider, new ArrayOcclusionCache(tracingDistance), aabbExpansion); + } + + private void updateCameraPos() { + var camera = CLIENT.gameRenderer.getCamera().getPos(); + cameraPos.set(camera.x, camera.y, camera.z); + } + + /** + * This first checks checks if the bounding box is within the camera's FOV, if + * it is then it checks for whether it's occluded or not. + * + * @return A boolean representing whether the bounding box is fully visible or + * not as per the instance's settings. + */ + public boolean isVisible(double x1, double y1, double z1, double x2, double y2, double z2) { + if (!FrustumUtils.isVisible(x1, y1, z1, x2, y2, z2)) return false; + + updateCameraPos(); + min.set(x1, y1, z1); + max.set(x2, y2, z2); + + return instance.isAABBVisible(min, max, cameraPos); + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCulling.java b/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCulling.java index 5f8d1592..b1ff10dd 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCulling.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/culling/OcclusionCulling.java @@ -1,47 +1,23 @@ package de.hysky.skyblocker.utils.render.culling; -import com.logisticscraft.occlusionculling.OcclusionCullingInstance; -import com.logisticscraft.occlusionculling.cache.ArrayOcclusionCache; -import com.logisticscraft.occlusionculling.util.Vec3d; -import de.hysky.skyblocker.utils.render.FrustumUtils; -import net.minecraft.client.MinecraftClient; - public class OcclusionCulling { private static final int TRACING_DISTANCE = 128; - private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static OcclusionCullingInstance instance = null; - - // Reused objects to reduce allocation overhead - private static final Vec3d cameraPos = new Vec3d(0, 0, 0); - private static final Vec3d min = new Vec3d(0, 0, 0); - private static final Vec3d max = new Vec3d(0, 0, 0); + private static OcclusionCuller regularCuller = null; + private static OcclusionCuller reducedCuller = null; /** - * Initializes the occlusion culling instance + * Initializes the occlusion culling instances */ public static void init() { - instance = new OcclusionCullingInstance(TRACING_DISTANCE, new WorldProvider(), new ArrayOcclusionCache(TRACING_DISTANCE), 2); + regularCuller = new OcclusionCuller(TRACING_DISTANCE, new WorldProvider(), 2); + reducedCuller = new OcclusionCuller(TRACING_DISTANCE, new ReducedWorldProvider(), 0); } - private static void updateCameraPos() { - var camera = CLIENT.gameRenderer.getCamera().getPos(); - cameraPos.set(camera.x, camera.y, camera.z); + public static OcclusionCuller getRegularCuller() { + return regularCuller; } - /** - * This first checks checks if the bounding box is within the camera's FOV, if - * it is then it checks for whether it's occluded or not. - * - * @return A boolean representing whether the bounding box is fully visible or - * not. - */ - public static boolean isVisible(double x1, double y1, double z1, double x2, double y2, double z2) { - if (!FrustumUtils.isVisible(x1, y1, z1, x2, y2, z2)) return false; - - updateCameraPos(); - min.set(x1, y1, z1); - max.set(x2, y2, z2); - - return instance.isAABBVisible(min, max, cameraPos); + public static OcclusionCuller getReducedCuller() { + return reducedCuller; } } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/culling/ReducedWorldProvider.java b/src/main/java/de/hysky/skyblocker/utils/render/culling/ReducedWorldProvider.java new file mode 100644 index 00000000..5a2b9d87 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/culling/ReducedWorldProvider.java @@ -0,0 +1,19 @@ +package de.hysky.skyblocker.utils.render.culling; + +import net.minecraft.block.BlockState; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.util.math.BlockPos; + +public class ReducedWorldProvider extends WorldProvider { + + @Override + public boolean isOpaqueFullCube(int x, int y, int z) { + BlockPos pos = new BlockPos(x, y, z); + BlockState state = this.world.getBlockState(pos); + + //Fixes edge cases where stairs etc aren't treated as being full blocks for the use case + boolean isException = state.isIn(BlockTags.STAIRS) || state.isIn(BlockTags.WALLS) || state.isIn(BlockTags.FENCES); + + return isException || this.world.getBlockState(pos).isOpaqueFullCube(this.world, pos); + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/render/culling/WorldProvider.java b/src/main/java/de/hysky/skyblocker/utils/render/culling/WorldProvider.java index 7ee0f0ed..1d2db238 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/culling/WorldProvider.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/culling/WorldProvider.java @@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos; public class WorldProvider implements DataProvider { private final static MinecraftClient CLIENT = MinecraftClient.getInstance(); - private ClientWorld world = null; + protected ClientWorld world = null; @Override public boolean prepareChunk(int chunkX, int chunkZ) { diff --git a/src/main/java/de/hysky/skyblocker/utils/scheduler/MessageScheduler.java b/src/main/java/de/hysky/skyblocker/utils/scheduler/MessageScheduler.java index a67d8da0..43194938 100644 --- a/src/main/java/de/hysky/skyblocker/utils/scheduler/MessageScheduler.java +++ b/src/main/java/de/hysky/skyblocker/utils/scheduler/MessageScheduler.java @@ -1,6 +1,8 @@ package de.hysky.skyblocker.utils.scheduler; import net.minecraft.client.MinecraftClient; +import net.minecraft.util.StringHelper; +import org.apache.commons.lang3.StringUtils; /** * A scheduler for sending chat messages or commands. Use the instance in {@link #INSTANCE}. Do not instantiate this class. @@ -34,13 +36,17 @@ public class MessageScheduler extends Scheduler { } private void sendMessage(String message) { - if (MinecraftClient.getInstance().player != null) { - if (message.startsWith("/")) { - MinecraftClient.getInstance().player.networkHandler.sendCommand(message.substring(1)); - } else { - MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(message); - MinecraftClient.getInstance().player.networkHandler.sendChatMessage(message); - } + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player == null) { + Scheduler.LOGGER.error("[Skyblocker Message Scheduler] Tried to send a message while player is null: {}", message); + return; + } + message = StringHelper.truncateChat(StringUtils.normalizeSpace(message.trim())); + if (message.startsWith("/")) { + client.player.networkHandler.sendCommand(message.substring(1)); + } else { + client.inGameHud.getChatHud().addToMessageHistory(message); + client.player.networkHandler.sendChatMessage(message); } } diff --git a/src/main/java/de/hysky/skyblocker/utils/scheduler/Scheduler.java b/src/main/java/de/hysky/skyblocker/utils/scheduler/Scheduler.java index 139ac05e..2f5375fe 100644 --- a/src/main/java/de/hysky/skyblocker/utils/scheduler/Scheduler.java +++ b/src/main/java/de/hysky/skyblocker/utils/scheduler/Scheduler.java @@ -20,7 +20,7 @@ import java.util.function.Supplier; * A scheduler for running tasks at a later time. Tasks will be run synchronously on the main client thread. Use the instance stored in {@link #INSTANCE}. Do not instantiate this class. */ public class Scheduler { - private static final Logger LOGGER = LoggerFactory.getLogger(Scheduler.class); + protected static final Logger LOGGER = LoggerFactory.getLogger(Scheduler.class); public static final Scheduler INSTANCE = new Scheduler(); private int currentTick = 0; private final AbstractInt2ObjectMap<List<ScheduledTask>> tasks = new Int2ObjectOpenHashMap<>(); diff --git a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java index eb30cf8d..2f9c9f63 100644 --- a/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java +++ b/src/main/java/de/hysky/skyblocker/utils/waypoint/Waypoint.java @@ -19,15 +19,19 @@ public class Waypoint { final boolean throughWalls; private boolean shouldRender; - protected Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents) { + public Waypoint(BlockPos pos, Type type, float[] colorComponents) { + this(pos, type, colorComponents, DEFAULT_HIGHLIGHT_ALPHA); + } + + public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents) { this(pos, typeSupplier, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, DEFAULT_LINE_WIDTH); } - protected Waypoint(BlockPos pos, Type type, float[] colorComponents, float alpha) { + public Waypoint(BlockPos pos, Type type, float[] colorComponents, float alpha) { this(pos, () -> type, colorComponents, alpha, DEFAULT_LINE_WIDTH); } - protected Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth) { + public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth) { this(pos, typeSupplier, colorComponents, alpha, lineWidth, true); } @@ -35,11 +39,11 @@ public class Waypoint { this(pos, typeSupplier, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, DEFAULT_LINE_WIDTH, throughWalls); } - protected Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls) { + public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls) { this(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, true); } - protected Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls, boolean shouldRender) { + public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls, boolean shouldRender) { this.pos = pos; this.box = new Box(pos); this.typeSupplier = typeSupplier; @@ -62,6 +66,10 @@ public class Waypoint { this.shouldRender = true; } + public void toggle() { + this.shouldRender = !this.shouldRender; + } + protected float[] getColorComponents() { return colorComponents; } |
