diff --git a/.github/README.md b/.github/README.md index bb1e52e9..73b4e636 100644 --- a/.github/README.md +++ b/.github/README.md @@ -10,7 +10,7 @@ A DiamondFire utility client for advanced coding. -A Fabric 1.20 mod for coding more efficiently with utility features including but not limited to: +A Fabric 1.21.3 mod for coding more efficiently with utility features including but not limited to: * Automatically placing templates in inventory * Moving faster in codespace * A palette with all the actions @@ -19,13 +19,14 @@ A Fabric 1.20 mod for coding more efficiently with utility features including bu 1. Download the latest release of the mod from **[here](https://github.com/DFOnline/CodeClient/releases/latest)**. 2. Download all the other required mods, they are [Fabric API](https://modrinth.com/mod/fabric-api), [Yet Another Config Lib](https://modrinth.com/mod/yacl), and optionally [Mod Menu](https://modrinth.com/mod/modmenu) 3. Move the downloaded mod files into the mods folder located at .minecraft/mods. -4. Launch the game and try it out on [DiamondFire](mcdiamondfire.com). +4. Launch the game and try it out on [DiamondFire](https://mcdiamondfire.com/). ## Useful Info There's a [discord](https://discord.gg/NqU6XnyVPA) for CodeClient, and a helpful [wiki](https://github.com/DFOnline/CodeClient/wiki) ## Versions -* [1.20 (latest)](https://github.com/DFOnline/CodeClient/releases/latest) + +* [1.21 (latest)](https://github.com/DFOnline/CodeClient/releases/latest) ## Contributing @@ -35,7 +36,7 @@ Feel free to help! [Open an issue](https://github.com/DFOnline/CodeClient/issues Thanks to all the people who contribute. - +CodeClient Contributors ## License diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0725b3ed..87eb9d6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,11 +14,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 17 - distribution: "temurin" + java-version: 21 + distribution: "temurin" - name: Build with Gradle run: ./gradlew build '-Pversion=${{ github.run_number }}' - name: Upload Artifact diff --git a/build.gradle b/build.gradle index 5b9623bf..01623479 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.1-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' id 'maven-publish' } @@ -24,22 +24,23 @@ repositories { } dependencies { - // To change the versions see the gradle.properties file + // To change the versions see the gradle.properties file. minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - // MixinExtras. Fabric Loader 0.15.0 and above should bundle it, but I don't have access to it for some reason. - implementation annotationProcessor(include("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}")) - // Fabric API. This is technically optional, but you probably want it anyway. + // Fabric API. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}" + // YetAnotherConfigLib. + modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}" + // ModMenu. modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" - // adventure api for minimessage parsing (see ExpressionHighlighter) -// implementation "net.kyori:adventure-api:4.16.0" - modImplementation include("net.kyori:adventure-platform-fabric:5.12.0") + // Adventure for MiniMessage parsing. + implementation("net.kyori:adventure-api:${project.adventure_api_version}") + modImplementation include("net.kyori:adventure-platform-fabric:${project.adventure_fabric_version}") + // WebSocket for CodeClient API. implementation include("org.java-websocket:Java-WebSocket:1.5.3") } @@ -52,7 +53,7 @@ processResources { } } -def targetJavaVersion = 17 +def targetJavaVersion = 21 tasks.withType(JavaCompile).configureEach { // ensure that the encoding is set to UTF-8, no matter what the system default is // this fixes some edge cases with special characters not displaying correctly @@ -76,6 +77,10 @@ java { // withSourcesJar() } +loom { + accessWidenerPath = file("src/main/resources/codeclient.accesswidener") +} + jar { from("LICENSE") { rename { "${it}_${project.archivesBaseName}" } diff --git a/gradle.properties b/gradle.properties index fe48f5c1..439857f3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,17 +3,18 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties ## Check these on https://fabricmc.net/develop/ -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.3 -mixin_extras_version=0.4.1 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 # Mod Properties -mod_version=1.7.2 +mod_version=2.0.0-beta.2 maven_group=dev.dfonline archives_base_name=CodeClient # Dependencies -fabric_version=0.92.1+1.20.4 -modmenu_version=9.0.0-pre.1 -yacl_version=3.3.1+1.20.4 +fabric_version=0.108.0+1.21.3 +modmenu_version=12.0.0-beta.1 +yacl_version=3.6.1+1.21.2-fabric +adventure_api_version=4.17.0 +adventure_fabric_version=6.1.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fce..e1adfb49 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/dev/dfonline/codeclient/CodeClient.java b/src/main/java/dev/dfonline/codeclient/CodeClient.java index b3170d18..e036a6f3 100644 --- a/src/main/java/dev/dfonline/codeclient/CodeClient.java +++ b/src/main/java/dev/dfonline/codeclient/CodeClient.java @@ -5,8 +5,15 @@ import dev.dfonline.codeclient.action.None; import dev.dfonline.codeclient.action.impl.DevForBuild; import dev.dfonline.codeclient.command.CommandManager; +import dev.dfonline.codeclient.command.CommandSender; import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.config.KeyBinds; +import dev.dfonline.codeclient.data.DFItem; +import dev.dfonline.codeclient.data.ItemData; +import dev.dfonline.codeclient.data.PublicBukkitValues; +import dev.dfonline.codeclient.data.value.DataValue; +import dev.dfonline.codeclient.data.value.NumberDataValue; +import dev.dfonline.codeclient.data.value.StringDataValue; import dev.dfonline.codeclient.dev.*; import dev.dfonline.codeclient.dev.debug.Debug; import dev.dfonline.codeclient.dev.highlighter.ExpressionHighlighter; @@ -42,17 +49,13 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.AbstractNbtNumber; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtString; import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.network.packet.s2c.play.BundleS2CPacket; import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -82,7 +85,7 @@ public class CodeClient implements ClientModInitializer { public static Action confirmingAction = null; public static Location lastLocation = null; public static Location location = null; - /*** + /** * Used to open a screen on the next tick. */ public static Screen screenToOpen = null; @@ -112,7 +115,9 @@ public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(Blocks.STRUCTURE_VOID, RenderLayer.getTranslucent()); BlockRenderLayerMap.INSTANCE.putBlock(Blocks.LIGHT, RenderLayer.getTranslucent()); - ClientLifecycleEvents.CLIENT_STOPPING.register(new Identifier(MOD_ID, "close"), client -> API.stop()); + ClientLifecycleEvents.CLIENT_STOPPING.register(Identifier.of(MOD_ID, "close"), client -> API.stop()); + + ClientTickEvents.END_CLIENT_TICK.register(client -> CommandSender.tick()); if (Config.getConfig().CodeClientAPI) { try { @@ -129,29 +134,33 @@ public void onInitializeClient() { ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> CommandManager.init(dispatcher, registryAccess)); - ItemTooltipCallback.EVENT.register((stack, context, lines) -> { + ItemTooltipCallback.EVENT.register((stack, context, type, lines) -> { if (isPreviewingItemTags) { - if (!stack.hasNbt()) return; - NbtCompound nbt = stack.getNbt(); - if (nbt == null) return; - if (!nbt.contains("PublicBukkitValues")) return; - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - for (var key : publicBukkit.getKeys()) { - if (key.startsWith("hypercube:")) { - NbtElement element = publicBukkit.get(key); - - // Any type = yellow, number = red, string = aqua. - MutableText value = Text.literal(publicBukkit.get(key).toString()).formatted(Formatting.GREEN); - if (element instanceof NbtString) value.formatted(Formatting.AQUA); - if (element instanceof AbstractNbtNumber) value.formatted(Formatting.RED); - - lines.add( - Text.literal(key.replace("hypercube:", "")) - .withColor(0xAAFF55) - .append(Text.literal(" = ").formatted(Formatting.DARK_GRAY)) - .append(value) - ); + DFItem item = DFItem.of(stack); + ItemData itemData = item.getItemData(); + if (itemData == null) return; + PublicBukkitValues publicBukkit = itemData.getPublicBukkitValues(); + if (publicBukkit == null) return; + for (var key : publicBukkit.getHypercubeKeys()) { + DataValue element = publicBukkit.getHypercubeValue(key); + + // Any type = yellow, number = red, string = aqua. + Formatting formatting = Formatting.GREEN; + String stringElement = element.getValue() == null ? "?" : element.getValue().toString(); + if (element instanceof StringDataValue) { + formatting = Formatting.AQUA; } + if (element instanceof NumberDataValue numberDataValue) { + formatting = Formatting.RED; + stringElement = String.valueOf(numberDataValue.getValue()); + } + + lines.add( + Text.literal(key) + .withColor(0xAAFF55) + .append(Text.literal(" = ").formatted(Formatting.DARK_GRAY)) + .append(Text.literal(stringElement).formatted(formatting)) + ); } } }); @@ -189,6 +198,7 @@ private static void loadFeatures() { feat(new CPUDisplay()); feat(new MessageHiding()); feat(new ExpressionHighlighter()); + feat(new PreviewSoundChest()); } /** @@ -205,6 +215,16 @@ private static Stream chestFeatures() { return features().map(Feature::getChest).filter(Optional::isPresent).map(Optional::get); } + /** + * Get an identifier using the mod id as the namespace. + * + * @param path The path to the resource. + * @return Identifier under the mod id's namespace and the provided path as the path. + */ + public static Identifier getId(String path) { + return Identifier.of(MOD_ID, path); + } + public static void isCodeChest() { isCodeChest = true; } @@ -216,6 +236,12 @@ public static Optional getFeature(Class clazz) { } public static boolean handlePacket(Packet packet) { + if (packet instanceof BundleS2CPacket bundle) { + bundle.getPackets().forEach(CodeClient::handlePacket); + return false; + } + + if (currentAction.onReceivePacket(packet)) return true; for (var feature : features().toList()) { if (feature.onReceivePacket(packet)) return true; @@ -263,6 +289,8 @@ public static void onTick() { features().forEach(Feature::tick); KeyBinds.tick(); +// System.out.println(location.name()); + if (!(location instanceof Dev) || !(MC.currentScreen instanceof HandledScreen)) { isCodeChest = false; features().forEach(Feature::closeChest); @@ -455,7 +483,7 @@ private boolean registerResourcePack(String id, Text name) throws NullPointerExc private boolean registerResourcePack(String id, Text name, ResourcePackActivationType type) throws NullPointerException { var prefix = String.format("[%s] ", MOD_NAME); return ResourceManagerHelper.registerBuiltinResourcePack( - new Identifier(CodeClient.MOD_ID, id), + getId(id), getModContainer(), Text.literal(prefix).formatted(Formatting.GRAY).append(name), type diff --git a/src/main/java/dev/dfonline/codeclient/Event.java b/src/main/java/dev/dfonline/codeclient/Event.java index 84e752ec..44e89557 100644 --- a/src/main/java/dev/dfonline/codeclient/Event.java +++ b/src/main/java/dev/dfonline/codeclient/Event.java @@ -1,9 +1,11 @@ package dev.dfonline.codeclient; +import dev.dfonline.codeclient.command.CommandSender; import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.location.*; import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket; import net.minecraft.network.packet.s2c.play.*; import net.minecraft.util.math.Vec3d; @@ -23,11 +25,11 @@ public static void handlePacket(Packet packet) { if (clear.shouldReset()) step = Sequence.WAIT_FOR_POS; } if (packet instanceof PlayerPositionLookS2CPacket pos) { - tp = new Vec3d(pos.getX(), pos.getY(), pos.getZ()); + tp = new Vec3d(pos.change().position().x, pos.change().position().y, pos.change().position().z); if (step == Sequence.WAIT_FOR_POS) step = Sequence.WAIT_FOR_MESSAGE; } if (packet instanceof OverlayMessageS2CPacket overlay) { - if (step == Sequence.WAIT_FOR_MESSAGE && overlay.getMessage().getString().startsWith("DiamondFire - ")) { + if (step == Sequence.WAIT_FOR_MESSAGE && overlay.text().getString().startsWith("DiamondFire - ")) { updateLocation(new Spawn()); } } @@ -52,10 +54,14 @@ public static void handlePacket(Packet packet) { public static void onSendPacket(Packet packet) { if (packet instanceof CommandExecutionC2SPacket command) { + CommandSender.registerCommandSend(); if (List.of("play", "build", "code", "dev").contains(command.command().replaceFirst("mode ", ""))) { switchingMode = true; } } + if (packet instanceof ChatMessageC2SPacket) { + CommandSender.registerCommandSend(); + } } public static void updateLocation(Location location) { diff --git a/src/main/java/dev/dfonline/codeclient/ItemSelector.java b/src/main/java/dev/dfonline/codeclient/ItemSelector.java index c407052a..6fcde470 100644 --- a/src/main/java/dev/dfonline/codeclient/ItemSelector.java +++ b/src/main/java/dev/dfonline/codeclient/ItemSelector.java @@ -131,5 +131,4 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) { private record Search(ItemStack item, int x, int y) { } - ; } diff --git a/src/main/java/dev/dfonline/codeclient/MoveToLocation.java b/src/main/java/dev/dfonline/codeclient/MoveToLocation.java index 7cb586d6..12da23ec 100644 --- a/src/main/java/dev/dfonline/codeclient/MoveToLocation.java +++ b/src/main/java/dev/dfonline/codeclient/MoveToLocation.java @@ -40,20 +40,20 @@ public void setPos(double x, double y, double z) { if (CodeClient.MC.getNetworkHandler() == null) return; if (new Vec3d(x, y, x).distanceTo(player.getPos()) > 10) { // I've always done it like this, problems? - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); } this.player.setPos(x, y, z); - this.player.teleport(x, y, z); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false)); + this.player.teleport(x, y, z, false); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false, true)); } /** diff --git a/src/main/java/dev/dfonline/codeclient/RateLimiter.java b/src/main/java/dev/dfonline/codeclient/RateLimiter.java new file mode 100644 index 00000000..896eea0a --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/RateLimiter.java @@ -0,0 +1,44 @@ +package dev.dfonline.codeclient; + +/** + * A rate limiter that can be used to limit the rate of execution of a certain operation. + */ +public class RateLimiter { + private final int incrementStep; + private final int threshold; + private int count; + + /** + * Creates a new rate limiter. + * @param incrementStep The amount to increment the count by each time the operation is executed. + * @param threshold The maximum count before the operation is rate limited. + */ + public RateLimiter(int incrementStep, int threshold) { + this.incrementStep = incrementStep; + this.threshold = threshold; + } + + /** + * Registers an operation, incrementing the count. + */ + public void increment() { + count += incrementStep; + } + + /** + * Decrements the count, should be called once per tick. + */ + public void tick() { + if (count > 0) { + --count; + } + } + + /** + * Checks if the operation is rate limited. + * @return True if the operation is rate limited, false otherwise. + */ + public boolean isRateLimited() { + return count >= threshold; + } +} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/Utility.java b/src/main/java/dev/dfonline/codeclient/Utility.java index 1fdb2464..6f3180aa 100644 --- a/src/main/java/dev/dfonline/codeclient/Utility.java +++ b/src/main/java/dev/dfonline/codeclient/Utility.java @@ -3,27 +3,22 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.mojang.serialization.JsonOps; import dev.dfonline.codeclient.action.impl.GetActionDump; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.template.Template; -import net.kyori.adventure.text.Component; +import net.kyori.adventure.platform.modcommon.impl.NonWrappingComponentSerializer; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import net.minecraft.text.TextColor; +import net.minecraft.sound.SoundEvents; +import net.minecraft.text.*; import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; +import net.kyori.adventure.text.Component; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -33,8 +28,6 @@ import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; -import static net.kyori.adventure.platform.fabric.FabricAudiences.nonWrappingSerializer; - public class Utility { /** * Get the slot id to be used with a creative packet, from a local slot id. @@ -81,24 +74,16 @@ public static void debug(String message) { * Gets the base64 template data from an item. Null if there is none. */ public static String templateDataItem(ItemStack item) { - if (!item.hasNbt()) return null; - NbtCompound nbt = item.getNbt(); - if (nbt == null) return null; - if (!nbt.contains("PublicBukkitValues")) return null; - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - if (!publicBukkit.contains("hypercube:codetemplatedata")) return null; - String codeTemplateData = publicBukkit.getString("hypercube:codetemplatedata"); + DFItem dfItem = DFItem.of(item); + String codeTemplateData = dfItem.getHypercubeStringValue("codetemplatedata"); return JsonParser.parseString(codeTemplateData).getAsJsonObject().get("code").getAsString(); } - public static ItemStack makeTemplate(String message) { + public static ItemStack makeTemplate(String code) { ItemStack template = new ItemStack(Items.ENDER_CHEST); - NbtCompound nbt = new NbtCompound(); - NbtCompound PublicBukkitValues = new NbtCompound(); - PublicBukkitValues.putString("hypercube:codetemplatedata", "{\"author\":\"CodeClient\",\"name\":\"Template to be placed\",\"version\":1,\"code\":\"" + message + "\"}"); - nbt.put("PublicBukkitValues", PublicBukkitValues); - template.setNbt(nbt); - return template; + DFItem dfItem = DFItem.of(template); + dfItem.editData(data -> data.setHypercubeStringValue("codetemplatedata", "{\"author\":\"CodeClient\",\"name\":\"Template to be placed\",\"version\":1,\"code\":\"" + code + "\"}")); + return dfItem.getItemStack(); } /** @@ -110,11 +95,11 @@ public static Template templateItem(ItemStack item) { } public static void addLore(ItemStack stack, Text... lore) { - var display = Objects.requireNonNullElse(stack.getSubNbt("display"), new NbtCompound()); - var loreList = new NbtList(); - for (Text line : lore) loreList.add(Utility.textToNBT(Text.empty().append(line))); - display.put("Lore", loreList); - stack.setSubNbt("display", display); + DFItem item = DFItem.of(stack); + List currentLore = item.getLore(); + ArrayList newLore = new ArrayList<>(currentLore); + newLore.addAll(List.of(lore)); + item.setLore(newLore); } public static void sendHandItem(ItemStack item) { @@ -131,12 +116,8 @@ public static List templatesInInventory() { ArrayList templates = new ArrayList<>(); for (int i = 0; i < (27 + 9); i++) { ItemStack item = inv.getStack(i); - if (!item.hasNbt()) continue; - NbtCompound nbt = item.getNbt(); - if (nbt == null || !nbt.contains("PublicBukkitValues")) continue; - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - if (!publicBukkit.contains("hypercube:codetemplatedata")) continue; - templates.add(item); + DFItem dfItem = DFItem.of(item); + if (dfItem.hasHypercubeKey("codetemplatedata")) templates.add(item); } return templates; } @@ -182,7 +163,7 @@ public static void sendMessage(Text message, @Nullable ChatType type) { .append(Text.literal(" ")) .append(message), false); if (type == ChatType.FAIL) { - player.playSound(SoundEvent.of(new Identifier("minecraft:block.note_block.didgeridoo")), SoundCategory.PLAYERS, 2, 0); + player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_DIDGERIDOO.value(), 2, 0); } } } @@ -193,7 +174,7 @@ public static void sendMessage(Text message, @Nullable ChatType type) { * @return Usable in lore and as a name in nbt. */ public static NbtString textToNBT(Text text) { - JsonElement json = Text.Serialization.toJsonTree(text); + JsonElement json = TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, text).getOrThrow(); if (json.isJsonObject()) { JsonObject obj = (JsonObject) json; @@ -213,7 +194,7 @@ public static NbtString textToNBT(Text text) { */ public static MutableText textFromString(String text) { MutableText output = Text.empty().setStyle(Text.empty().getStyle().withColor(TextColor.fromRgb(0xFFFFFF)).withItalic(false)); - MutableText component = Text.empty(); + MutableText component = Text.empty().styled(s -> s.withItalic(false)); Matcher m = Pattern.compile("§(([0-9a-kfmnolr])|x(§[0-9a-f]){6})|[^§]+").matcher(text); while (m.find()) { @@ -234,17 +215,14 @@ public static MutableText textFromString(String text) { } public static boolean isGlitchStick(ItemStack item) { - if (item == null) return false; - NbtCompound nbt = item.getNbt(); - if (nbt == null) return false; - if (nbt.isEmpty()) return false; - if (Objects.equals(nbt.getCompound("PublicBukkitValues").getString("hypercube:item_instance"), "")) - return false; - return Objects.equals(nbt.getCompound("display").getString("Name"), "{\"italic\":false,\"color\":\"red\",\"text\":\"Glitch Stick\"}"); + DFItem dfItem = DFItem.of(item); + if (!dfItem.hasHypercubeKey("item_instance")) return false; + return Objects.equals(dfItem.getName(), Text.literal("Glitch Stick").setStyle(Style.EMPTY.withColor(Formatting.RED).withItalic(false))); } public static HashMap getBlockTagLines(ItemStack item) { - NbtCompound display = item.getSubNbt("display"); + // Not migrated to 1.21 due to not being called anywhere. + /*NbtCompound display = item.getSubNbt("display"); NbtList lore = (NbtList) display.get("Lore"); if (lore == null) throw new NullPointerException("Can't get lore."); @@ -260,7 +238,8 @@ public static HashMap getBlockTagLines(ItemStack item) { options.put(index, data.replaceAll("» ", "")); } - return options; + return options;*/ + return null; } public static void textToString(Text content, StringBuilder build, GetActionDump.ColorMode colorMode) { @@ -320,23 +299,23 @@ public static String fromTrimmed(String trimmedUUID) { } /** - * Turns a {@link Component} to an {@link OrderedText} + * Turns a {@link net.kyori.adventure.text.Component} to an {@link OrderedText} * * @param component The component to convert * @return The converted component */ public static OrderedText componentToOrderedText(Component component) { - return nonWrappingSerializer().serialize(component).asOrderedText(); + return NonWrappingComponentSerializer.INSTANCE.serialize(component).asOrderedText(); } /** - * Turns a {@link Component} to a {@link Text} + * Turns a {@link net.kyori.adventure.text.Component} to a {@link Text} * * @param component The component to convert * @return The converted component */ public static Text componentToText(Component component) { - return nonWrappingSerializer().serialize(component); + return NonWrappingComponentSerializer.INSTANCE.serialize(component); } } \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/action/Action.java b/src/main/java/dev/dfonline/codeclient/action/Action.java index 39b82e2d..a89658bc 100644 --- a/src/main/java/dev/dfonline/codeclient/action/Action.java +++ b/src/main/java/dev/dfonline/codeclient/action/Action.java @@ -1,10 +1,7 @@ package dev.dfonline.codeclient.action; import dev.dfonline.codeclient.Callback; -import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Feature; -import dev.dfonline.codeclient.location.Location; -import net.minecraft.network.packet.Packet; public abstract class Action extends Feature { private final Callback callback; diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/GetPlotSize.java b/src/main/java/dev/dfonline/codeclient/action/impl/GetPlotSize.java index 7863bf94..8535fcd2 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/GetPlotSize.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/GetPlotSize.java @@ -4,12 +4,11 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.action.Action; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.location.Dev; import dev.dfonline.codeclient.location.Plot; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtString; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; @@ -28,11 +27,8 @@ public GetPlotSize(Callback callback) { public void init() { recoverMainHand = CodeClient.MC.player.getInventory().getStack(0); ItemStack item = Items.PAPER.getDefaultStack(); - NbtCompound compound = new NbtCompound(); - NbtCompound publicBukkitValues = new NbtCompound(); - publicBukkitValues.put("hypercube:varitem", NbtString.of("{\"id\":\"loc\",\"data\":{\"isBlock\":false,\"loc\":{\"x\":0.0,\"y\":256.0,\"z\":1000.0,\"pitch\":0.0,\"yaw\":0.0}}}")); - compound.put("PublicBukkitValues", publicBukkitValues); - item.setNbt(compound); + DFItem dfItem = new DFItem(item); + dfItem.getItemData().setHypercubeStringValue("varitem", "{\"id\":\"loc\",\"data\":{\"isBlock\":false,\"loc\":{\"x\":0.0,\"y\":256.0,\"z\":1000.0,\"pitch\":0.0,\"yaw\":0.0}}}"); Utility.makeHolding(item); } @@ -53,7 +49,7 @@ public boolean onReceivePacket(Packet packet) { if (CodeClient.location instanceof Dev plot) { if (step == Step.TP && packet instanceof PlayerPositionLookS2CPacket position) { step = Step.DONE; - double size = position.getZ() - plot.getZ(); + double size = position.change().position().z - plot.getZ(); if (size > 49) { plot.setSize(Plot.Size.BASIC); } diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java b/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java index d898b4c2..592662cb 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java @@ -54,7 +54,7 @@ public boolean onReceivePacket(Packet packet) { if (locationItem == null) return super.onReceivePacket(packet); if (packet instanceof PlayerPositionLookS2CPacket tp) { if (CodeClient.MC.getNetworkHandler() == null || CodeClient.MC.player == null) return false; - CodeClient.MC.getNetworkHandler().sendPacket(new TeleportConfirmC2SPacket(tp.getTeleportId())); + CodeClient.MC.getNetworkHandler().sendPacket(new TeleportConfirmC2SPacket(tp.teleportId())); CodeClient.MC.player.setPosition(target); active = false; callback(); @@ -134,7 +134,7 @@ private void hackTowards() { for (int i = 0; i < Math.min(lastTickPackets + 5, 50); i++) { thisTickPackets++; this.doNotSuppress = true; - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true)); } } thisTickPackets++; diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/MoveToSpawn.java b/src/main/java/dev/dfonline/codeclient/action/impl/MoveToSpawn.java index 2d81f560..c3f779b3 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/MoveToSpawn.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/MoveToSpawn.java @@ -36,7 +36,7 @@ public boolean onReceivePacket(Packet packet) { public boolean onTeleport(PlayerPositionLookS2CPacket packet) { Dev plot = (Dev) CodeClient.location; if (currentStep == Step.WAIT_FOR_TELEPORT) { - plot.setDevSpawn(packet.getX(), packet.getZ()); + plot.setDevSpawn(packet.change().position().x, packet.change().position().z); currentStep = Step.MOVE_TO_CORNER; } return false; diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/PlaceTemplates.java b/src/main/java/dev/dfonline/codeclient/action/impl/PlaceTemplates.java index 9cc2e7b0..4e3583f8 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/PlaceTemplates.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/PlaceTemplates.java @@ -5,6 +5,7 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.action.Action; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.template.Template; import dev.dfonline.codeclient.hypercube.template.TemplateBlock; import dev.dfonline.codeclient.location.Dev; @@ -12,7 +13,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.entity.SignText; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; @@ -78,13 +78,9 @@ public PlaceTemplates(HashMap templates, Callback callback) var scan = dev.scanForSigns(Pattern.compile(".*")); ArrayList leftOvers = new ArrayList<>(templates); for (ItemStack item : templates) { - if (!item.hasNbt()) continue; - NbtCompound nbt = item.getNbt(); - if (nbt == null) continue; - if (!nbt.contains("PublicBukkitValues")) continue; - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - if (!publicBukkit.contains("hypercube:codetemplatedata")) continue; - String codeTemplateData = publicBukkit.getString("hypercube:codetemplatedata"); + DFItem dfItem = new DFItem(item); + String codeTemplateData = dfItem.getHypercubeStringValue("codetemplatedata"); + if (codeTemplateData.isEmpty()) continue; try { Template template = Template.parse64(JsonParser.parseString(codeTemplateData).getAsJsonObject().get("code").getAsString()); if (template == null || template.blocks.isEmpty()) continue; diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/ScanPlot.java b/src/main/java/dev/dfonline/codeclient/action/impl/ScanPlot.java index 97c6c7d2..b0043975 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/ScanPlot.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/ScanPlot.java @@ -107,7 +107,7 @@ public void tick() { private class PickUpBlock extends Action { - private BlockPos pos; + private final BlockPos pos; private Integer ticks = 0; public PickUpBlock(BlockPos pos, Callback callback) { diff --git a/src/main/java/dev/dfonline/codeclient/command/CommandManager.java b/src/main/java/dev/dfonline/codeclient/command/CommandManager.java index 4941be25..d13b341a 100644 --- a/src/main/java/dev/dfonline/codeclient/command/CommandManager.java +++ b/src/main/java/dev/dfonline/codeclient/command/CommandManager.java @@ -36,7 +36,8 @@ public class CommandManager { new CommandTemplatePlacer(), new CommandUuid(), new CommandWidthDump(), - new CommandWorldPlot() + new CommandWorldPlot(), + new CommandClearQueue() ); public static void init(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) { diff --git a/src/main/java/dev/dfonline/codeclient/command/CommandSender.java b/src/main/java/dev/dfonline/codeclient/command/CommandSender.java new file mode 100644 index 00000000..f2fff52f --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/CommandSender.java @@ -0,0 +1,48 @@ +package dev.dfonline.codeclient.command; + +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.RateLimiter; + +import java.util.ArrayDeque; + +/** + * Queues up commands and sends them to avoid getting kicked for spam. + */ +public class CommandSender { + // Vanilla Minecraft uses 20 increment 200 threshold. + // We have a lower threshold for extra safety and to account for lag. + private static final RateLimiter rateLimiter = new RateLimiter(20, 140); + private static final ArrayDeque commandQueue = new ArrayDeque<>(); + + public static void queue(String command) { + commandQueue.add(command); + } + + public static void clearQueue() { + commandQueue.clear(); + } + + public static int queueSize() { + return commandQueue.size(); + } + + + public static void tick() { + rateLimiter.tick(); + if (CodeClient.MC.getNetworkHandler() == null) return; + if (!rateLimiter.isRateLimited() && !commandQueue.isEmpty()) { + CodeClient.MC.getNetworkHandler().sendCommand(commandQueue.pop()); + // No need to increment here, since our packet listener will do that for us. (Event#onSendPacket) + } + } + + + /** + * Registers a command send. + * This should be called whenever a command or chat message is sent to the server. + */ + public static void registerCommandSend() { + rateLimiter.increment(); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandCCConfig.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandCCConfig.java index 4b362f2e..67774a88 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandCCConfig.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandCCConfig.java @@ -88,17 +88,6 @@ public LiteralArgumentBuilder create(LiteralArgumentB } Utility.sendMessage(Text.translatable("codeclient.config.command.set.fail", Text.literal(option).formatted(Formatting.YELLOW), Text.literal(value).formatted(Formatting.YELLOW)), ChatType.FAIL); return -1; - } else if (field.getType().equals(int.class)) { - try { - var number = Integer.parseInt(value); - field.set(Config.getConfig(), number); - Utility.sendMessage(Text.translatable("codeclient.config.command.set", Text.literal(option).formatted(Formatting.AQUA), Text.literal(String.valueOf(number)).formatted(Formatting.AQUA)), ChatType.SUCCESS); - Config.getConfig().save(); - return 0; - } catch (NumberFormatException e) { - Utility.sendMessage(Text.translatable("codeclient.config.command.set.fail", Text.literal(option).formatted(Formatting.YELLOW), Text.literal(value).formatted(Formatting.YELLOW)), ChatType.FAIL); - return -1; - } } Utility.sendMessage(Text.translatable("codeclient.config.command.fail"), ChatType.FAIL); } catch (Exception ignored) { diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandClearQueue.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandClearQueue.java new file mode 100644 index 00000000..b5964eba --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandClearQueue.java @@ -0,0 +1,32 @@ +package dev.dfonline.codeclient.command.impl; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import dev.dfonline.codeclient.ChatType; +import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.command.Command; +import dev.dfonline.codeclient.command.CommandSender; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.text.Text; + +public class CommandClearQueue extends Command { + + @Override + public String name() { + return "ccclearqueue"; + } + + @Override + public LiteralArgumentBuilder create(LiteralArgumentBuilder cmd, CommandRegistryAccess registryAccess) { + return cmd.executes(context -> { + if (CommandSender.queueSize() > 0) { + CommandSender.clearQueue(); + Utility.sendMessage(Text.translatable("codeclient.action.clearqueue.success"), ChatType.SUCCESS); + } else { + Utility.sendMessage(Text.translatable("codeclient.action.clearqueue.empty"), ChatType.FAIL); + } + + return 1; + }); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandDFGive.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandDFGive.java index 040b2f91..8aa137ca 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandDFGive.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandDFGive.java @@ -82,7 +82,7 @@ private void giveItem(ItemStack item, int count) { CodeClient.MC.player.giveItemStack(item); Utility.sendInventory(); } else { - Utility.sendMessage(Text.translatable("codeclient.command.dfgive.count_above_max", item.getItem(), item.getMaxCount()), ChatType.FAIL); + Utility.sendMessage(Text.translatable("codeclient.command.dfgive.count_above_max", item.getMaxCount()), ChatType.FAIL); } } } diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandItemData.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandItemData.java index 3a88b77a..4d42bddb 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandItemData.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandItemData.java @@ -10,7 +10,7 @@ import net.minecraft.command.CommandRegistryAccess; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; import net.minecraft.text.ClickEvent; @@ -33,7 +33,9 @@ public LiteralArgumentBuilder create(LiteralArgumentB ClientPlayerEntity player = CodeClient.MC.player; if (player == null) return -1; ItemStack item = player.getInventory().getMainHandStack(); - NbtCompound nbt = item.getNbt(); + if (CodeClient.MC.world == null) return -1; + NbtElement nbt = item.toNbt(CodeClient.MC.world.getRegistryManager()); + if (nbt == null) { Utility.sendMessage(Text.translatable("codeclient.command.itemdata.no_nbt"), ChatType.FAIL); return 0; @@ -44,7 +46,7 @@ public LiteralArgumentBuilder create(LiteralArgumentB .append(Text.literal(" ").setStyle(Style.EMPTY.withStrikethrough(false).withColor(Formatting.AQUA)) .append(Text.translatable("codeclient.command.itemdata.header", Text.empty().formatted(Formatting.WHITE).append(item.getName()))) .append(Text.literal(" "))) - .append(" ".repeat(15)) + .append(" ".repeat(15)), false ); player.sendMessage(Text.literal(nbt.toString()), false); diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandLoad.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandLoad.java index 3eee2934..297a0183 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandLoad.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandLoad.java @@ -6,6 +6,7 @@ import dev.dfonline.codeclient.FileManager; import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.command.TemplateActionCommand; +import dev.dfonline.codeclient.data.DFItem; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.item.ItemStack; @@ -39,8 +40,9 @@ public LiteralArgumentBuilder create(LiteralArgumentB try { byte[] data = Files.readAllBytes(path); ItemStack template = Utility.makeTemplate(new String(Base64.getEncoder().encode(data))); - template.setCustomName(Text.empty().formatted(Formatting.RED).append("Saved Template").append(Text.literal(" » ").formatted(Formatting.DARK_RED, Formatting.BOLD)).append(String.valueOf(FileManager.templatesPath().relativize(path)))); - CodeClient.MC.player.giveItemStack(template); + DFItem dfItem = new DFItem(template); + dfItem.setName(Text.empty().formatted(Formatting.RED).append("Saved Template").append(Text.literal(" » ").formatted(Formatting.DARK_RED, Formatting.BOLD)).append(String.valueOf(FileManager.templatesPath().relativize(path)))); + CodeClient.MC.player.giveItemStack(dfItem.getItemStack()); Utility.sendInventory(); } catch (Exception e) { Utility.sendMessage(Text.translatable("codeclient.files.error.read_file", path), ChatType.FAIL); diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java index ea4f35c7..f6813e37 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java @@ -49,4 +49,4 @@ public LiteralArgumentBuilder create(LiteralArgumentB private static @NotNull Component getText(CommandContext context) { return MM.deserialize(context.getArgument("text", String.class)); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/config/Config.java b/src/main/java/dev/dfonline/codeclient/config/Config.java index b6efe45b..c42cb94e 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -34,7 +34,6 @@ public class Config { public int AutoJoinPlotId = 0; public CharSetOption FileCharSet = CharSetOption.UTF_8; public boolean InvisibleBlocksInDev = false; - public float ReachDistance = 5; public boolean AutoFly = false; public LayerInteractionMode CodeLayerInteractionMode = LayerInteractionMode.AUTO; public boolean FocusSearch = false; @@ -72,7 +71,7 @@ public class Config { public int RecentValues = 0; public Boolean ValueDetails = true; public Boolean PhaseToggle = false; - public static DestroyItemReset DestroyItemResetMode = DestroyItemReset.OFF; + public DestroyItemReset DestroyItemResetMode = DestroyItemReset.OFF; public boolean ShowVariableScopeBelowName = true; public boolean DevNodes = false; public boolean GiveUuidNameStrings = true; @@ -121,7 +120,6 @@ public void save() { object.addProperty("AutoJoinPlotId", AutoJoinPlotId); object.addProperty("FileCharSet", FileCharSet.name()); object.addProperty("InvisibleBlocksInDev", InvisibleBlocksInDev); - object.addProperty("ReachDistance", ReachDistance); object.addProperty("AutoFly", AutoFly); object.addProperty("CodeLayerInteractionMode", CodeLayerInteractionMode.name()); object.addProperty("FocusSearch", FocusSearch); @@ -158,7 +156,7 @@ public void save() { object.addProperty("ActionViewerLocation",ActionViewerLocation.name()); object.addProperty("RecentValues", RecentValues); object.addProperty("PhaseToggle", PhaseToggle); - object.addProperty("DestroyItemReset", DestroyItemResetMode.name()); + object.addProperty("DestroyItemResetMode", DestroyItemResetMode.name()); object.addProperty("ShowVariableScopeBelowName", ShowVariableScopeBelowName); object.addProperty("DevNodes", DevNodes); object.addProperty("GiveUuidNameStrings", GiveUuidNameStrings); @@ -557,7 +555,7 @@ public YetAnotherConfigLib getLibConfig() { ) .controller(integerOption -> IntegerFieldControllerBuilder.create(integerOption).range(0, 100)) .build()) - .option(Option.createBuilder(Config.DestroyItemReset.class) + .option(Option.createBuilder(DestroyItemReset.class) .name(Text.translatable("codeclient.config.destroy_item_reset.name")) .description(OptionDescription.of(Text.translatable("codeclient.config.destroy_item_reset.description"))) .binding( @@ -565,7 +563,7 @@ public YetAnotherConfigLib getLibConfig() { () -> DestroyItemResetMode, opt -> DestroyItemResetMode = opt ) - .controller(nodeOption -> () -> new EnumController<>(nodeOption, Config.DestroyItemReset.class)) + .controller(nodeOption -> () -> new EnumController<>(nodeOption, DestroyItemReset.class)) .build()) .option(Option.createBuilder(boolean.class) .name(Text.translatable("codeclient.config.givestrings")) diff --git a/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java b/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java index 58343a62..471cc42a 100644 --- a/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java +++ b/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java @@ -1,12 +1,14 @@ package dev.dfonline.codeclient.config; import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.command.CommandSender; import dev.dfonline.codeclient.dev.InteractionManager; import dev.dfonline.codeclient.dev.menu.devinventory.DevInventoryScreen; import dev.dfonline.codeclient.location.Dev; import dev.dfonline.codeclient.location.Play; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.block.Blocks; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; import net.minecraft.util.Hand; @@ -37,6 +39,11 @@ public class KeyBinds { */ public static KeyBinding previewItemTags; + /** + * Plays all the sounds in a code chest. + */ + public static KeyBinding previewSounds; + /** * Toggles between Play and Dev modes. */ @@ -57,12 +64,13 @@ public static void init() { teleportBackward = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.tp.backward", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.navigation")); previewItemTags = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.preview_item_tags", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); + previewSounds = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.preview_sounds", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); playDev = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.playDev", InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); playBuild = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.playBuild", InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); } public static void tick() { - var player = CodeClient.MC.player; + ClientPlayerEntity player = CodeClient.MC.player; if (player != null) { checkTp(teleportLeft, new Vec3d(0, 0, -2)); checkTp(teleportRight, new Vec3d(0, 0, 2)); @@ -97,10 +105,10 @@ public static void tick() { if(CodeClient.MC.getNetworkHandler() == null) return; if (playDev.wasPressed()) - CodeClient.MC.getNetworkHandler().sendCommand(CodeClient.location instanceof Play ? "dev" : "play"); + CommandSender.queue(CodeClient.location instanceof Play ? "dev" : "play"); if (playBuild.wasPressed()) - CodeClient.MC.getNetworkHandler().sendCommand(CodeClient.location instanceof Play ? "build" : "play"); + CommandSender.queue(CodeClient.location instanceof Play ? "build" : "play"); } private static void checkTp(KeyBinding keyBinding, Vec3d offset) { diff --git a/src/main/java/dev/dfonline/codeclient/data/DFItem.java b/src/main/java/dev/dfonline/codeclient/data/DFItem.java new file mode 100644 index 00000000..6dc6ad4e --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/DFItem.java @@ -0,0 +1,221 @@ +package dev.dfonline.codeclient.data; + +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.*; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.util.Unit; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Consumer; + +/** + * Represents an item, with configurable data, lore, name, and more. + */ +public class DFItem { + ItemStack item; + ItemData data; + + /** + * Creates a new DFItem from an ItemStack. + * + * @param item The item to create the DFItem from. + */ + public DFItem(ItemStack item) { + this.item = item; + this.data = new ItemData(item); + } + + /** + * Creates a new DFItem from an ItemStack. + * + * @param item The item to create the DFItem from. + * @return The new DFItem. + */ + public static DFItem of(ItemStack item) { + return new DFItem(item); + } + + /** + * Gets the item's data. + * + * @return The item's data. + */ + public ItemData getItemData() { + return data; + } + + /** + * Sets the item's data. + * + * @param itemData The new data to set. + */ + public void setItemData(ItemData itemData) { + data = itemData; + } + + /** + * Edits the item's data with a consumer, creates the data if it doesn't exist. + *
+ * Example: + *
{@code
+     * item.editData(data -> {
+     *    data.setStringValue("key", "value");
+     * });
+     * }
+ * + * @param consumer The consumer to edit the data with. + */ + public void editData(Consumer consumer) { + if (!data.hasCustomData()) data = ItemData.getEmpty(); + consumer.accept(data); + } + + /** + * Delegates to {@link ItemData#getHypercubeStringValue(String)}. + * + * @param key The key to get, without the hypercube: prefix. + * @return The value of the key, or an empty string if it doesn't exist. + */ + public String getHypercubeStringValue(String key) { + var itemData = getItemData(); + if (itemData == null) return ""; + return itemData.getHypercubeStringValue(key); + } + + /** + * Delegates to {@link ItemData#hasHypercubeKey(String)}. + * + * @param key The key to check, without the hypercube: prefix. + * @return Whether the key exists. + */ + public boolean hasHypercubeKey(String key) { + var itemData = getItemData(); + if (itemData == null) return false; + return itemData.hasHypercubeKey(key); + } + + /** + * Converts the DFItem back into an ItemStack. + * + * @return The ItemStack. + */ + public ItemStack getItemStack() { + if (data != null) item.set(DataComponentTypes.CUSTOM_DATA, getItemData().toComponent()); + return item; + } + + /** + * Delegates to {@link ItemData#getPublicBukkitValues()}. + * + * @return The PublicBukkitValues. + */ + public PublicBukkitValues getPublicBukkitValues() { + return getItemData().getPublicBukkitValues(); + } + + /** + * Gets the lore of the item. + * + * @return The lore of the item. + */ + public List getLore() { + LoreComponent loreComponent = item.get(DataComponentTypes.LORE); + if (loreComponent == null) return List.of(); + return loreComponent.lines(); + } + + /** + * Sets the lore of the item. + * + * @param lore The new lore to set. + */ + public void setLore(List lore) { + item.set(DataComponentTypes.LORE, new LoreComponent(lore)); + } + + /** + * Gets the name of the item. + * + * @return The name of the item. + */ + public Text getName() { + return item.getName(); + } + + /** + * Sets the name of the item. + * + * @param name The new name to set. + */ + public void setName(Text name) { + item.set(DataComponentTypes.CUSTOM_NAME, name); + } + + /** + * Hides additional information about the item, such as additional tooltip, jukebox playable, fireworks, and attribute modifiers. + */ + public void hideFlags() { + item.set(DataComponentTypes.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE); + item.remove(DataComponentTypes.JUKEBOX_PLAYABLE); + item.remove(DataComponentTypes.FIREWORKS); + item.remove(DataComponentTypes.ATTRIBUTE_MODIFIERS); + } + + /** + * Sets the dye color of the item. + * + * @param color The new dye color to set. + */ + public void setDyeColor(int color) { + item.set(DataComponentTypes.DYED_COLOR, new DyedColorComponent(color, false)); + } + + /** + * Sets the custom model data of the item. + * + * @param modelData The new custom model data to set. + */ + public void setCustomModelData(int modelData) { + item.set(DataComponentTypes.CUSTOM_MODEL_DATA, new CustomModelDataComponent(modelData)); + } + + /** + * Sets the profile of the item, for use with player heads. + * + * @param uuid The UUID of the player. + * @param value The value of the profile. + * @param signature The signature of the profile. + */ + public void setProfile(UUID uuid, String value, String signature) { + PropertyMap map = new PropertyMap(); + map.put("textures", new Property("textures", value, signature)); + item.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.empty(), Optional.ofNullable(uuid), map)); + } + + /** + * Removes the item's data. + */ + public void removeItemData() { + item.remove(DataComponentTypes.CUSTOM_DATA); + data = null; + } + + + // This method doesn't fit the theme of entire abstraction of item data, but its use case is very specific. + + /** + * Gets the container of the item. + * + * @return The container of the item. + */ + @Nullable + public ContainerComponent getContainer() { + return item.get(DataComponentTypes.CONTAINER); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/ItemData.java b/src/main/java/dev/dfonline/codeclient/data/ItemData.java new file mode 100644 index 00000000..a4c28ba1 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/ItemData.java @@ -0,0 +1,173 @@ +package dev.dfonline.codeclient.data; + +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.NbtComponent; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; +import org.jetbrains.annotations.Nullable; + +public class ItemData { + private NbtCompound customData; + private PublicBukkitValues publicBukkitValues; + + /** + * Creates a new ItemData from an ItemStack. + * + * @param item The item to create the ItemData from. + * @implNote Most operations won't work if the item doesn't have custom data. + */ + public ItemData(ItemStack item) { + var customDataComponent = item.get(DataComponentTypes.CUSTOM_DATA); + if (customDataComponent != null) { + customData = customDataComponent.copyNbt(); + } + } + + /** + * Creates an ItemData with an existing empty NbtCompound. + */ + private ItemData() { + this.customData = new NbtCompound(); + } + + /** + * Gets the NBT Compound of the CUSTOM_DATA item component, applying the PublicBukkitValues along the way. + * + * @return The NBT Compound of the CUSTOM_DATA item component. + * @apiNote This should only be used in very specific cases, the entire point of this class is to abstract the NBT data. + */ + public NbtCompound getNbt() { + // Should only be used in very specific cases, the entire point of this class is to abstract the NBT data. + if (customData == null) { + customData = new NbtCompound(); + } + if (publicBukkitValues != null) + customData.put(PublicBukkitValues.PUBLIC_BUKKIT_VALUES_KEY, publicBukkitValues.getNbt()); + return customData; + } + + /** + * Creates an empty ItemData. + */ + public static ItemData getEmpty() { + return new ItemData(); + } + + /** + * Checks if the item data has custom data. + * + * @return Whether the item data has custom data. + */ + public boolean hasCustomData() { + return customData != null; + } + + /** + * Gets the PublicBukkitValues from the item data. + * + * @return The PublicBukkitValues. + */ + @Nullable + public PublicBukkitValues getPublicBukkitValues() { + if (publicBukkitValues == null) { + publicBukkitValues = PublicBukkitValues.fromItemData(this); + } + return publicBukkitValues; + } + + /** + * Sets the PublicBukkitValues of the item data. + * + * @param publicBukkitValues The PublicBukkitValues to set. + */ + public void setPublicBukkitValues(PublicBukkitValues publicBukkitValues) { + this.publicBukkitValues = publicBukkitValues; + } + + /** + * Removes a key from the custom data. + * + * @param key The key to remove. + */ + public void removeKey(String key) { + customData.remove(key); + } + + /** + * Gets a String value of a key. + * + * @param key The key to get. + * @return The value of the key, or an empty string if it doesn't exist. + */ + public String getStringValue(String key) { + return customData.getString(key); + } + + /** + * Gets a String value of a key. + * + * @param key The key to get. + * @param value The value of the key. + */ + public void setStringValue(String key, String value) { + customData.putString(key, value); + } + + /** + * Checks if the custom data has a key. + * + * @param key The key to check. + * @return Whether the custom data has the key. + */ + public boolean hasKey(String key) { + return customData.contains(key); + } + + /** + * Delegates to {@link PublicBukkitValues#getHypercubeStringValue(String)}. + * + * @param key The key to get, without the hypercube: prefix. + * @return The value of the key, or an empty string if it doesn't exist. + */ + public String getHypercubeStringValue(String key) { + var publicBukkitValues = getPublicBukkitValues(); + if (publicBukkitValues == null) return ""; + return publicBukkitValues.getHypercubeStringValue(key); + } + + /** + * Delegates to {@link PublicBukkitValues#setHypercubeStringValue(String, String)}. + * + * @param key The key to set, without the hypercube: prefix. + * @param value The value to set. + */ + public void setHypercubeStringValue(String key, String value) { + var publicBukkitValues = getPublicBukkitValues(); + if (publicBukkitValues == null) { + publicBukkitValues = PublicBukkitValues.getEmpty(); + } + publicBukkitValues.setHypercubeStringValue(key, value); + } + + /** + * Delegates to {@link PublicBukkitValues#hasHypercubeKey(String)}. + * + * @param key The key to check, without the hypercube: prefix. + * @return Whether the key exists. + */ + public boolean hasHypercubeKey(String key) { + var publicBukkitValues = getPublicBukkitValues(); + if (publicBukkitValues == null) return false; + return publicBukkitValues.hasHypercubeKey(key); + } + + /** + * Converts the item data to a NbtComponent. + * + * @return The NbtComponent. + * @apiNote This should only be used in very specific cases, the entire point of this class is to abstract the NBT data. + */ + public NbtComponent toComponent() { + return NbtComponent.of(getNbt()); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/PublicBukkitValues.java b/src/main/java/dev/dfonline/codeclient/data/PublicBukkitValues.java new file mode 100644 index 00000000..f7306c93 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/PublicBukkitValues.java @@ -0,0 +1,151 @@ +package dev.dfonline.codeclient.data; + +import dev.dfonline.codeclient.data.value.DataValue; +import net.minecraft.nbt.NbtCompound; +import org.jetbrains.annotations.Nullable; + +import java.util.Set; +import java.util.stream.Collectors; + +public class PublicBukkitValues { + public static final String PUBLIC_BUKKIT_VALUES_KEY = "PublicBukkitValues"; + /** + * The prefix for hypercube keys. + * + * @implNote This should only be used internally, if you find yourself using this, + * you're either doing something wrong or you're in a very specific use-case + * in which you should make a method for it in this class. + */ + private static final String HYPERCUBE_KEY_PREFIX = "hypercube:"; + + private final NbtCompound publicBukkitValues; + + private PublicBukkitValues(NbtCompound publicBukkitValues) { + this.publicBukkitValues = publicBukkitValues; + } + + /** + * Creates a new PublicBukkitValues from an ItemData. + * + * @param data The ItemData to create the PublicBukkitValues from. + * @return The new PublicBukkitValues. + * @implNote This method will return null if the ItemData does not have PublicBukkitValues. + */ + @Nullable + public static PublicBukkitValues fromItemData(ItemData data) { + var customData = data.getNbt(); + if (customData == null) return null; + var publicBukkitValues = customData.getCompound(PUBLIC_BUKKIT_VALUES_KEY); + if (publicBukkitValues == null) return null; + return new PublicBukkitValues(publicBukkitValues); + } + + /** + * Creates an empty PublicBukkitValues. + * + * @return The new empty PublicBukkitValues. + */ + public static PublicBukkitValues getEmpty() { + var empty = new NbtCompound(); + empty.put(PUBLIC_BUKKIT_VALUES_KEY, new NbtCompound()); + return new PublicBukkitValues(empty); + } + + /** + * Gets the NbtCompound of the PublicBukkitValues. + * + * @return The NbtCompound of the PublicBukkitValues. + * @apiNote This should only be used in very specific cases, the entire point of this class is to abstract the NBT data. + */ + public NbtCompound getNbt() { + return publicBukkitValues; + } + + /** + * Gets a String value of a hypercube key. + * + * @param key The key to get, without the hypercube: prefix. + * @return The value of the key. + */ + public String getHypercubeStringValue(String key) { + return publicBukkitValues.getString(HYPERCUBE_KEY_PREFIX + key); + } + + /** + * Gets a String value of a key. + * + * @param key The key to get. + * @return The value of the key. + */ + public String getStringValue(String key) { + return publicBukkitValues.getString(key); + } + + /** + * Gets a DataValue of a hypercube key. + * + * @param key The key to get, without the hypercube: prefix. + * @return The value of the key. + */ + public DataValue getHypercubeValue(String key) { + return DataValue.fromNbt(publicBukkitValues.get(HYPERCUBE_KEY_PREFIX + key)); + } + + /** + * Gets all the hypercube keys. + * + * @return The hypercube keys. + */ + public Set getHypercubeKeys() { + return publicBukkitValues.getKeys().stream().filter(key -> key.startsWith(HYPERCUBE_KEY_PREFIX)).map(key -> key.substring(10)).collect(Collectors.toSet()); + } + + /** + * Gets all the keys. + * + * @return The keys. + */ + public Set getKeys() { + return publicBukkitValues.getKeys(); + } + + /** + * Checks if the PublicBukkitValues has a hypercube key. + * + * @param key The key to check, without the hypercube: prefix. + * @return Whether the key exists. + */ + public boolean hasHypercubeKey(String key) { + return publicBukkitValues.contains(HYPERCUBE_KEY_PREFIX + key); + } + + /** + * Checks if the PublicBukkitValues has a key. + * + * @param key The key to check. + * @return Whether the key exists. + */ + public boolean hasKey(String key) { + return publicBukkitValues.contains(key); + } + + /** + * Sets a value of a key. + * + * @param key The key to set. + * @param value The value to set. + */ + public void setStringValue(String key, String value) { + publicBukkitValues.putString(key, value); + } + + /** + * Sets a value of a hypercube key. + * + * @param key The key to set, without the hypercube: prefix. + * @param value The value to set. + */ + public void setHypercubeStringValue(String key, String value) { + publicBukkitValues.putString(HYPERCUBE_KEY_PREFIX + key, value); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/value/DataValue.java b/src/main/java/dev/dfonline/codeclient/data/value/DataValue.java new file mode 100644 index 00000000..5b4c0896 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/value/DataValue.java @@ -0,0 +1,49 @@ +package dev.dfonline.codeclient.data.value; + +import net.minecraft.nbt.AbstractNbtNumber; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtString; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a value of a key that can be of a specific type, + * where recognized types can return the value as their respective data type. + */ +public class DataValue { + private final Object value; + + /** + * Creates a new DataValue with the given value. + * + * @param value The value of the DataValue. + */ + protected DataValue(Object value) { + this.value = value; + } + + /** + * Creates a new DataValue with the given value, where if a recognized type is given, + * a DataType of that type will be created. + * @param nbt The NbtElement to create the DataValue from. + * @return The new DataValue. + */ + public static DataValue fromNbt(NbtElement nbt) { + if (nbt instanceof NbtString) { + return new StringDataValue(nbt.asString()); + } + if (nbt instanceof AbstractNbtNumber) { + return new NumberDataValue(((AbstractNbtNumber) nbt).doubleValue()); + } + return new UnknownDataValue(nbt); + } + + /** + * Gets the value of the DataValue. + * @return The value of the DataValue as an Object. + * @implNote Make sure you really want to use this instead of the classes for specific types. + */ + @Nullable + public Object getValue() { + return value; + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/value/NumberDataValue.java b/src/main/java/dev/dfonline/codeclient/data/value/NumberDataValue.java new file mode 100644 index 00000000..1df6293c --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/value/NumberDataValue.java @@ -0,0 +1,14 @@ +package dev.dfonline.codeclient.data.value; + +/** + * Represents a value of a key that is a number. + */ +public class NumberDataValue extends DataValue { + public NumberDataValue(double value) { + super(value); + } + + public Double getValue() { + return (Double) super.getValue(); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/value/StringDataValue.java b/src/main/java/dev/dfonline/codeclient/data/value/StringDataValue.java new file mode 100644 index 00000000..5a2a9e49 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/value/StringDataValue.java @@ -0,0 +1,14 @@ +package dev.dfonline.codeclient.data.value; + +/** + * Represents a value of a key that is a string. + */ +public class StringDataValue extends DataValue { + public StringDataValue(String value) { + super(value); + } + + public String getValue() { + return (String) super.getValue(); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/data/value/UnknownDataValue.java b/src/main/java/dev/dfonline/codeclient/data/value/UnknownDataValue.java new file mode 100644 index 00000000..6165800d --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/data/value/UnknownDataValue.java @@ -0,0 +1,10 @@ +package dev.dfonline.codeclient.data.value; + +/** + * Represents a value of a key that can be of any type. + */ +public class UnknownDataValue extends DataValue { + public UnknownDataValue(Object value) { + super(value); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java b/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java index 8428f2b2..e626a187 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java +++ b/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java @@ -45,7 +45,7 @@ public float calculateBlockDelta(BlockPos pos) { } private static class RecentBlocks { - private ArrayList blocks = new ArrayList(); + private final ArrayList blocks = new ArrayList(); public void addBlock(BlockPos pos) { blocks.add(new RecentBlock(pos, new Date())); diff --git a/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java b/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java index 50afea20..bb490b20 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java +++ b/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java @@ -1,34 +1,23 @@ package dev.dfonline.codeclient.dev; -import dev.dfonline.codeclient.ChatType; import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Feature; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.command.CommandSender; import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.config.KeyBinds; -import dev.dfonline.codeclient.hypercube.item.Location; -import dev.dfonline.codeclient.location.Build; -import dev.dfonline.codeclient.location.Dev; -import net.minecraft.client.network.ClientPlayNetworkHandler; +import dev.dfonline.codeclient.location.Creator; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.item.ItemStack; -import net.minecraft.network.listener.PacketListener; +import net.minecraft.network.packet.CustomPayload; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket; import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundFromEntityS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; public class BuildPhaser extends Feature { @@ -37,8 +26,10 @@ public class BuildPhaser extends Feature { private Vec3d lastPos = new Vec3d(0, 0, 0); private boolean allowPacket = false; private boolean waitForTP = false; + private boolean updateVelocity = false; private boolean dontSpamBuildWarn = false; private boolean heldKeyCheck = false; + private Vec3d velocity = null; @Override public void reset() { @@ -49,6 +40,7 @@ public void reset() { waitForTP = false; dontSpamBuildWarn = false; heldKeyCheck = false; + velocity = null; } public boolean isClipping() { @@ -60,7 +52,7 @@ private boolean isPhaseToggleEnabled() { } public void tick() { - if (CodeClient.location instanceof Dev plot) { + if (CodeClient.location instanceof Creator plot) { if (plot.getX() == null) { if (KeyBinds.clipBind.wasPressed()) Utility.sendMessage(Text.translatable("codeclient.phaser.plot_origin")); @@ -90,26 +82,26 @@ public void tick() { Math.min(Math.max(player.getZ(), plot.getZ()), plot.getZ() + plot.assumeSize().size + 1) ); allowPacket = true; - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(lastPos.x, lastPos.y, lastPos.z, false)); + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(lastPos.x, lastPos.y, lastPos.z, false, true)); CodeClient.MC.player.getAbilities().flying = true; } } else if (clipping || waitForTP) { disableClipping(); } - if (CodeClient.location instanceof Build) { - if (KeyBinds.clipBind.isPressed() && !dontSpamBuildWarn) { - dontSpamBuildWarn = true; - Utility.sendMessage(Text.translatable("codeclient.phaser.dev_mode1", - Text.translatable("codeclient.phaser.dev_mode2") - .setStyle(Text.empty().getStyle() - .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/DFOnline/CodeClient/wiki/phaser#internal")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("chat.link.open"))) - ).formatted(Formatting.AQUA, Formatting.UNDERLINE)), - ChatType.FAIL); - } - if (dontSpamBuildWarn && !KeyBinds.clipBind.isPressed()) dontSpamBuildWarn = false; - } +// if (CodeClient.location instanceof Build) { +// if (KeyBinds.clipBind.isPressed() && !dontSpamBuildWarn) { +// dontSpamBuildWarn = true; +// Utility.sendMessage(Text.translatable("codeclient.phaser.dev_mode1", +// Text.translatable("codeclient.phaser.dev_mode2") +// .setStyle(Text.empty().getStyle() +// .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/DFOnline/CodeClient/wiki/phaser#internal")) +// .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("chat.link.open"))) +// ).formatted(Formatting.AQUA, Formatting.UNDERLINE)), +// ChatType.FAIL); +// } +// if (dontSpamBuildWarn && !KeyBinds.clipBind.isPressed()) dontSpamBuildWarn = false; +// } } public boolean onSendPacket(Packet packet) { @@ -117,13 +109,23 @@ public boolean onSendPacket(Packet packet) { allowPacket = false; return false; } + if (packet instanceof PlayerMoveC2SPacket.PositionAndOnGround && updateVelocity) { + var player = CodeClient.MC.player; + if (player != null && velocity != null) { + player.setVelocity(velocity); + } + updateVelocity = false; + return false; + } return clipping && (packet instanceof PlayerMoveC2SPacket || packet instanceof ClientCommandC2SPacket); } public boolean onReceivePacket(Packet packet) { if (!waitForTP) return false; if (packet instanceof PlayerPositionLookS2CPacket move) { - CodeClient.MC.getNetworkHandler().sendPacket(new TeleportConfirmC2SPacket(move.getTeleportId())); +// CodeClient.MC.getNetworkHandler().sendPacket(new TeleportConfirmC2SPacket(move.teleportId())); + + updateVelocity = true; return true; } if (packet instanceof EntityAnimationS2CPacket) return true; @@ -145,13 +147,26 @@ private void startClipping() { private void finishClipping() { disableClipping(); - if (CodeClient.location instanceof Dev plot) { + if (CodeClient.location instanceof Creator plot) { ClientPlayerEntity player = CodeClient.MC.player; PlayerAbilities abilities = player.getAbilities(); abilities.allowFlying = true; abilities.flying = wasFlying; waitForTP = true; + var size = plot.assumeSize(); + + var x = Math.min(Math.max(player.getX(), plot.getX()), plot.getX() + size.size + 1); + var y = player.getY(); + var z = Math.min(Math.max(player.getZ(), plot.getZ()), plot.getZ() + size.size + 1); + var pitch = player.getPitch(); + var yaw = player.getYaw(); + + velocity = player.getVelocity(); + + CommandSender.queue(String.format("ptp %s %s %s %s %s", x, y, z, pitch, yaw)); + + /* Vec3d pos = plot.getPos().relativize(player.getPos()); ItemStack location = new Location(pos.x, pos.y, pos.z, player.getPitch(), player.getYaw()).toStack(); @@ -168,13 +183,7 @@ private void finishClipping() { net.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); Utility.sendHandItem(lastItem); - - final int MAX_SPEED = 2; - - var velocity = CodeClient.MC.player.getVelocity(); - if(velocity.length() > MAX_SPEED) { - CodeClient.MC.player.setVelocity(velocity.normalize().multiply(MAX_SPEED)); - } + */ } } diff --git a/src/main/java/dev/dfonline/codeclient/dev/InteractionManager.java b/src/main/java/dev/dfonline/codeclient/dev/InteractionManager.java index 05f267c1..b3cac803 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/InteractionManager.java +++ b/src/main/java/dev/dfonline/codeclient/dev/InteractionManager.java @@ -4,8 +4,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import dev.dfonline.codeclient.CodeClient; -import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.location.Dev; import dev.dfonline.codeclient.switcher.ScopeSwitcher; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -15,24 +15,21 @@ import net.minecraft.block.Blocks; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.EntityAttachments; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; -import net.minecraft.nbt.NbtString; import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; import net.minecraft.text.MutableText; +import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.text.TextColor; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; import net.minecraft.util.function.BooleanBiFunction; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.*; @@ -106,7 +103,7 @@ public static boolean onBreakBlock(BlockPos pos) { private static void breakCodeBlock(BlockPos pos) { ClientWorld world = CodeClient.MC.world; - CodeClient.MC.getSoundManager().play(new PositionedSoundInstance(SoundEvent.of(new Identifier("minecraft:block.stone.break")), SoundCategory.BLOCKS, 2, 0.8F, Random.create(), pos)); + CodeClient.MC.getSoundManager().play(new PositionedSoundInstance(SoundEvents.BLOCK_STONE_BREAK, SoundCategory.BLOCKS, 2, 0.8F, Random.create(), pos)); world.setBlockState(pos, Blocks.AIR.getDefaultState()); world.setBlockState(pos.add(0, 1, 0), Blocks.AIR.getDefaultState()); world.setBlockState(pos.add(-1, 0, 0), Blocks.AIR.getDefaultState()); @@ -118,16 +115,14 @@ public static boolean onClickSlot(Slot slot, int button, SlotActionType actionTy CodeClient.onClickSlot(slot,button,actionType,syncId,revision); if (!slot.hasStack()) return false; ItemStack item = slot.getStack(); - if (!item.hasNbt()) return false; - NbtCompound nbt = item.getNbt(); - if (nbt != null && !nbt.contains("PublicBukkitValues")) return false; - if (nbt != null && nbt.get("PublicBukkitValues") instanceof NbtCompound bukkitValues) { - if (!bukkitValues.contains("hypercube:varitem")) return false; + DFItem dfItem = DFItem.of(item); + if (dfItem.hasHypercubeKey("varitem")) { try { - if (bukkitValues.get("hypercube:varitem") instanceof NbtString varItem) { + String varItem = dfItem.getItemData().getHypercubeStringValue("varitem"); + if (!varItem.isEmpty()) { if (!Config.getConfig().CustomTagInteraction) return false; if (actionType == SlotActionType.PICKUP_ALL) return false; - JsonElement varElement = JsonParser.parseString(varItem.asString()); + JsonElement varElement = JsonParser.parseString(varItem); if (!varElement.isJsonObject()) return false; JsonObject varObject = (JsonObject) varElement; if (!(Objects.equals(varObject.get("id").getAsString(), "bl_tag"))) return false; @@ -138,9 +133,8 @@ public static boolean onClickSlot(Slot slot, int button, SlotActionType actionTy CodeClient.MC.getNetworkHandler().sendPacket(new ClickSlotC2SPacket(syncId, revision, slot.getIndex(), button, SlotActionType.PICKUP, item, int2ObjectMap)); String selected = varObject.get("data").getAsJsonObject().get("option").getAsString(); - NbtCompound display = nbt.getCompound("display"); - NbtList lore = (NbtList) display.get("Lore"); - if (lore == null) return true; + List currentLore = dfItem.getLore(); + ArrayList lore = new ArrayList<>(currentLore); int i = 0; Integer tagStartIndex = null; @@ -148,8 +142,7 @@ public static boolean onClickSlot(Slot slot, int button, SlotActionType actionTy List options = new ArrayList<>(); // TODO: Utility.getBlockTagLines - for (NbtElement element : lore) { - Text text = Text.Serialization.fromJson(element.asString()); + for (Text text : lore) { if (text == null) return false; TextColor color = text.getStyle().getColor(); if (color == null) { @@ -178,15 +171,15 @@ public static boolean onClickSlot(Slot slot, int button, SlotActionType actionTy for (String option : options) { MutableText text = Text.empty(); if (optionIndex == newSelection) { - text.append(Text.literal("» ").formatted(Formatting.DARK_AQUA)).append(Text.literal(option).formatted(Formatting.AQUA)); + text.append(Text.literal("» ").setStyle(Style.EMPTY.withColor(Formatting.DARK_AQUA).withItalic(false))).append(Text.literal(option).setStyle(Style.EMPTY.withColor(Formatting.AQUA).withItalic(false))); } else text = Text.literal(option).setStyle(Text.empty().getStyle().withColor(TextColor.fromRgb(0x808080))); - lore.set(tagStartIndex + optionIndex, Utility.textToNBT(text)); + lore.set(tagStartIndex + optionIndex, text); optionIndex++; } - display.put("Lore", lore); - item.setSubNbt("display", display); - slot.setStack(item); + + dfItem.setLore(lore); + slot.setStack(dfItem.getItemStack()); return true; } } catch (Exception e) { @@ -199,7 +192,7 @@ public static boolean onClickSlot(Slot slot, int button, SlotActionType actionTy public static boolean isInsideWall(Vec3d playerPos) { Vec3d middlePos = playerPos.add(0, 0.75, 0); - Box box = new EntityDimensions(0.6f, 1.8f, true).getBoxAt(playerPos); //Box.of(middlePos, 0.6, 5, 0.6); + Box box = new EntityDimensions(0.6f, 1.8f, 1.8f * 0.85f, EntityAttachments.of(0.6f, 1.8f), true).getBoxAt(playerPos); //Box.of(middlePos, 0.6, 5, 0.6); CodeClient.LOGGER.info(String.valueOf(box)); return BlockPos.stream(box).anyMatch((pos) -> { BlockState blockState = CodeClient.MC.world.getBlockState(pos); @@ -256,14 +249,11 @@ public static boolean onItemInteract(PlayerEntity player, Hand hand) { if (player.isSneaking() || !Config.getConfig().ScopeSwitcher) return false; ItemStack stack = player.getStackInHand(hand); + DFItem dfItem = DFItem.of(stack); - NbtCompound nbt = stack.getNbt(); - if (nbt == null) return false; - NbtCompound pbv = (NbtCompound) nbt.get("PublicBukkitValues"); - if (pbv == null) return false; - NbtString varItem = (NbtString) pbv.get("hypercube:varitem"); - if (varItem == null) return false; - JsonObject var = JsonParser.parseString(varItem.asString()).getAsJsonObject(); + if (!dfItem.hasHypercubeKey("varitem")) return false; + String varItem = dfItem.getHypercubeStringValue("varitem"); + JsonObject var = JsonParser.parseString(varItem).getAsJsonObject(); if (!var.get("id").getAsString().equals("var")) return false; JsonObject data = var.get("data").getAsJsonObject(); String scopeName = data.get("scope").getAsString(); diff --git a/src/main/java/dev/dfonline/codeclient/dev/LastPos.java b/src/main/java/dev/dfonline/codeclient/dev/LastPos.java index daa8f1fa..9b685114 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/LastPos.java +++ b/src/main/java/dev/dfonline/codeclient/dev/LastPos.java @@ -6,9 +6,7 @@ import dev.dfonline.codeclient.location.Creator; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; +import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; public class LastPos { @@ -27,7 +25,7 @@ public static boolean tpBack() { if (CodeClient.location instanceof Creator plot && CodeClient.currentAction instanceof None) { if (plot.devPos == null) return false; CodeClient.currentAction = new GoTo(plot.devPos, () -> { - CodeClient.MC.player.playSound(SoundEvent.of(new Identifier("minecraft:entity.enderman.teleport")), SoundCategory.PLAYERS, 2, 1); + CodeClient.MC.player.playSound(SoundEvents.ENTITY_ENDERMAN_TELEPORT, 2, 1); CodeClient.currentAction = new None(); }); CodeClient.currentAction.init(); diff --git a/src/main/java/dev/dfonline/codeclient/dev/PreviewSoundChest.java b/src/main/java/dev/dfonline/codeclient/dev/PreviewSoundChest.java new file mode 100644 index 00000000..313be018 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/dev/PreviewSoundChest.java @@ -0,0 +1,42 @@ +package dev.dfonline.codeclient.dev; + +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.Feature; +import dev.dfonline.codeclient.config.KeyBinds; +import dev.dfonline.codeclient.dev.overlay.ChestPeeker; +import dev.dfonline.codeclient.hypercube.item.Sound; +import dev.dfonline.codeclient.hypercube.item.VarItem; +import dev.dfonline.codeclient.hypercube.item.VarItems; +import dev.dfonline.codeclient.location.Dev; +import net.minecraft.item.ItemStack; +import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; + +import java.util.Optional; + +public class PreviewSoundChest extends Feature { + + @Override + public void tick() { + if (KeyBinds.previewSounds.wasPressed() && CodeClient.MC.world != null && CodeClient.location instanceof Dev) { + if (CodeClient.MC.player == null) return; + ChestPeeker.pick(items -> { + for (ItemStack item : items) { + VarItem varItem = VarItems.parse(item); + if (!(varItem instanceof Sound sound)) continue; + Optional adSound = sound.getSoundId(); + if (adSound.isEmpty()) continue; + try { + CodeClient.MC.player.playSound( + (SoundEvent) SoundEvents.class.getDeclaredField(adSound.get().sound).get(null), + (float) sound.getVolume(), + (float) sound.getPitch() + ); + } catch (Exception ignored) { + + } + } + }); + } + } +} diff --git a/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java b/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java index 22ad1741..dba92ca4 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java +++ b/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java @@ -5,20 +5,15 @@ import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.location.Dev; import net.minecraft.block.Blocks; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.VertexRendering; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class RecentChestInsert extends Feature { private float alpha = 0; @@ -41,7 +36,10 @@ public void render(MatrixStack matrices, VertexConsumerProvider.Immediate vertex VoxelShape shape = CodeClient.MC.world.getBlockState(lastChest).getOutlineShape(CodeClient.MC.world, lastChest).offset(lastChest.getX(), lastChest.getY(), lastChest.getZ()); VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getLines()); int color = Config.getConfig().ChestHighlightColor; - WorldRenderer.drawShapeOutline(matrices, vertexConsumer, shape, -cameraX, -cameraY, -cameraZ, (float) (color >> 16) / 255, (float) ((color & 0xFF00) >> 8) / 255, (float) (color & 0x0000FF) / 255, Math.min(alpha, 1), true); + float a = Math.min(alpha, 1f); + + color = (int) (a * 255) << 24 | (color & 0x00FFFFFF); + VertexRendering.drawOutline(matrices, vertexConsumer, shape, -cameraX, -cameraY, -cameraZ, color); } } diff --git a/src/main/java/dev/dfonline/codeclient/dev/debug/Debug.java b/src/main/java/dev/dfonline/codeclient/dev/debug/Debug.java index ca8cba1d..a25ea04d 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/debug/Debug.java +++ b/src/main/java/dev/dfonline/codeclient/dev/debug/Debug.java @@ -41,7 +41,7 @@ public boolean onReceivePacket(Packet packet) { if (CodeClient.location instanceof Plot plot) { if (!Config.getConfig().CCDBUG) return false; if (packet instanceof OverlayMessageS2CPacket overlay) { - var txt = overlay.getMessage(); + var txt = overlay.text(); if (Text.empty().equals(txt)) { return false; } diff --git a/src/main/java/dev/dfonline/codeclient/dev/highlighter/ExpressionHighlighter.java b/src/main/java/dev/dfonline/codeclient/dev/highlighter/ExpressionHighlighter.java index ae123204..814fac11 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/highlighter/ExpressionHighlighter.java +++ b/src/main/java/dev/dfonline/codeclient/dev/highlighter/ExpressionHighlighter.java @@ -1,5 +1,4 @@ package dev.dfonline.codeclient.dev.highlighter; - import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Feature; import dev.dfonline.codeclient.config.Config; @@ -87,6 +86,8 @@ public HighlightedExpression format(String input, String partial, IntegerRange r var matcher = command.regex.matcher(input); if (!matcher.find(1)) { continue; + } else if (matcher.start() > 1) { + continue; } cachedHighlight = formatCommand(input, command, matcher.end(), range); return cachedHighlight; @@ -358,4 +359,4 @@ private enum CommandType { this.parseMinimessage = parseMinimessage; } } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java b/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java index b86f73af..9c4674a4 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java +++ b/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java @@ -22,11 +22,14 @@ import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; -/** - * Parses MiniMessage input, but leaves the tags in the message for formatting in the edit box. - */ +// / +// * Parses MiniMessage input, but leaves the tags in the message for formatting in the edit box. +// / public class MiniMessageHighlighter { public MiniMessage HIGHLIGHTER = MiniMessage.builder().tags(TagResolver.resolver( + new ShownTagResolver() + )).build(); + public MiniMessage PARSER = MiniMessage.builder().tags(TagResolver.resolver( new ShownTagResolver(), HypercubeMiniMessage.NEWLINE_TAG, HypercubeMiniMessage.SPACE_TAG @@ -44,7 +47,7 @@ public Component highlight(String input) { if (resets.length > 1 || input.toLowerCase().endsWith(RESET_TAG)) { Component value = Component.empty(); - Component reset = HIGHLIGHTER.deserialize(String.format("<%s>", getTagStyle()) + HIGHLIGHTER.escapeTags(RESET_TAG) + String.format("", getTagStyle())); + Component reset = PARSER.deserialize(String.format("<%s>", getTagStyle()) + HIGHLIGHTER.escapeTags(RESET_TAG) + String.format("", getTagStyle())); for (String partial : resets) { value = value.append(highlight(partial)) @@ -53,7 +56,7 @@ public Component highlight(String input) { return value; } - Node.Root root = HIGHLIGHTER.deserializeToTree(input); + Node.Root root = PARSER.deserializeToTree(input); StringBuilder newInput = new StringBuilder(input.length()); handle(root, root.input(), newInput, new AtomicInteger(), new ArrayList<>()); @@ -76,13 +79,14 @@ private void handle(Node node, String full, StringBuilder sb, AtomicInteger inde decorations.add(tagName); } - sb.append(tagString); + // prevent "space" and "newline" tags from being added extra as they dont get parsed in the chatbox. + if (!(tagString.contains("space") || tagString.contains("newline"))) sb.append(tagString); } else if (node instanceof ValueNode valueNode) { String value = valueNode.value(); index.addAndGet(value.length()); - sb.append(HIGHLIGHTER.escapeTags(value)); + sb.append(PARSER.escapeTags(value)); } for (Node child : node.children()) { @@ -106,7 +110,7 @@ private void handle(Node node, String full, StringBuilder sb, AtomicInteger inde } private void appendEscapedTag(StringBuilder sb, String tag, String style, ArrayList decorations) { - /* idk if someone wants to figure this out, it doesn't actually seem to work with multiple decorations. + // idk if someone wants to figure this out, it doesn't actually seem to work with multiple decorations. StringBuilder opening = new StringBuilder(); StringBuilder closing = new StringBuilder(); @@ -114,7 +118,7 @@ private void appendEscapedTag(StringBuilder sb, String tag, String style, ArrayL interpolate(opening, "<", decoration, ">"); interpolate(closing, ""); }); - */ + // interpolate(sb, "<", style, ">", HIGHLIGHTER.escapeTags(tag), ""); } @@ -156,4 +160,4 @@ public boolean has(@NotNull String name) { } } -} +} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/InsertOverlayFeature.java b/src/main/java/dev/dfonline/codeclient/dev/menu/InsertOverlayFeature.java index 89d175cd..311cd434 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/InsertOverlayFeature.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/InsertOverlayFeature.java @@ -1,14 +1,19 @@ package dev.dfonline.codeclient.dev.menu; -import dev.dfonline.codeclient.*; +import dev.dfonline.codeclient.ChestFeature; +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.Feature; +import dev.dfonline.codeclient.ItemSelector; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.dev.menu.customchest.CustomChestField; import dev.dfonline.codeclient.dev.menu.customchest.CustomChestMenu; -import dev.dfonline.codeclient.hypercube.item.*; import dev.dfonline.codeclient.hypercube.item.Number; +import dev.dfonline.codeclient.hypercube.item.*; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.render.RenderLayer; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; @@ -40,8 +45,10 @@ private static class InsertOverlay extends ChestFeature { private int screenY = 0; static { - searchIcon = Items.ITEM_FRAME.getDefaultStack(); - searchIcon.setCustomName(Text.translatable("itemGroup.search")); + var item = Items.ITEM_FRAME.getDefaultStack(); + DFItem dfItem = DFItem.of(item); + dfItem.setName(Text.translatable("itemGroup.search")); + searchIcon = dfItem.getItemStack(); } public InsertOverlay(HandledScreen screen) { @@ -179,7 +186,7 @@ public void close() { public void render(DrawContext context, int mouseX, int mouseY) { context.getMatrices().push(); context.getMatrices().translate(0.0F, 0.0F, 900.0F); - context.drawGuiTexture(new Identifier("recipe_book/overlay_recipe"), x, y, width, height); + context.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.ofVanilla("recipe_book/overlay_recipe"), x, y, width, height); if (field != null) { field.render(context, mouseX, mouseY, 0); } else { diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/RecentValues.java b/src/main/java/dev/dfonline/codeclient/dev/menu/RecentValues.java index 2117295b..72bb4d1c 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/RecentValues.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/RecentValues.java @@ -9,18 +9,16 @@ import dev.dfonline.codeclient.Feature; import dev.dfonline.codeclient.FileManager; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.location.Dev; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; -import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; -import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents; import net.minecraft.SharedConstants; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.datafixer.DataFixTypes; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.StringNbtReader; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; @@ -28,7 +26,6 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; -import org.jetbrains.annotations.Nullable; import java.nio.file.Files; import java.nio.file.Path; @@ -78,36 +75,43 @@ public RecentValues() { } }); } catch (Exception err) { - CodeClient.LOGGER.error("Failed reading recent_values.json!"); - err.printStackTrace(); + CodeClient.LOGGER.error("Failed reading recent_values.json!", err); } } private JsonArray saveItems(List list) { JsonArray out = new JsonArray(); + if (CodeClient.MC.world == null) throw new RuntimeException("World is null!"); + for (ItemStack item : list) { - out.add(item.writeNbt(new NbtCompound()).asString()); + out.add(item.toNbt(CodeClient.MC.world.getRegistryManager()).toString()); } return out; } private ItemStack readItem(int version, JsonElement item) throws Exception { - return ItemStack.fromNbt(DataFixTypes.HOTBAR.update(CodeClient.MC.getDataFixer(), StringNbtReader.parse(item.getAsString()), version)); + if (CodeClient.MC.world == null) return null; + var fromNbt = ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), DataFixTypes.HOTBAR.update(CodeClient.MC.getDataFixer(), StringNbtReader.parse(item.getAsString()), version)); + return fromNbt.orElse(null); } public void remember(ItemStack item) { - if (!(CodeClient.location instanceof Dev) - || item.getNbt() == null - || item.getNbt().get("PublicBukkitValues") == null - || item.getSubNbt("PublicBukkitValues").get("hypercube:varitem") == null) return; + if (CodeClient.MC.world == null) return; + + DFItem dfItem = DFItem.of(item); + if (!(CodeClient.location instanceof Dev) || dfItem.getHypercubeStringValue("varitem").isEmpty()) return; for (ItemStack it : pinned) { - if (item.getItem() == it.getItem() && item.getNbt().equals(it.getNbt())) return; + if (item.getItem() == it.getItem() && item.equals(it)) return; } ItemStack lambdaItem = item; - recent.removeIf(it -> lambdaItem.getItem() == it.getItem() && lambdaItem.getNbt().equals(it.getNbt())); + if (item.getItem() == null) { + recent.remove(item); + return; + } + recent.removeIf(it -> it != null && lambdaItem.getItem() == it.getItem() && lambdaItem.toNbt(CodeClient.MC.world.getRegistryManager()).equals(it.toNbt(CodeClient.MC.world.getRegistryManager()))); item = item.copyWithCount(1); recent.add(0, item); @@ -130,10 +134,10 @@ public RecentValuesOverlay(HandledScreen screen) { public void render(DrawContext context, int mouseX, int mouseY, int screenX, int screenY, float delta) { hoveredItem = null; if(recent.isEmpty() && pinned.isEmpty()) return; - int xEnd = 16*15; + int xEnd = 16 * 20; - context.drawGuiTexture(new Identifier("recipe_book/overlay_recipe"), -screenX + 6, -5, - Math.min(Math.max(pinned.size(), recent.size()),16) * 15 + 10, + context.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.ofVanilla("recipe_book/overlay_recipe"), -screenX + 6, -5, + Math.min(Math.max(pinned.size(), recent.size()), 16) * 20 + 10, (((int) Math.ceil((double) pinned.size() / 16)) + ((int) Math.ceil((double) recent.size() / 16))) * 16 + 10 ); @@ -141,22 +145,23 @@ public void render(DrawContext context, int mouseX, int mouseY, int screenX, int hoveredOrigin = null; int y = screenY; for (List group : List.of(pinned,recent)) { - int x = 10; + int x = 13; for (ItemStack item : group) { + if (item == null) continue; context.drawItem(item, x - screenX, y - screenY); - context.drawItemInSlot(CodeClient.MC.textRenderer, item, x - screenX, y - screenY); + context.drawStackOverlay(CodeClient.MC.textRenderer, item, x - screenX, y - screenY); if (mouseX > x && mouseY > y && mouseX < x + 15 && mouseY < y + 15) { context.drawItemTooltip(CodeClient.MC.textRenderer, item, mouseX - screenX, mouseY - screenY); hoveredItem = item; hoveredOrigin = group; } - x += 15; + x += 20; if (x > xEnd) { - x = 10; + x = 13; y += 15; } } - if (x != 10) y += 15; + if (x != 13) y += 15; } } diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/SlotGhostManager.java b/src/main/java/dev/dfonline/codeclient/dev/menu/SlotGhostManager.java index 598dd51d..d8ae8651 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/SlotGhostManager.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/SlotGhostManager.java @@ -112,7 +112,7 @@ public void drawSlot(DrawContext context, Slot slot) { // itemStack.setCount(slot.id); context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, arg.optional ? 0x50__90_90_ff : 0x30__ff_00_00); context.drawItem(itemStack, slot.x, slot.y); - context.drawItemInSlot(CodeClient.MC.textRenderer, itemStack, slot.x, slot.y); + context.drawStackOverlay(CodeClient.MC.textRenderer, itemStack, slot.x, slot.y); // context.drawText(CodeClient.MC.textRenderer, Text.literal(arg.type),slot.x,slot.y,0xFFFFFF00,true); context.fill(RenderLayer.getGuiGhostRecipeOverlay(), slot.x, slot.y, slot.x + 16, slot.y + 16, 0x40ffffff); } catch (Exception e) { diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestField.java b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestField.java index 8318f353..2856c51d 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestField.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestField.java @@ -21,7 +21,6 @@ import org.lwjgl.glfw.GLFW; import java.text.DecimalFormat; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestMenu.java b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestMenu.java index 1d3438f9..c118f776 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestMenu.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestMenu.java @@ -2,7 +2,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.dfonline.codeclient.CodeClient; -import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.hypercube.item.BlockTag; import dev.dfonline.codeclient.hypercube.item.VarItem; import dev.dfonline.codeclient.hypercube.item.VarItems; @@ -15,15 +14,15 @@ import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.gui.widget.TextWidget; import net.minecraft.client.gui.widget.Widget; +import net.minecraft.client.render.RenderLayer; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerListener; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import org.lwjgl.glfw.GLFW; import java.util.ArrayList; @@ -32,6 +31,10 @@ public class CustomChestMenu extends HandledScreen implements ScreenHandlerProvider { + // copy vanilla + private final Identifier SLOT_HIGHLIGHT_BACK_TEXTURE = Identifier.ofVanilla("container/slot_highlight_back"); + private final Identifier SLOT_HIGHLIGHT_FRONT_TEXTURE = Identifier.ofVanilla("container/slot_highlight_front"); + private final CustomChestNumbers Size; private final HashMap widgets = new HashMap<>(); private final ArrayList varItems = new ArrayList<>(); @@ -86,8 +89,9 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { final int x = Size.SLOT_X + 1; final int y = i * 18 + Size.SLOT_Y + 1; + if (i + scroll < 27) { - drawSlot(context, new Slot(slot.inventory, slot.id, x, y)); + int relX = mouseX - this.x; int relY = mouseY - this.y; if ( @@ -96,11 +100,18 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { && relY > y && relY < y + 18 ) { - drawSlotHighlight(context, x, y, -10); focusedSlot = slot; + + context.drawGuiTexture(RenderLayer::getGuiTextured, SLOT_HIGHLIGHT_BACK_TEXTURE, x-4, y-4, 24, 24); // draw back + drawSlot(context, new Slot(slot.inventory, slot.id, x, y)); + context.drawGuiTexture(RenderLayer::getGuiTexturedOverlay, SLOT_HIGHLIGHT_FRONT_TEXTURE, x-4, y-4, 24, 24); // draw front + + //drawSlotHighlight(context, x, y, -10); + } else { + drawSlot(context, new Slot(slot.inventory, slot.id, x, y)); } } else { - context.drawTexture(Size.TEXTURE, x - 1, y - 1, Size.DISABLED_X, 0, 18, 18, Size.TEXTURE_WIDTH, Size.TEXTURE_HEIGHT); + context.drawTexture(RenderLayer::getGuiTextured, Size.TEXTURE, x - 1, y - 1, Size.DISABLED_X, 0, 18, 18, Size.TEXTURE_WIDTH, Size.TEXTURE_HEIGHT); } } @@ -360,11 +371,11 @@ protected void drawBackground(DrawContext context, float delta, int mouseX, int RenderSystem.enableBlend(); int centerX = this.width / 2 - (Size.MENU_WIDTH / 2); int centerY = this.height / 2 - (Size.MENU_HEIGHT / 2); - context.drawTexture(Size.TEXTURE, centerX, centerY, 0.0F, 0.0F, Size.MENU_WIDTH, Size.MENU_HEIGHT, Size.TEXTURE_WIDTH, Size.TEXTURE_HEIGHT); + context.drawTexture(RenderLayer::getGuiTextured, Size.TEXTURE, centerX, centerY, 0, 0, Size.MENU_WIDTH, Size.MENU_HEIGHT, Size.TEXTURE_WIDTH, Size.TEXTURE_HEIGHT); boolean disabled = false; float scrollProgress = (float) scroll / (27 - Size.WIDGETS); - context.drawTexture(Size.TEXTURE, + context.drawTexture(RenderLayer::getGuiTextured, Size.TEXTURE, centerX + Size.SCROLL_POS_X, (int) (centerY + Size.SCROLL_POS_Y + scrollProgress * (Size.SCROLL_ROOM - Size.SCROLL_HEIGHT)), (disabled ? Size.MENU_WIDTH + Size.SCROLL_WIDTH : Size.MENU_WIDTH), @@ -374,6 +385,7 @@ protected void drawBackground(DrawContext context, float delta, int mouseX, int Size.TEXTURE_WIDTH, Size.TEXTURE_HEIGHT ); + context.getMatrices().pop(); } diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestNumbers.java b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestNumbers.java index c0e45a75..011032d8 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestNumbers.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/CustomChestNumbers.java @@ -6,7 +6,7 @@ public class CustomChestNumbers { public static final CustomChestNumbers SMALL = new CustomChestNumbers( - new Identifier(CodeClient.MOD_ID, "textures/gui/container/custom_chest/background.png"), + CodeClient.getId("textures/gui/container/custom_chest/background.png"), 176, 216, 202, @@ -26,7 +26,7 @@ public class CustomChestNumbers { 133, -1); public static final CustomChestNumbers LARGE = new CustomChestNumbers( - new Identifier(CodeClient.MOD_ID, "textures/gui/container/custom_chest/background_big.png"), + CodeClient.getId("textures/gui/container/custom_chest/background_big.png"), 198, 294, 228, diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/FakeSlot.java b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/FakeSlot.java index 96de70db..d3b09a32 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/FakeSlot.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/customchest/FakeSlot.java @@ -3,10 +3,11 @@ import dev.dfonline.codeclient.CodeClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.render.RenderLayer; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandler; @@ -16,7 +17,7 @@ import org.jetbrains.annotations.Nullable; public class FakeSlot extends ClickableWidget { - public static final Identifier TEXTURE = new Identifier("minecraft", "textures/gui/sprites/container/slot.png"); + public static final Identifier TEXTURE = Identifier.ofVanilla("textures/gui/sprites/container/slot.png"); private final ScreenHandler handler; public boolean disabled = false; @NotNull @@ -30,10 +31,14 @@ public FakeSlot(int x, int y, Text message, ScreenHandler handler) { @Override protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { - context.drawTexture(TEXTURE, this.getX(), this.getY(), 0, 0, this.width, this.height, 18, 18); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, this.getX(), this.getY(), 0, 0, this.width, this.height, 18, 18); context.drawItem(item, this.getX() + 1, this.getY() + 1); if (this.isMouseOver(mouseX, mouseY)) { - HandledScreen.drawSlotHighlight(context, this.getX() + 1, this.getY() + 1, -1000); + if (CodeClient.MC.currentScreen instanceof GenericContainerScreen sc) { + context.getMatrices().push(); + context.getMatrices().translate(mouseX, mouseY, 0.0F); + // FIXMe: remnder + } context.drawItemTooltip(CodeClient.MC.textRenderer, item, mouseX, mouseY); } } diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryGroup.java b/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryGroup.java index 4f15198f..d0d6ac8a 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryGroup.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryGroup.java @@ -1,7 +1,9 @@ package dev.dfonline.codeclient.dev.menu.devinventory; +import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.FileManager; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.actiondump.*; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -49,18 +51,18 @@ public class DevInventoryGroup { OTHERS.setItemsProvider(query -> { ArrayList items = emptyMenu(); try { - items.set(0, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:string\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"txt\",\"data\":{\"name\":\"string\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"A series of characters which\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"is highly manipulatable.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Recommended for variable\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"operations.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Type in the chat while\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"holding this item.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"E.g. \\'\"},{\"italic\":false,\"color\":\"white\",\"text\":\"Sample text\"},{\"italic\":false,\"color\":\"gray\",\"text\":\"\\'\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"aqua\",\"text\":\"String\"}],\"text\":\"\"}'}}}")))); - items.set(1, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:book\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"comp\",\"data\":{\"name\":\"text\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Text with extra formatting via\"}],\"text\":\"\"}','{\"extra\":[{\"italic\":false,\"color\":\"white\",\"text\":\"MiniMessage\"},{\"italic\":false,\"color\":\"gray\",\"text\":\" tags such as \"},{\"italic\":false,\"color\":\"white\",\"text\":\"\"},{\"italic\":false,\"color\":\"gray\",\"text\":\".\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Recommended for text displayed\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"through chat, item names, and others.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Type in the chat while\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"holding this item.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"E.g. \\'\"},{\"italic\":false,\"color\":\"white\",\"text\":\"Rainbow text!\"},{\"italic\":false,\"color\":\"gray\",\"text\":\"\\'\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#7FD42A\",\"text\":\"Styled Text\"}],\"text\":\"\"}'}}}")))); - items.set(2, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:slime_ball\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"num\",\"data\":{\"name\":\"0\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Represents a number of an\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"integer or a decimal. It can\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"have up to 3 decimal places.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Type a number in chat while\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"holding this item.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"E.g. \"},{\"italic\":false,\"color\":\"white\",\"text\":\"4\"},{\"italic\":false,\"color\":\"gray\",\"text\":\" or \"},{\"italic\":false,\"color\":\"white\",\"text\":\"1.25\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"red\",\"text\":\"Number\"}],\"text\":\"\"}'}}}")))); - items.set(3, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:paper\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"loc\",\"data\":{\"isBlock\":false,\"loc\":{\"x\":0.0,\"y\":0.0,\"z\":0.0,\"pitch\":0.0,\"yaw\":0.0}}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Represents a location in the plot.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"[0,0,0] points to the north-west\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"bottom corner of the plot.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click this item to set it\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to your current location.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Left-click to set it to a block.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Shift left-click to teleport to it.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"green\",\"text\":\"Location\"}],\"text\":\"\"}'}}}")))); - items.set(4, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:prismarine_shard\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"vec\",\"data\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"A vector consists of X, Y and\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Z values. Used for multiple\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"purposes such as representing\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"a direction, motion or an offset.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Use the /vector command or\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"type \"},{\"italic\":false,\"color\":\"aqua\",\"text\":\"\\\\\" \\\\\"\"},{\"italic\":false,\"color\":\"gray\",\"text\":\" to set the\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"components. Left-click to\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"preview it.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#2AFFAA\",\"text\":\"Vector\"}],\"text\":\"\"}'}}}")))); - items.set(5, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:nautilus_shell\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"snd\",\"data\":{\"pitch\":1.0,\"vol\":2.0,\"sound\":\"Pling\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Represents a Minecraft sound or a\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"custom sound from resource pack.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click this item to select\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"a sound effect.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Shift right-click to select\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"a variant of the sound.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"To add a pitch & volume, type\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"them in one chat line, in order.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Left-click to preview it.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"blue\",\"text\":\"Sound\"}],\"text\":\"\"}'}}}")))); - items.set(6, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:white_dye\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"part\",\"data\":{\"particle\":\"Cloud\",\"cluster\":{\"amount\":1,\"horizontal\":0.0,\"vertical\":0.0},\"data\":{\"x\":1.0,\"y\":0.0,\"z\":0.0,\"motionVariation\":100}}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Represents a particle effect with\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"customizable parameters.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click this item to select\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"a particle effect.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Use the /particle command\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to change its parameters.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Left-click to preview it.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#AA55FF\",\"text\":\"Particle\"}],\"text\":\"\"}'}}}")))); + items.set(0, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"txt\",\"data\":{\"name\":\"string\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"aqua\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"String\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"A series of characters which\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"is highly manipulatable.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Recommended for variable\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"operations.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Type in the chat while\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"holding this item.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"E.g. \\'\",\"underlined\":false},{\"color\":\"white\",\"italic\":false,\"text\":\"Sample text\"},{\"color\":\"gray\",\"italic\":false,\"text\":\"\\'\"}],\"text\":\"\"}']},count:1,id:\"minecraft:string\"}")).get())); + items.set(1, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"comp\",\"data\":{\"name\":\"text\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#7FD42A\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Styled Text\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Text with extra formatting via\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"color\":\"white\",\"italic\":false,\"text\":\"MiniMessage\"},{\"color\":\"gray\",\"italic\":false,\"text\":\" tags such as \"},{\"color\":\"white\",\"italic\":false,\"text\":\"\"},{\"color\":\"gray\",\"italic\":false,\"text\":\".\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Recommended for text displayed\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"through chat, item names, and others.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Type in the chat while\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"holding this item.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"E.g. \\'\",\"underlined\":false},{\"color\":\"white\",\"italic\":false,\"text\":\"Rainbow text!\"},{\"color\":\"gray\",\"italic\":false,\"text\":\"\\'\"}],\"text\":\"\"}']},count:1,id:\"minecraft:book\"}")).get())); + items.set(2, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"num\",\"data\":{\"name\":\"0\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"red\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Number\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Represents a number of an\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"integer or a decimal. It can\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"have up to 3 decimal places.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Type a number in chat while\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"holding this item.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"E.g. \",\"underlined\":false},{\"color\":\"white\",\"italic\":false,\"text\":\"4\"},{\"color\":\"gray\",\"italic\":false,\"text\":\" or \"},{\"color\":\"white\",\"italic\":false,\"text\":\"1.25\"}],\"text\":\"\"}']},count:1,id:\"minecraft:slime_ball\"}")).get())); + items.set(3, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"loc\",\"data\":{\"isBlock\":false,\"loc\":{\"x\":0.0,\"y\":0.0,\"z\":0.0,\"pitch\":0.0,\"yaw\":0.0}}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"green\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Location\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Represents a location in the plot.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"[0,0,0] points to the north-west\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"bottom corner of the plot.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click this item to set it\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"to your current location.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Left-click to set it to a block.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Shift left-click to teleport to it.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:paper\"}")).get())); + items.set(4, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"vec\",\"data\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#2AFFAA\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Vector\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"A vector consists of X, Y and\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Z values. Used for multiple\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"purposes such as representing\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"a direction, motion or an offset.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Use the /vector command or\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"type \",\"underlined\":false},{\"color\":\"aqua\",\"italic\":false,\"text\":\"\\\\\" \\\\\"\"},{\"color\":\"gray\",\"italic\":false,\"text\":\" to set the\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"components. Left-click to\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"preview it.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:prismarine_shard\"}")).get())); + items.set(5, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"snd\",\"data\":{\"pitch\":1.0,\"vol\":2.0,\"sound\":\"Pling\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"blue\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Sound\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Represents a Minecraft sound or a\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"custom sound from resource pack.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click this item to select\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"a sound effect.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Shift right-click to select\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"a variant of the sound.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"To add a pitch & volume, type\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"them in one chat line, in order.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Left-click to preview it.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:nautilus_shell\"}")).get())); + items.set(6, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"part\",\"data\":{\"particle\":\"Cloud\",\"cluster\":{\"amount\":1,\"horizontal\":0.0,\"vertical\":0.0},\"data\":{\"x\":1.0,\"y\":0.0,\"z\":0.0,\"motionVariation\":100}}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#AA55FF\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Particle\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Represents a particle effect with\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"customizable parameters.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click this item to select\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"a particle effect.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Use the /particle command\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"to change its parameters.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Left-click to preview it.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:white_dye\"}")).get())); - items.set(9, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:dragon_breath\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"pot\",\"data\":{\"pot\":\"Speed\",\"dur\":1000000,\"amp\":0}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Represents a potion effect with\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"custom amplifier and duration.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click this item to select\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"a potion effect.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Use the /potion command or\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"type \"},{\"italic\":false,\"color\":\"aqua\",\"text\":\"\\\\\" [duration]\\\\\"\"},{\"italic\":false,\"color\":\"gray\",\"text\":\"\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to set its options. Left-click\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to preview it.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#FF557F\",\"text\":\"Potion Effect\"}],\"text\":\"\"}'}}}")))); - items.set(10, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:magma_cream\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"var\",\"data\":{\"name\":\"&eVariable\",\"scope\":\"unsaved\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Variables can store values inside.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Give a name to your variable, and\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"use \"},{\"italic\":false,\"color\":\"white\",\"text\":\"Set Variable\"},{\"italic\":false,\"color\":\"gray\",\"text\":\" to set its value.\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Type a variable name in chat\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"while holding this item.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Shift right-click for options.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"yellow\",\"text\":\"Variable\"}],\"text\":\"\"}'}}}")))); - items.set(11, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:name_tag\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"g_val\",\"data\":{\"type\":\"Location\",\"target\":\"Default\"}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"An automatically set value based\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"on the game\\'s current conditions\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"(e.g. a player\\'s location).\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click to select a game\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"value and its target.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#FFD47F\",\"text\":\"Game Value\"}],\"text\":\"\"}'}}}")))); - items.set(12, new Searchable.StaticSearchable(ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:ender_eye\",tag:{CustomModelData:5000,HideFlags:-1,PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"pn_el\",\"data\":{\"name\":\"name\",\"type\":\"any\",\"plural\":false,\"optional\":false}}'},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"A parameter to put in the\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"code chest of a \"},{\"italic\":false,\"color\":\"aqua\",\"text\":\"function\"},{\"italic\":false,\"color\":\"gray\",\"text\":\".\"}],\"text\":\"\"}','{\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"light_purple\",\"text\":\"How to set:\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Type in chat to edit name.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click to open the editor.\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"#AAFFAA\",\"text\":\"Parameter\"}],\"text\":\"\"}'}}}")))); + items.set(9, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"pot\",\"data\":{\"pot\":\"Speed\",\"dur\":1000000,\"amp\":0}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#FF557F\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Potion Effect\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Represents a potion effect with\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"custom amplifier and duration.\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click this item to select\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"a potion effect.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Use the /potion command or\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"type \",\"underlined\":false},{\"color\":\"aqua\",\"italic\":false,\"text\":\"\\\\\" [duration]\\\\\"\"},{\"color\":\"gray\",\"italic\":false,\"text\":\"\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"to set its options. Left-click\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"to preview it.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:dragon_breath\"}")).get())); + items.set(10, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"var\",\"data\":{\"name\":\"§eVariable\",\"scope\":\"unsaved\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"yellow\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Variable\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Variables can store values inside.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Give a name to your variable, and\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"use \",\"underlined\":false},{\"color\":\"white\",\"italic\":false,\"text\":\"Set Variable\"},{\"color\":\"gray\",\"italic\":false,\"text\":\" to set its value.\"}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Type a variable name in chat\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"while holding this item.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Shift right-click for options.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:magma_cream\"}")).get())); + items.set(11, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"g_val\",\"data\":{\"type\":\"Location\",\"target\":\"Default\"}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#FFD47F\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Game Value\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"An automatically set value based\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"on the game\\'s current conditions\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"(e.g. a player\\'s location).\",\"underlined\":false}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click to select a game\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"value and its target.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:name_tag\"}")).get())); + items.set(12, new Searchable.StaticSearchable(ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{components:{\"minecraft:attribute_modifiers\":{modifiers:[],show_in_tooltip:0b},\"minecraft:custom_data\":{PublicBukkitValues:{\"hypercube:varitem\":'{\"id\":\"pn_el\",\"data\":{\"name\":\"name\",\"type\":\"any\",\"plural\":false,\"optional\":false}}'}},\"minecraft:custom_model_data\":5000,\"minecraft:custom_name\":'{\"extra\":[{\"bold\":false,\"color\":\"#AAFFAA\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Parameter\",\"underlined\":false}],\"text\":\"\"}',\"minecraft:hide_additional_tooltip\":{},\"minecraft:lore\":['{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"A parameter to put in the\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"code chest of a \",\"underlined\":false},{\"color\":\"aqua\",\"italic\":false,\"text\":\"function\"},{\"color\":\"gray\",\"italic\":false,\"text\":\".\"}],\"text\":\"\"}','\"\"','{\"extra\":[{\"bold\":false,\"color\":\"light_purple\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"How to set:\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Type in chat to edit name.\",\"underlined\":false}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"color\":\"gray\",\"italic\":false,\"obfuscated\":false,\"strikethrough\":false,\"text\":\"Right-click to open the editor.\",\"underlined\":false}],\"text\":\"\"}']},count:1,id:\"minecraft:ender_eye\"}")).get())); int i = 0; @@ -72,9 +74,9 @@ public class DevInventoryGroup { // Items bellow except arrow cannot be normally given since they have an item_instance that changes per node and every restart, // so unless the player is in dev mode with these items in their inventory already we cannot display the usable items. // Caching the item_instance for each node can also be a solution. -// items.set(8,ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:written_book\",tag:{CustomModelData:0,HideFlags:127,PublicBukkitValues:{\"hypercube:item_instance\":\"18726d32-57ae-4305-b317-2b084283e704\"},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click to open the\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"reference menu.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"extra\":[{\"color\":\"gold\",\"text\":\"◆ \"},{\"color\":\"aqua\",\"text\":\"Reference Book \"},{\"color\":\"gold\",\"text\":\"◆\"}],\"text\":\"\"}'}}}"))); -// items.set(17,ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:blaze_rod\",tag:{CustomModelData:0,HideFlags:127,PublicBukkitValues:{\"hypercube:item_instance\":\"de7f011e-8248-40e6-b04f-8315c4c7be4a\"},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Shows two corresponding brackets\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"for a short amount of time.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-Click a bracket to highlight\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"both.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"color\":\"gold\",\"text\":\"Bracket Finder\"}'}}}"))); -// items.set(26, ItemStack.fromNbt(NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:arrow\",tag:{CustomModelData:0,HideFlags:127,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Click on a Condition block with this\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to switch between \\'IF\\' and \\'IF NOT\\'.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"color\":\"red\",\"text\":\"NOT Arrow\"}'}}}"))); +// items.set(8,ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:written_book\",tag:{CustomModelData:0,HideFlags:127,PublicBukkitValues:{\"hypercube:item_instance\":\"18726d32-57ae-4305-b317-2b084283e704\"},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-click to open the\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"reference menu.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"extra\":[{\"color\":\"gold\",\"text\":\"◆ \"},{\"color\":\"aqua\",\"text\":\"Reference Book \"},{\"color\":\"gold\",\"text\":\"◆\"}],\"text\":\"\"}'}}}"))); +// items.set(17,ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:blaze_rod\",tag:{CustomModelData:0,HideFlags:127,PublicBukkitValues:{\"hypercube:item_instance\":\"de7f011e-8248-40e6-b04f-8315c4c7be4a\"},display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Shows two corresponding brackets\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"for a short amount of time.\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Right-Click a bracket to highlight\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"both.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"color\":\"gold\",\"text\":\"Bracket Finder\"}'}}}"))); +// items.set(26, ItemStack.fromNbt(CodeClient.MC.world.getRegistryManager(), NbtHelper.fromNbtProviderString("{Count:1b,id:\"minecraft:arrow\",tag:{CustomModelData:0,HideFlags:127,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"Click on a Condition block with this\"}],\"text\":\"\"}','{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"to switch between \\'IF\\' and \\'IF NOT\\'.\"}],\"text\":\"\"}'],Name:'{\"italic\":false,\"color\":\"red\",\"text\":\"NOT Arrow\"}'}}}"))); } catch (Exception e) { e.printStackTrace(); } @@ -180,8 +182,9 @@ static private ArrayList readTemplates(Path path, Path root) { if (file.getFileName().toString().endsWith(".dft")) { byte[] data = Files.readAllBytes(file); ItemStack template = Utility.makeTemplate(new String(Base64.getEncoder().encode(data))); - template.setCustomName(Text.empty().formatted(Formatting.RED).append("Saved Template").append(Text.literal(" » ").formatted(Formatting.DARK_RED, Formatting.BOLD)).append(String.valueOf(root.relativize(file)))); - list.add(new Searchable.StaticSearchable(template)); + DFItem item = DFItem.of(template); + item.setName(Text.empty().formatted(Formatting.RED).append("Saved Template").append(Text.literal(" » ").formatted(Formatting.DARK_RED, Formatting.BOLD)).append(String.valueOf(root.relativize(file)))); + list.add(new Searchable.StaticSearchable(item.getItemStack())); } } dir.close(); diff --git a/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryScreen.java b/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryScreen.java index 763fdc8b..7e28fdec 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryScreen.java +++ b/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryScreen.java @@ -14,15 +14,16 @@ import net.fabricmc.api.Environment; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; import net.minecraft.client.gui.screen.ingame.CreativeInventoryListener; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.render.RenderLayer; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.SimpleInventory; +import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandler; @@ -46,10 +47,10 @@ import static dev.dfonline.codeclient.dev.menu.devinventory.DevInventoryGroup.*; @Environment(EnvType.CLIENT) -public class DevInventoryScreen extends AbstractInventoryScreen { +public class DevInventoryScreen extends HandledScreen { static final SimpleInventory Inventory = new SimpleInventory(45); - private static final Identifier TEXTURE = new Identifier(CodeClient.MOD_ID, "textures/gui/container/dev_inventory/tabs.png"); - private static final String TAB_TEXTURE_PREFIX = "textures/gui/container/creative_inventory/tab_"; + private static final Identifier TEXTURE = CodeClient.getId("textures/gui/container/dev_inventory/tabs.png"); +// private static final String TAB_TEXTURE_PREFIX = "container/creative_inventory/tab_"; private static final Text DELETE_ITEM_SLOT_TEXT = Text.translatable("inventory.binSlot"); private static int selectedTab; private double scrollPosition; @@ -64,8 +65,11 @@ public class DevInventoryScreen extends AbstractInventoryScreen getOverlayText() { return referenceBook.getTooltip(); } var item = action.icon.getItem(); - return item.getTooltip(null, TooltipContext.BASIC); + return item.getTooltip(Item.TooltipContext.DEFAULT, CodeClient.MC.player, TooltipType.BASIC); } return null; } @@ -138,7 +139,7 @@ private void drawTooltip(DrawContext context, HandledScreen handledScreen, Li int tooltipHeight = components.size() == 1 ? -2 : 0; TooltipComponent tooltipComponent; - for (Iterator iterator = components.iterator(); iterator.hasNext(); tooltipHeight += tooltipComponent.getHeight()) { + for (Iterator iterator = components.iterator(); iterator.hasNext(); tooltipHeight += tooltipComponent.getHeight(textRenderer)) { tooltipComponent = iterator.next(); int width = tooltipComponent.getWidth(textRenderer); if (width > tooltipWidth) { @@ -150,14 +151,16 @@ private void drawTooltip(DrawContext context, HandledScreen handledScreen, Li var finalWidth = tooltipWidth; var finalHeight = tooltipHeight; - context.draw(() -> TooltipBackgroundRenderer.render(context, vector.x(), vector.y(), finalWidth, finalHeight, z)); + context.draw((vertexConsumer) -> TooltipBackgroundRenderer.render(context, vector.x(), vector.y(), finalWidth, finalHeight, z, null)); context.getMatrices().translate(0.0F, 0.0F, (float) z); int textY = vector.y(); for (int index = 0; index < components.size(); ++index) { tooltipComponent = components.get(index); - tooltipComponent.drawText(textRenderer, vector.x(), textY, context.getMatrices().peek().getPositionMatrix(), context.getVertexConsumers()); - textY += tooltipComponent.getHeight() + (index == 0 ? 2 : 0); + TooltipComponent finalTooltipComponent = tooltipComponent; + int finalTextY = textY; + context.draw(consumer -> finalTooltipComponent.drawText(textRenderer, vector.x(), finalTextY, context.getMatrices().peek().getPositionMatrix(), (VertexConsumerProvider.Immediate) consumer)); + textY += tooltipComponent.getHeight(textRenderer) + (index == 0 ? 2 : 0); } context.getMatrices().pop(); @@ -218,10 +221,7 @@ private boolean isMouseInside(int x, int y, int width, int height, int screenWid // check in range if (x <= mouseX && mouseX <= x + width) { - if (y <= mouseY && mouseY <= y + height) { - return true; - } - ; + return y <= mouseY && mouseY <= y + height; } return false; } diff --git a/src/main/java/dev/dfonline/codeclient/dev/overlay/CPUDisplay.java b/src/main/java/dev/dfonline/codeclient/dev/overlay/CPUDisplay.java index f64bf00f..527ddf86 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/overlay/CPUDisplay.java +++ b/src/main/java/dev/dfonline/codeclient/dev/overlay/CPUDisplay.java @@ -21,13 +21,13 @@ public boolean onReceivePacket(Packet packet) { } if (!(packet instanceof OverlayMessageS2CPacket overlay)) return false; - String txt = overlay.getMessage().getString(); + String txt = overlay.text().getString(); Pattern pattern = Pattern.compile("CPU Usage: \\[" + "▮".repeat(20) + "] \\(\\d+\\.\\d+%\\)"); if (!pattern.matcher(txt).matches()) return false; overlayTimeout = 2 * 20; - OverlayManager.setCpuUsage(overlay.getMessage()); + OverlayManager.setCpuUsage(overlay.text()); return true; } diff --git a/src/main/java/dev/dfonline/codeclient/dev/overlay/ChestPeeker.java b/src/main/java/dev/dfonline/codeclient/dev/overlay/ChestPeeker.java index 2a4b9e3e..126794bc 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/overlay/ChestPeeker.java +++ b/src/main/java/dev/dfonline/codeclient/dev/overlay/ChestPeeker.java @@ -5,25 +5,25 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Feature; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.item.Scope; import dev.dfonline.codeclient.location.Dev; import net.minecraft.block.Blocks; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ContainerComponent; +import net.minecraft.component.type.NbtComponent; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; import net.minecraft.network.packet.s2c.play.BlockEventS2CPacket; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; -import net.minecraft.registry.Registries; import net.minecraft.text.MutableText; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.text.TextColor; import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.NotNull; @@ -32,12 +32,21 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.function.Consumer; public class ChestPeeker extends Feature { - private BlockPos currentBlock = null; - private NbtList items = null; + + private static BlockPos currentBlock = null; + private static ArrayList items = null; private boolean shouldClearChest = false; private int timeOut = 0; + private static Consumer> currentCallback = null; + + public static void pick(Consumer> callback) { + currentCallback = callback; + currentBlock = null; + items = null; + } public void tick() { if (timeOut > 0) { @@ -46,7 +55,7 @@ public void tick() { } if (CodeClient.MC.currentScreen != null) return; if (CodeClient.MC.world == null) return; - if (!Config.getConfig().ChestPeeker) return; + if (!Config.getConfig().ChestPeeker && currentCallback == null) return; if (CodeClient.location instanceof Dev dev) { if (CodeClient.MC.crosshairTarget instanceof BlockHitResult block) { BlockPos pos = block.getBlockPos(); @@ -62,15 +71,16 @@ public void tick() { items = null; shouldClearChest = true; + // Uses non-abstracted item changes due to this very specific use case. ItemStack item = Items.CHEST.getDefaultStack(); NbtCompound bet = new NbtCompound(); - bet.put("Items", new NbtList()); bet.putString("id", "minecraft:chest"); bet.putInt("x", pos.getX()); bet.putInt("y", pos.getY()); bet.putInt("z", pos.getZ()); - item.setSubNbt("BlockEntityTag", bet); - item.setCustomName(Text.literal("CodeClient chest peeker internal")); + item.set(DataComponentTypes.BLOCK_ENTITY_DATA, NbtComponent.of(bet)); + item.set(DataComponentTypes.CUSTOM_NAME, Text.literal("CodeClient chest peeker internal")); + CodeClient.MC.getNetworkHandler().sendPacket(new CreativeInventoryActionC2SPacket(1, ItemStack.EMPTY)); CodeClient.MC.getNetworkHandler().sendPacket(new CreativeInventoryActionC2SPacket(1, item)); return; @@ -84,7 +94,7 @@ public void tick() { public boolean onReceivePacket(Packet packet) { if (CodeClient.MC.currentScreen != null) return false; if (CodeClient.MC.getNetworkHandler() == null) return false; - if (!Config.getConfig().ChestPeeker) return false; + if (!Config.getConfig().ChestPeeker && currentCallback == null) return false; if (CodeClient.location instanceof Dev) { if (packet instanceof BlockEventS2CPacket block) { if (!Objects.equals(currentBlock, block.getPos())) return false; @@ -93,18 +103,22 @@ public boolean onReceivePacket(Packet packet) { reset(); } if (packet instanceof ScreenHandlerSlotUpdateS2CPacket slot) { - var nbt = slot.getStack().getNbt(); - if (nbt == null) return false; - var display = nbt.getCompound("display"); - if (display == null || !display.contains("Name", NbtElement.STRING_TYPE)) return false; - String name = display.getString("Name"); - if (Objects.equals(name, ") {\"text\":\"CodeClient chest peeker internal\"}")) return false; - var bet = nbt.getCompound("BlockEntityTag"); - if (bet == null) return false; - if (!Objects.equals(bet.getString("id"), "minecraft:chest")) return false; - if (currentBlock != null) items = bet.getList("Items", NbtElement.COMPOUND_TYPE); + DFItem item = DFItem.of(slot.getStack()); + if (!Objects.equals(item.getName(), Text.literal("CodeClient chest peeker internal"))) return false; + ContainerComponent container = item.getContainer(); + if (container == null) return false; + items = new ArrayList<>(); + container.iterateNonEmpty().forEach((stack) -> { + items.add(stack); + }); CodeClient.MC.getNetworkHandler().sendPacket(new CreativeInventoryActionC2SPacket(slot.getSlot(), ItemStack.EMPTY)); shouldClearChest = false; + + // Invoke the callback if it exists + if (currentCallback != null) { + currentCallback.accept(items); + currentCallback = null; + } return true; } } @@ -119,19 +133,17 @@ public List getOverlayText() { texts.add(Text.translatable("codeclient.peeker.empty").formatted(Formatting.GOLD)); } else { texts.add(Text.translatable("codeclient.peeker.contents").formatted(Formatting.GOLD)); - for (NbtElement itemData : items) { - if (itemData instanceof NbtCompound compound) { - ItemStack item = Registries.ITEM.get(Identifier.tryParse(compound.getString("id"))).getDefaultStack(); - item.setCount(compound.getInt("Count")); - NbtCompound tag = compound.getCompound("tag"); - item.setNbt(tag); - NbtList lore = tag.getCompound("display").getList("Lore", NbtElement.STRING_TYPE); - - MutableText text = Text.empty(); + for (ItemStack item : items) { + DFItem dfItem = DFItem.of(item); + List currentLore = dfItem.getLore(); + ArrayList lore = new ArrayList<>(currentLore); + + + MutableText text = Text.empty(); text.append(Text.literal(" • ").formatted(Formatting.DARK_GRAY)); - String varItem = tag.getCompound("PublicBukkitValues").getString("hypercube:varitem"); + String varItem = dfItem.getHypercubeStringValue("varitem"); if (Objects.equals(varItem, "")) { - text.append(compound.getInt("Count") + "x "); + text.append(item.getCount() + "x "); text.append(item.getName()); } else { try { @@ -164,7 +176,7 @@ public List getOverlayText() { ).fillStyle(Style.EMPTY.withColor(Type.vec.color))); } if (type == Type.snd) { - text.append(Text.Serialization.fromJson(lore.getString(0))); + text.append(lore.getFirst()); text.append(Text.literal(" P: ").formatted(Formatting.GRAY)); text.append(Text.literal("%.1f".formatted(data.get("pitch").getAsFloat()))); text.append(Text.literal(" V: ").formatted(Formatting.GRAY)); @@ -172,10 +184,10 @@ public List getOverlayText() { } if (type == Type.part) { text.append(Text.literal("%dx ".formatted(data.get("cluster").getAsJsonObject().get("amount").getAsInt()))); - text.append(Text.Serialization.fromJson(lore.getString(0))); + text.append(lore.getFirst()); } if (type == Type.pot) { - text.append(Text.Serialization.fromJson(lore.getString(0))); + text.append(lore.getFirst()); text.append(Text.literal(" %d ".formatted(data.get("amp").getAsInt() + 1))); int dur = data.get("dur").getAsInt(); text.append(dur >= 1000000 ? "Infinite" : dur % 20 == 0 ? "%d:%02d".formatted((dur / 1200), (dur / 20) % 60) : (dur + "ticks")); @@ -191,7 +203,6 @@ public List getOverlayText() { } } texts.add(text); - } } } return texts; @@ -214,6 +225,7 @@ public void reset() { shouldClearChest = true; currentBlock = null; timeOut = 10; + currentCallback = null; } enum Type { diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java b/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java index c04d6673..58ef9291 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java @@ -38,4 +38,4 @@ private static TagResolver repetitionTagResolver(String name, String literal) { }); } } -} +} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/ReferenceBook.java b/src/main/java/dev/dfonline/codeclient/hypercube/ReferenceBook.java index aadeecee..627708bd 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/ReferenceBook.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/ReferenceBook.java @@ -1,8 +1,13 @@ package dev.dfonline.codeclient.hypercube; -import net.minecraft.client.item.TooltipContext; +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.data.DFItem; +import dev.dfonline.codeclient.data.ItemData; +import dev.dfonline.codeclient.data.PublicBukkitValues; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.WrittenBookItem; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.text.Text; import java.util.List; @@ -17,8 +22,8 @@ public ReferenceBook(ItemStack item) throws IllegalArgumentException { private boolean validate(ItemStack item) { if (item.getItem() instanceof WrittenBookItem) { - var nbt = item.getSubNbt("PublicBukkitValues"); - return nbt != null && !nbt.getString("hypercube:item_instance").isEmpty(); + DFItem dfItem = DFItem.of(item); + return !dfItem.getHypercubeStringValue("item_instance").isEmpty(); } return false; } @@ -37,13 +42,16 @@ public ItemStack getItem() { * @return the reference book without any tags applied to it. */ public ItemStack getTaglessItem() { - var tagless = book.copy(); - tagless.setSubNbt("PublicBukkitValues", null); - return tagless; + DFItem tagless = DFItem.of(book.copy()); + ItemData itemData = tagless.getItemData(); + if (itemData == null) return book; + itemData.removeKey(PublicBukkitValues.PUBLIC_BUKKIT_VALUES_KEY); + tagless.setItemData(itemData); + return tagless.getItemStack(); } public List getTooltip() { - return getTaglessItem().getTooltip(null, TooltipContext.BASIC); + return getTaglessItem().getTooltip(Item.TooltipContext.DEFAULT, CodeClient.MC.player, TooltipType.BASIC); } // todo: parse into action? diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Action.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Action.java index 730ca5a5..f83389e5 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Action.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Action.java @@ -4,16 +4,17 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.item.BlockTag; import dev.dfonline.codeclient.hypercube.template.Argument; import dev.dfonline.codeclient.hypercube.template.Bracket; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtString; import org.jetbrains.annotations.Nullable; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class Action implements Searchable { public String name; @@ -43,9 +44,6 @@ public CodeBlock getCodeBlock() { @Override public ItemStack getItem() { ItemStack item = icon.getItem(); - NbtCompound nbt = item.getNbt(); - assert nbt != null; - NbtCompound PublicBukkitValues = new NbtCompound(); JsonObject CodeTemplateData = new JsonObject(); CodeTemplateData.addProperty("author", CodeClient.MC.getSession().getUsername()); CodeTemplateData.addProperty("name", icon.name); @@ -84,13 +82,12 @@ public ItemStack getItem() { } catch (Exception ignored) { } - PublicBukkitValues.put("hypercube:codetemplatedata", NbtString.of(String.valueOf(CodeTemplateData))); - nbt.put("PublicBukkitValues", PublicBukkitValues); - item.setNbt(nbt); - return item; + DFItem dfItem = DFItem.of(item); + dfItem.getItemData().setHypercubeStringValue("codetemplatedata", String.valueOf(CodeTemplateData)); + return dfItem.getItemStack(); } public boolean isInvalid() { - return this.icon.name.equals(""); + return this.icon.name.isEmpty(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Argument.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Argument.java index f18b9e50..50ca1011 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Argument.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Argument.java @@ -1,13 +1,15 @@ package dev.dfonline.codeclient.hypercube.actiondump; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; public class Argument { @@ -32,41 +34,26 @@ public ItemStack getItem() { if(icon == null) return ItemStack.EMPTY; var item = icon.getIcon(); - NbtCompound nbt = new NbtCompound(); - NbtCompound display = new NbtCompound(); - NbtList lore = new NbtList(); - - int index = 0; - for (NbtElement line: getLore()) { - if(line instanceof NbtString string) { - if(index++ == 0) { - display.put("Name", string); - } - else { - lore.add(line); - } - } - } - - display.put("Lore",lore); - - nbt.put("display", display); - nbt.put("HideFlags", NbtInt.of(127)); - - item.setNbt(nbt); + DFItem dfItem = DFItem.of(item); + // First line is item name, others are lore + List lore = getLore(); + if (lore.isEmpty()) return item; + dfItem.setName(lore.getFirst()); + lore.removeFirst(); + dfItem.setLore(lore); return item; } - - public NbtList getLore() { - var lore = new NbtList(); + + public List getLore() { + ArrayList lore = new ArrayList<>(); int i = 0; if (this.text != null) addToLore(lore, this.text); if (this.description != null) for (String line : this.description) { Icon.Type type = Icon.Type.valueOf(this.type); if (i == 0) { - MutableText text = Text.empty().formatted(Formatting.GRAY); - MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color)); + MutableText text = Text.empty().formatted(Formatting.GRAY).styled(s -> s.withItalic(false)); + MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color).withItalic(false)); if (this.plural) typeText.append("(s)"); text.append(typeText); if (this.optional) { @@ -74,8 +61,8 @@ public NbtList getLore() { } text.append(Text.literal(" - ").formatted(Formatting.DARK_GRAY)); text.append(Utility.textFromString(line).formatted(Formatting.GRAY)); - lore.add(Utility.textToNBT(text)); - } else lore.add(Utility.textToNBT(Utility.textFromString(line).formatted(Formatting.GRAY))); + lore.add(text); + } else lore.add(Utility.textFromString(line).formatted(Formatting.GRAY)); i++; } if (this.notes != null) for (String[] lines : this.notes) { @@ -97,6 +84,6 @@ public boolean isSplitter() { return Objects.equals(text,""); } - private void addToLore(NbtList lore, String text) { - lore.add(Utility.textToNBT(Utility.textFromString(text))); + private void addToLore(ArrayList lore, String text) { + lore.add(Utility.textFromString(text)); }} \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/CodeBlock.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/CodeBlock.java index 338fc31b..4cbb10ca 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/CodeBlock.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/CodeBlock.java @@ -1,12 +1,8 @@ package dev.dfonline.codeclient.hypercube.actiondump; -import dev.dfonline.codeclient.CodeClient; import net.minecraft.item.ItemStack; -import java.io.IOException; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class CodeBlock implements Searchable { /** diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Icon.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Icon.java index 0bef9488..f5c432f0 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Icon.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Icon.java @@ -1,18 +1,16 @@ package dev.dfonline.codeclient.hypercube.actiondump; import dev.dfonline.codeclient.Utility; -import dev.dfonline.codeclient.hypercube.item.*; +import dev.dfonline.codeclient.data.DFItem; +import dev.dfonline.codeclient.data.ItemData; import dev.dfonline.codeclient.hypercube.item.Number; import dev.dfonline.codeclient.hypercube.item.Potion; import dev.dfonline.codeclient.hypercube.item.Sound; import dev.dfonline.codeclient.hypercube.item.VarItem; +import dev.dfonline.codeclient.hypercube.item.*; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtInt; -import net.minecraft.nbt.NbtIntArray; -import net.minecraft.nbt.NbtList; import net.minecraft.registry.Registries; import net.minecraft.text.MutableText; import net.minecraft.text.Style; @@ -20,13 +18,14 @@ import net.minecraft.text.TextColor; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; public class Icon { - private static TextColor GOLD = TextColor.fromFormatting(Formatting.GOLD); + private static final TextColor GOLD = TextColor.fromFormatting(Formatting.GOLD); public String material; public String head; public String name; @@ -57,11 +56,12 @@ public String getCleanName() { } public ItemStack getItem() { - ItemStack item = Registries.ITEM.get(new Identifier(material.toLowerCase())).getDefaultStack(); + ItemStack item = Registries.ITEM.get(Identifier.ofVanilla(material.toLowerCase())).getDefaultStack(); - NbtCompound nbt = new NbtCompound(); - NbtCompound display = new NbtCompound(); - NbtList lore = new NbtList(); + DFItem dfItem = DFItem.of(item); + ItemData data = dfItem.getItemData(); + + ArrayList lore = new ArrayList<>(); for (String line : description) { addToLore(lore, "§7" + line); @@ -83,8 +83,8 @@ public ItemStack getItem() { if (arg.description != null && description.length != 0) for (String line : arg.description) { Type type = Type.valueOf(arg.type); if (i == 0) { - MutableText text = Text.empty().formatted(Formatting.GRAY); - MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color)); + MutableText text = Text.empty().formatted(Formatting.GRAY).styled(s -> s.withItalic(false)); + MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color).withItalic(false)); if (arg.plural) typeText.append("(s)"); text.append(typeText); if (arg.optional) { @@ -93,8 +93,8 @@ public ItemStack getItem() { } text.append(Text.literal(" - ").formatted(Formatting.DARK_GRAY)); text.append(Utility.textFromString(line).formatted(Formatting.GRAY)); - lore.add(Utility.textToNBT(text)); - } else lore.add(Utility.textToNBT(Utility.textFromString(line).formatted(Formatting.GRAY))); + lore.add(text); + } else lore.add(Utility.textFromString(line).formatted(Formatting.GRAY)); i++; } if (arg.notes != null) for (String[] lines : arg.notes) { @@ -107,11 +107,11 @@ public ItemStack getItem() { } } if (tags != null && tags != 0) { - lore.add(Utility.textToNBT(Text.literal("# ").formatted(Formatting.DARK_AQUA).append(Text.literal(tags + " Tag" + (tags != 1 ? "s" : "")).formatted(Formatting.GRAY)))); + lore.add(Text.literal("# ").formatted(Formatting.DARK_AQUA).styled(s -> s.withItalic(false)).append(Text.literal(tags + " Tag" + (tags != 1 ? "s" : "")).formatted(Formatting.GRAY))); } if (hasOptional) { - lore.add(Utility.textToNBT(Text.literal(""))); - lore.add(Utility.textToNBT(Text.literal("*Optional").formatted(Formatting.GRAY))); + lore.add(Text.empty()); + lore.add(Text.literal("*Optional").formatted(Formatting.GRAY).styled(s -> s.withItalic(false))); } } if (returnValues != null && returnValues.length != 0) { @@ -120,7 +120,7 @@ public ItemStack getItem() { for (ReturnValue returnValue : returnValues) { if (returnValue.text != null) addToLore(lore, returnValue.text); else { - lore.add(Utility.textToNBT(Text.empty().append(Text.literal(returnValue.type.display).setStyle(Style.EMPTY.withColor(returnValue.type.color))).append(Text.literal(" - ").formatted(Formatting.DARK_GRAY)).append(Text.literal(returnValue.description[0]).formatted(Formatting.GRAY)))); + lore.add(Text.empty().append(Text.literal(returnValue.type.display).setStyle(Style.EMPTY.withColor(returnValue.type.color).withItalic(false))).append(Text.literal(" - ").formatted(Formatting.DARK_GRAY)).append(Text.literal(returnValue.description[0]).formatted(Formatting.GRAY).styled(s -> s.withItalic(false)))); boolean first = true; for (String description : returnValue.description) { if (first) { @@ -151,47 +151,35 @@ public ItemStack getItem() { } if(requireTokens) { addToLore(lore,""); - lore.add(Utility.textToNBT(Text.literal("Unlock with Tokens").withColor(0xffd42a))); + lore.add(Text.literal("Unlock with Tokens").withColor(0xffd42a)); } if(requiredRank != null) { if(requireTokens) { - lore.add(Utility.textToNBT(Text.literal("OR").withColor(0xff55aa))); - lore.add(Utility.textToNBT(Text.literal( "Unlock with " + requiredRank.name).withColor(requiredRank.color.getRgb()))); + lore.add(Text.literal("OR").withColor(0xff55aa)); + lore.add(Text.literal("Unlock with " + requiredRank.name).withColor(requiredRank.color.getRgb())); } else { addToLore(lore,""); - lore.add(Utility.textToNBT(Text.literal(requiredRank.name + " Exclusive").withColor(requiredRank.color.getRgb()))); + lore.add(Text.literal(requiredRank.name + " Exclusive").setStyle(Style.EMPTY.withColor(requiredRank.color.getRgb()).withItalic(false))); } } - display.put("Lore", lore); - display.put("Name", Utility.textToNBT(Utility.textFromString(name))); + dfItem.setName(Utility.textFromString(name)); + dfItem.setLore(lore); - nbt.put("display", display); - nbt.put("HideFlags", NbtInt.of(127)); - if (color != null) nbt.put("CustomPotionColor", NbtInt.of(color.getColor())); + dfItem.hideFlags(); - if (head != null) { - NbtCompound SkullOwner = new NbtCompound(); - NbtIntArray Id = new NbtIntArray(List.of(0, 0, 0, 0)); - SkullOwner.put("Id", Id); - SkullOwner.putString("Name", "DF-HEAD"); - NbtCompound Properties = new NbtCompound(); - NbtList textures = new NbtList(); - NbtCompound texture = new NbtCompound(); - texture.putString("Value", head); - textures.add(texture); - Properties.put("textures", textures); - SkullOwner.put("Properties", Properties); - nbt.put("SkullOwner", SkullOwner); - } + if (color != null) dfItem.setDyeColor(color.getColor()); + + if (head != null) dfItem.setProfile(Util.NIL_UUID, head, null); + + dfItem.setCustomModelData(5000); - item.setNbt(nbt); return item; } - private void addToLore(NbtList lore, String text) { - lore.add(Utility.textToNBT(Utility.textFromString(text))); + private void addToLore(ArrayList lore, String text) { + lore.add(Utility.textFromString(text)); } public List getArgGroups() { @@ -240,7 +228,6 @@ public enum Type { this.color = color; this.display = display; var item = icon.getDefaultStack(); - item.setSubNbt("CustomModelData",NbtInt.of(5000)); this.icon = item; getVarItem = null; } @@ -252,9 +239,7 @@ public interface getVarItem { Type(TextColor color, String display, Item icon, @Nullable Icon.Type.getVarItem getVarItem) { this.color = color; this.display = display; - var item = icon.getDefaultStack(); - item.setSubNbt("CustomModelData",NbtInt.of(5000)); - this.icon = item; + this.icon = icon.getDefaultStack(); this.getVarItem = getVarItem; } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Particle.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Particle.java index d41de15a..2ab5c1ef 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Particle.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/Particle.java @@ -2,17 +2,15 @@ import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static dev.dfonline.codeclient.Utility.textToNBT; - public class Particle extends VarItem implements Searchable { public String particle; public String category; @@ -51,17 +49,18 @@ public ItemStack getItem() { ItemStack item = super.getItem("part", data); - NbtCompound display = item.getSubNbt("display"); - NbtList Lore = (NbtList) display.get("Lore"); - Lore.add(textToNBT(Text.literal(""))); - Lore.add(textToNBT(Text.literal("Additional Fields:").formatted(Formatting.GRAY))); - if (optionFields.size() == 0) Lore.add(textToNBT(Text.literal("None").formatted(Formatting.DARK_GRAY))); + DFItem dfItem = DFItem.of(item); + List lore = dfItem.getLore(); + ArrayList newLore = new ArrayList<>(lore); + + newLore.add(Text.empty()); + newLore.add(Text.literal("Additional Fields:").formatted(Formatting.GRAY)); + if (optionFields.isEmpty()) newLore.add(Text.literal("None").formatted(Formatting.DARK_GRAY)); else for (ParticleField field : optionFields) { - if (field != null) Lore.add(textToNBT(Text.literal("• " + field.displayName).formatted(Formatting.WHITE))); - else Lore.add(textToNBT(Text.of("NULL?"))); + if (field != null) newLore.add(Text.literal("• " + field.displayName).formatted(Formatting.WHITE)); + else newLore.add(Text.of("NULL?")); } - display.put("Lore", Lore); - item.setSubNbt("display", display); + dfItem.setLore(newLore); return item; } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/VarItem.java b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/VarItem.java index 745a9fa4..d5878175 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/VarItem.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/actiondump/VarItem.java @@ -1,23 +1,20 @@ package dev.dfonline.codeclient.hypercube.actiondump; import com.google.gson.JsonObject; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtString; public abstract class VarItem { public Icon icon; public ItemStack getItem(String id, JsonObject data) { ItemStack item = icon.getItem(); - NbtCompound nbt = item.getNbt(); - NbtCompound publicBukkitValues = new NbtCompound(); - JsonObject varItem = new JsonObject(); - varItem.addProperty("id", id); - varItem.add("data", data); - publicBukkitValues.put("hypercube:varitem", NbtString.of(varItem.toString())); - nbt.put("PublicBukkitValues", publicBukkitValues); - item.setNbt(nbt); - return item; + + DFItem dfItem = DFItem.of(item); + dfItem.editData(itemData -> { + itemData.setHypercubeStringValue("id", id); + itemData.setHypercubeStringValue("data", data.toString()); + }); + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/BlockTag.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/BlockTag.java index 76625080..5bf5c1c7 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/BlockTag.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/BlockTag.java @@ -2,9 +2,6 @@ import com.google.gson.JsonObject; import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.registry.Registries; -import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/GameValue.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/GameValue.java index 58ffd653..dfdf490a 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/GameValue.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/GameValue.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.Target; import dev.dfonline.codeclient.hypercube.actiondump.ActionDump; import net.minecraft.item.Item; @@ -76,13 +77,14 @@ public void setTarget(Target target) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); + DFItem dfItem = DFItem.of(stack); try { ActionDump db = ActionDump.getActionDump(); var value = Arrays.stream(db.gameValues).filter(gv -> gv.icon.getCleanName().equals(type)).findFirst(); if (value.isEmpty()) throw new Exception(""); - stack.setCustomName(Text.literal(value.get().icon.name)); + dfItem.setName(Text.literal(value.get().icon.name).setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.WHITE))); } catch (Exception e) { - stack.setCustomName(Text.literal(type).setStyle(Style.EMPTY)); + dfItem.setName(Text.literal(type).setStyle(Style.EMPTY)); } Utility.addLore(stack, Text.literal("Target: ").formatted(Formatting.GRAY).append(Text.literal(target.name()).setStyle(Style.EMPTY.withColor(target.color)))); return stack; diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Location.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Location.java index d07dc7dc..758e9079 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Location.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Location.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.actiondump.Icon; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -12,7 +13,7 @@ import net.minecraft.util.math.Vec3d; public class Location extends VarItem { - private JsonObject loc; + private final JsonObject loc; private double x; private double y; private double z; @@ -157,15 +158,16 @@ public void setCoords(double x, double y, double z, double pitch, double yaw) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - stack.setCustomName(Text.literal("Location").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.LOCATION.color))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal("Location").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.LOCATION.color))); Utility.addLore( - stack, + dfItem.getItemStack(), Text.empty().append(Text.literal("X: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.x)), Text.empty().append(Text.literal("Y: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.y)), Text.empty().append(Text.literal("Z: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.z)), Text.empty().append(Text.literal("p: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.pitch)), Text.empty().append(Text.literal("y: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.yaw)) ); - return stack; + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/NamedItem.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/NamedItem.java index 7a63df7b..c736e72b 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/NamedItem.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/NamedItem.java @@ -1,7 +1,7 @@ package dev.dfonline.codeclient.hypercube.item; import com.google.gson.JsonObject; -import net.minecraft.item.Item; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.ItemStack; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -42,6 +42,8 @@ public void setName(String name) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - return stack.setCustomName(Text.literal(name).setStyle(Style.EMPTY.withItalic(false))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal(name).setStyle(Style.EMPTY.withItalic(false))); + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Number.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Number.java index 57d4e98f..6cea8e84 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Number.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Number.java @@ -1,6 +1,7 @@ package dev.dfonline.codeclient.hypercube.item; import com.google.gson.JsonObject; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -37,6 +38,8 @@ public Number() { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - return stack.setCustomName(Text.literal(this.getName()).setStyle(Style.EMPTY.withColor(Formatting.RED).withItalic(false))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal(this.getName()).setStyle(Style.EMPTY.withColor(Formatting.RED).withItalic(false))); + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Potion.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Potion.java index 38260eef..51add3f0 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Potion.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Potion.java @@ -2,8 +2,8 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.actiondump.ActionDump; -import dev.dfonline.codeclient.hypercube.actiondump.Icon; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -89,7 +89,8 @@ public void setAmplifier(int amplifier) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - stack.setCustomName(Text.literal("Potion Effect").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.POTION.color))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal("Potion Effect").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.WHITE))); Text name; try { ActionDump db = ActionDump.getActionDump(); @@ -99,12 +100,12 @@ public ItemStack toStack() { } catch (Exception e) { name = Text.literal(potion).setStyle(Style.EMPTY); } - Utility.addLore(stack, + Utility.addLore(dfItem.getItemStack(), name, Text.empty(), Text.empty().append(Text.literal("Amplifier: ").formatted(Formatting.GRAY)).append(Text.literal(String.valueOf(amplifier + 1))), Text.empty().append(Text.literal("Duration: ").formatted(Formatting.GRAY)).append(Text.literal(duration()))); - return stack; + return dfItem.getItemStack(); } public String duration() { diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Sound.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Sound.java index 26f69284..7ff423e9 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Sound.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Sound.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.actiondump.ActionDump; import dev.dfonline.codeclient.hypercube.actiondump.Icon; import net.minecraft.item.Item; @@ -12,9 +13,7 @@ import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class Sound extends VarItem { private String sound; @@ -98,6 +97,15 @@ public String getSound() { return sound; } + public Optional getSoundId() { + try { + return Arrays.stream(ActionDump.getActionDump().sounds).filter(sound -> Objects.equals(sound.icon.getCleanName(), this.sound)).findFirst(); + } catch (Exception ignored) { + + } + return Optional.empty(); + } + public void setSound(String sound) { this.sound = sound; this.data.addProperty("sound", sound); @@ -136,7 +144,8 @@ public void setVolume(double volume) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - stack.setCustomName(Text.literal("Sound").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.SOUND.color))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal("Sound").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.SOUND.color))); Text name; try { ActionDump db = ActionDump.getActionDump(); @@ -146,11 +155,11 @@ public ItemStack toStack() { } catch (Exception e) { name = Text.literal(sound).setStyle(Style.EMPTY); } - Utility.addLore(stack, + Utility.addLore(dfItem.getItemStack(), name, Text.empty(), Text.empty().append(Text.literal("Pitch: ").formatted(Formatting.GRAY)).append("%.2f".formatted(pitch)), Text.empty().append(Text.literal("Volume: ").formatted(Formatting.GRAY)).append("%.2f".formatted(volume))); - return stack; + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/VarItem.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/VarItem.java index 2c99915e..3200f32f 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/VarItem.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/VarItem.java @@ -2,12 +2,10 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import dev.dfonline.codeclient.data.DFItem; +import dev.dfonline.codeclient.data.PublicBukkitValues; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtInt; -import net.minecraft.nbt.NbtString; import java.util.Objects; @@ -33,34 +31,28 @@ public VarItem() { } public static JsonObject prefetch(ItemStack item) throws Exception { - if (!item.hasNbt()) throw new Exception("Item has no nbt."); - NbtCompound nbt = item.getNbt(); - if (nbt == null) throw new Exception("NBT is null."); - if (!nbt.contains("PublicBukkitValues", NbtElement.COMPOUND_TYPE)) - throw new Exception("Item has no PublicBukkitValues"); - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - if (!publicBukkit.contains("hypercube:varitem", NbtElement.STRING_TYPE)) - throw new Exception("Item has no hypercube:varitem"); - String varitem = publicBukkit.getString("hypercube:varitem"); + DFItem dfItem = DFItem.of(item); + PublicBukkitValues pbv = dfItem.getPublicBukkitValues(); + String varitem = pbv.getHypercubeStringValue("varitem"); + if (varitem.isEmpty()) throw new Exception("Item does not have a varitem"); return JsonParser.parseString(varitem).getAsJsonObject(); } public ItemStack getIcon() { ItemStack item = getIconItem().getDefaultStack(); - item.setSubNbt("CustomModelData", NbtInt.of(5000)); + DFItem dfItem = DFItem.of(item); + dfItem.setCustomModelData(5000); return item; } public ItemStack toStack() { - var pbv = new NbtCompound(); + DFItem dfItem = DFItem.of(getIcon()); var varItem = new JsonObject(); varItem.addProperty("id", getId()); varItem.add("data", data); - pbv.put("hypercube:varitem", NbtString.of(varItem.toString())); - var item = getIcon(); - item.setSubNbt("PublicBukkitValues", pbv); - return item; + dfItem.getPublicBukkitValues().setHypercubeStringValue("varitem", varItem.toString()); + return dfItem.getItemStack(); } public JsonObject getData() { diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Variable.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Variable.java index 4d59861e..728dd24b 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Variable.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Variable.java @@ -2,6 +2,7 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -44,8 +45,9 @@ protected Item getIconItem() { @Override public ItemStack toStack() { var stack = super.toStack(); - stack.setCustomName(Text.literal(getName()).setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.WHITE))); - Utility.addLore(stack, Text.literal(scope.longName).setStyle(Style.EMPTY.withColor(scope.color))); - return stack; + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal(getName()).setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.WHITE))); + Utility.addLore(dfItem.getItemStack(), Text.literal(scope.longName).setStyle(Style.EMPTY.withColor(scope.color))); + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/item/Vector.java b/src/main/java/dev/dfonline/codeclient/hypercube/item/Vector.java index 5e68de42..ed6185b4 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/item/Vector.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/item/Vector.java @@ -3,7 +3,7 @@ import com.google.gson.JsonObject; import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; -import dev.dfonline.codeclient.hypercube.actiondump.Icon; +import dev.dfonline.codeclient.data.DFItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -89,13 +89,14 @@ public void setCoords(Double x, Double y, Double z) { @Override public ItemStack toStack() { ItemStack stack = super.toStack(); - stack.setCustomName(Text.literal("Vector").setStyle(Style.EMPTY.withItalic(false).withColor(Icon.Type.VECTOR.color))); + DFItem dfItem = DFItem.of(stack); + dfItem.setName(Text.literal("Vector").setStyle(Style.EMPTY.withItalic(false).withColor(Formatting.WHITE))); Utility.addLore( - stack, + dfItem.getItemStack(), Text.empty().append(Text.literal("X: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.x)), Text.empty().append(Text.literal("Y: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.y)), Text.empty().append(Text.literal("Z: ").formatted(Formatting.GRAY)).append("%.2f".formatted(this.z)) ); - return stack; + return dfItem.getItemStack(); } } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/template/Argument.java b/src/main/java/dev/dfonline/codeclient/hypercube/template/Argument.java index 46f98250..27db74cb 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/template/Argument.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/template/Argument.java @@ -1,6 +1,7 @@ package dev.dfonline.codeclient.hypercube.template; import com.google.gson.JsonObject; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.item.VarItem; import dev.dfonline.codeclient.hypercube.item.VarItems; import net.minecraft.item.Item; @@ -64,9 +65,10 @@ public MinecraftItem(@NotNull ItemStack item) { @Override public JsonObject getData() { + DFItem dfItem = DFItem.of(stack); + dfItem.removeItemData(); var data = new JsonObject(); var item = new NbtCompound(); - stack.writeNbt(item); data.addProperty("item", item.toString()); return data; } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/MKeyboard.java b/src/main/java/dev/dfonline/codeclient/mixin/MKeyboard.java index 9a652bb1..54e11f61 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/MKeyboard.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/MKeyboard.java @@ -1,7 +1,5 @@ package dev.dfonline.codeclient.mixin; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.config.KeyBinds; import dev.dfonline.codeclient.location.Creator; @@ -10,8 +8,6 @@ import dev.dfonline.codeclient.switcher.SpeedSwitcher; import dev.dfonline.codeclient.switcher.StateSwitcher; import net.minecraft.client.Keyboard; -import net.minecraft.client.gui.Element; -import net.minecraft.client.gui.screen.Screen; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -52,15 +48,4 @@ private void onKey(long window, int key, int scancode, int action, int modifiers CodeClient.isPreviewingItemTags = action == 1 || action == 2; } } - - // guys i gotta love mixing into lambda methods. - @WrapOperation(method = "method_1458", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Element;charTyped(CI)Z")) - private static boolean charTyped(Element instance, char chr, int modifiers, Operation original) { - return CodeClient.onCharTyped(chr, modifiers) || original.call(instance, chr, modifiers); - } - - @WrapOperation(method = "method_1454", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyReleased(III)Z")) - private static boolean keyReleased(Screen instance, int keyCode, int scanCode, int modifiers, Operation original) { - return CodeClient.onKeyReleased(keyCode, scanCode, modifiers) || original.call(instance, keyCode, scanCode, modifiers); - } } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/entity/MLivingEntity.java b/src/main/java/dev/dfonline/codeclient/mixin/entity/MLivingEntity.java index 991e1c28..cf1a2a92 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/entity/MLivingEntity.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/entity/MLivingEntity.java @@ -1,9 +1,7 @@ package dev.dfonline.codeclient.mixin.entity; import dev.dfonline.codeclient.CodeClient; -import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.dev.Navigation; -import dev.dfonline.codeclient.dev.NoClip; import net.minecraft.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerEntity.java b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerEntity.java index c94c201e..796d5b25 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerEntity.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerEntity.java @@ -2,8 +2,6 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.action.impl.MoveToSpawn; -import dev.dfonline.codeclient.config.Config; -import dev.dfonline.codeclient.dev.InteractionManager; import dev.dfonline.codeclient.dev.Navigation; import dev.dfonline.codeclient.dev.NoClip; import dev.dfonline.codeclient.location.Dev; @@ -62,12 +60,12 @@ private void sendMovementPackets(CallbackInfo ci) { if (position) { NoClip.timesSinceMoved = 0; if (rotation) { - this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(pos.x, pos.y, pos.z, yaw, pitch, false)); + this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(pos.x, pos.y, pos.z, yaw, pitch, false, true)); } else { - this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(pos.x, pos.y, pos.z, false)); + this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(pos.x, pos.y, pos.z, false, true)); } } else { - this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, false)); + this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, false, true)); } } NoClip.lastPos = pos; diff --git a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerInteractionManager.java b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerInteractionManager.java index 19620e1e..aa12555a 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerInteractionManager.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MClientPlayerInteractionManager.java @@ -3,9 +3,9 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.dev.BlockBreakDeltaCalculator; import dev.dfonline.codeclient.dev.InteractionManager; -import dev.dfonline.codeclient.dev.NoClip; import dev.dfonline.codeclient.location.Dev; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; @@ -17,13 +17,9 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtElement; -import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -35,8 +31,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ClientPlayerInteractionManager.class) @@ -78,7 +72,7 @@ public void onBreakBlock(BlockPos pos, CallbackInfoReturnable cir) { @Inject(method = "interactBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;sendSequencedPacket(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V")) public void beforeSendPlace(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) { ItemStack handItem = player.getStackInHand(hand); - boolean isTemplate = handItem.hasNbt() && handItem.getNbt() != null && handItem.getNbt().contains("PublicBukkitValues", NbtElement.COMPOUND_TYPE) && handItem.getNbt().getCompound("PublicBukkitValues").contains("hypercube:codetemplatedata", NbtElement.STRING_TYPE); + boolean isTemplate = DFItem.of(handItem).hasHypercubeKey("codetemplatedata"); if (!isTemplate) return; BlockPos place = InteractionManager.getPlacePos(hitResult); if (place != null && CodeClient.MC.world.getBlockState(place).isSolidBlock(CodeClient.MC.world, place)) { @@ -93,8 +87,9 @@ public void beforeSendPlace(ClientPlayerEntity player, Hand hand, BlockHitResult } } ItemStack template = Items.ENDER_CHEST.getDefaultStack(); - template.setNbt(handItem.getNbt()); - Utility.sendHandItem(template); + DFItem dfTemplate = DFItem.of(template); + dfTemplate.setItemData(DFItem.of(handItem).getItemData()); + Utility.sendHandItem(dfTemplate.getItemStack()); item = handItem; } @@ -111,13 +106,6 @@ public void afterSendPlace(ClientPlayerEntity player, Hand hand, BlockHitResult } } - @Redirect(method = "interactItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V")) - public void interactItemMovement(ClientPlayNetworkHandler instance, Packet packet) { - if (!CodeClient.getFeature(NoClip.class).map(NoClip::isIgnoringWalls).orElse(false)) { - instance.sendPacket(packet); - } - } - @Inject(method = "interactItem", at = @At("HEAD"), cancellable = true) public void interactItem(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { if (InteractionManager.onItemInteract(player, hand)) { @@ -125,13 +113,6 @@ public void interactItem(PlayerEntity player, Hand hand, CallbackInfoReturnable< } } - @Inject(method = "getReachDistance", at = @At("HEAD"), cancellable = true) - private void reachDistance(CallbackInfoReturnable cir) { - if (CodeClient.location instanceof Dev) { - cir.setReturnValue(Config.getConfig().ReachDistance); - } - } - @Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true) private void attackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { if (!Config.getConfig().CustomBlockBreaking) return; diff --git a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MPlayerEntity.java b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MPlayerEntity.java index 87e50a64..f6d285cc 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MPlayerEntity.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/entity/player/MPlayerEntity.java @@ -1,14 +1,14 @@ package dev.dfonline.codeclient.mixin.entity.player; import dev.dfonline.codeclient.CodeClient; -import dev.dfonline.codeclient.config.Config; -import dev.dfonline.codeclient.dev.InteractionManager; import dev.dfonline.codeclient.dev.Navigation; import dev.dfonline.codeclient.dev.NoClip; -import dev.dfonline.codeclient.location.Dev; import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,7 +16,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class MPlayerEntity { +public abstract class MPlayerEntity extends LivingEntity { + + protected MPlayerEntity(EntityType entityType, World world) { + super(entityType, world); + } + @Inject(method = "getOffGroundSpeed", at = @At("HEAD"), cancellable = true) private void getAirSpeed(CallbackInfoReturnable cir) { if (!(CodeClient.MC.player != null && CodeClient.MC.player.getAbilities().flying)) { @@ -24,9 +29,9 @@ private void getAirSpeed(CallbackInfoReturnable cir) { } } - @Inject(method = "jump", at = @At("HEAD"), cancellable = true) - private void jump(CallbackInfo ci) { - if(CodeClient.getFeature(Navigation.class).map(Navigation::onJump).orElse(false)) { + @Inject(method = "travel", at = @At("HEAD"), cancellable = true) + private void jump(Vec3d movementInput, CallbackInfo ci) { + if (this.jumping && CodeClient.getFeature(Navigation.class).map(Navigation::onJump).orElse(false)) { ci.cancel(); } } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/MDebugRenderer.java b/src/main/java/dev/dfonline/codeclient/mixin/render/MDebugRenderer.java index d82aff56..e36957ac 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/MDebugRenderer.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/render/MDebugRenderer.java @@ -1,6 +1,7 @@ package dev.dfonline.codeclient.mixin.render; import dev.dfonline.codeclient.CodeClient; +import net.minecraft.client.render.Frustum; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.debug.DebugRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -12,7 +13,7 @@ @Mixin(DebugRenderer.class) public class MDebugRenderer { @Inject(method = "render", at = @At("HEAD")) - private void onRender(MatrixStack matrices, VertexConsumerProvider.Immediate vertexConsumers, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { + private void onRender(MatrixStack matrices, Frustum frustum, VertexConsumerProvider.Immediate vertexConsumers, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { CodeClient.onRender(matrices, vertexConsumers, cameraX, cameraY, cameraZ); } } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MDrawContext.java b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MDrawContext.java index 6fb540cf..0c9b4cdb 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MDrawContext.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MDrawContext.java @@ -23,8 +23,8 @@ public abstract class MDrawContext { @Shadow public abstract int drawText(TextRenderer textRenderer, Text text, int x, int y, int color, boolean shadow); - @Inject(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", shift = At.Shift.AFTER)) - private void additionalItemRendering(TextRenderer textRenderer, ItemStack stack, int x, int y, String countOverride, CallbackInfo ci) { + @Inject(method = "drawStackOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", shift = At.Shift.AFTER)) + private void additionalItemRendering(TextRenderer textRenderer, ItemStack stack, int x, int y, String stackCountText, CallbackInfo ci) { CodeClient.getFeature(ValueDetails.class).ifPresent(valueDetails -> valueDetails.draw(this::drawText, textRenderer, stack, x, y, matrices)); } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java index 5667d4b7..6c2ae72a 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java @@ -6,14 +6,15 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.OverlayManager; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.dev.overlay.ChestPeeker; import dev.dfonline.codeclient.dev.overlay.SignPeeker; import dev.dfonline.codeclient.hypercube.item.Scope; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Style; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; @@ -28,16 +29,15 @@ @Mixin(InGameHud.class) public abstract class MInGameHud { - @Shadow - private int scaledHeight; - @Shadow - private int scaledWidth; @Shadow public abstract TextRenderer getTextRenderer(); @Inject(method = "render", at = @At("HEAD")) - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + int scaledWidth = context.getScaledWindowWidth(); + int scaledHeight = context.getScaledWindowHeight(); + TextRenderer textRenderer = getTextRenderer(); List overlay = new ArrayList<>(List.copyOf(OverlayManager.getOverlayText())); @@ -92,13 +92,12 @@ private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { public void renderHeldItemTooltip(DrawContext context, CallbackInfo ci) { if (!Config.getConfig().ShowVariableScopeBelowName) return; - if (!currentStack.hasNbt()) return; - NbtCompound nbt = currentStack.getNbt(); - if (nbt == null) return; - if (!nbt.contains("PublicBukkitValues")) return; - NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues"); - if (!publicBukkit.contains("hypercube:varitem")) return; - String varItem = publicBukkit.getString("hypercube:varitem"); + DFItem dfItem = DFItem.of(currentStack); + if (!dfItem.hasHypercubeKey("varitem")) return; + String varItem = dfItem.getHypercubeStringValue("varitem"); + + int scaledWidth = context.getScaledWindowWidth(); + int scaledHeight = context.getScaledWindowHeight(); try { JsonObject varItemJson = JsonParser.parseString(varItem).getAsJsonObject(); diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MTitleScreen.java b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MTitleScreen.java index d367ca6c..0c0e4c5d 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MTitleScreen.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MTitleScreen.java @@ -17,7 +17,7 @@ public class MTitleScreen { public void onInit(CallbackInfo ci) { if (CodeClient.autoJoin == CodeClient.AutoJoin.GAME) { ServerInfo info = new ServerInfo("DiamondFire", Config.getConfig().AutoNode.prepend + "mcdiamondfire.com", ServerInfo.ServerType.OTHER); - ConnectScreen.connect((TitleScreen) (Object) this, CodeClient.MC, ServerAddress.parse(info.address), info, true); + ConnectScreen.connect((TitleScreen) (Object) this, CodeClient.MC, ServerAddress.parse(info.address), info, true, null); CodeClient.autoJoin = Config.getConfig().AutoJoinPlot ? CodeClient.AutoJoin.PLOT : CodeClient.AutoJoin.NONE; } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java index 886ff68b..db6a37ec 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java @@ -1,6 +1,7 @@ package dev.dfonline.codeclient.mixin.screen; import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.command.CommandSender; import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.location.Dev; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; @@ -26,11 +27,11 @@ public void slotClicked(@Nullable Slot slot, int slotId, int button, SlotActionT && actionType == SlotActionType.QUICK_MOVE && slot == this.deleteItemSlot) { - String cmd = Config.DestroyItemResetMode.command; + String cmd = Config.getConfig().DestroyItemResetMode.command; if (cmd != null) { CodeClient.MC.setScreen(null); - CodeClient.MC.getNetworkHandler().sendCommand(cmd); + CommandSender.queue(cmd); ci.cancel(); } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/MElement.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MElement.java new file mode 100644 index 00000000..51e418dc --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MElement.java @@ -0,0 +1,16 @@ +package dev.dfonline.codeclient.mixin.screen; + +import dev.dfonline.codeclient.CodeClient; +import net.minecraft.client.gui.Element; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Element.class) +public interface MElement { + @Inject(method = "keyReleased", at = @At("HEAD"), cancellable = true) + default void keyReleased(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { + if (CodeClient.onKeyReleased(keyCode, scanCode, modifiers)) cir.setReturnValue(true); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreen.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreen.java index ecf9317b..b209a881 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreen.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreen.java @@ -2,8 +2,6 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.dev.InteractionManager; -import dev.dfonline.codeclient.dev.menu.SlotGhostManager; -import dev.dfonline.codeclient.dev.overlay.ActionViewer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.item.ItemStack; diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreens.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreens.java index 3bb54c64..06bc2c00 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreens.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MHandledScreens.java @@ -6,7 +6,6 @@ import dev.dfonline.codeclient.dev.InteractionManager; import dev.dfonline.codeclient.dev.menu.customchest.CustomChestHandler; import dev.dfonline.codeclient.dev.menu.customchest.CustomChestMenu; -import dev.dfonline.codeclient.dev.overlay.ActionViewer; import net.minecraft.client.gui.screen.ingame.HandledScreens; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; @@ -14,7 +13,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import java.util.Map; diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/MTextFieldWidget.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MTextFieldWidget.java new file mode 100644 index 00000000..b79f9d3f --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MTextFieldWidget.java @@ -0,0 +1,17 @@ +package dev.dfonline.codeclient.mixin.screen; + +import dev.dfonline.codeclient.CodeClient; +import net.minecraft.client.gui.widget.TextFieldWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(TextFieldWidget.class) +public class MTextFieldWidget { + @Inject(method = "charTyped", at = @At("HEAD")) + public void charTypes(char chr, int modifiers, CallbackInfoReturnable cir) { + if (CodeClient.onCharTyped(chr, modifiers)) cir.setReturnValue(true); + + } +} diff --git a/src/main/java/dev/dfonline/codeclient/mixin/screen/chat/MChatInputSuggester.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/chat/MChatInputSuggester.java index 56dd9d7a..7565c7a4 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/screen/chat/MChatInputSuggester.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/chat/MChatInputSuggester.java @@ -3,7 +3,6 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.dev.highlighter.ExpressionHighlighter; import dev.dfonline.codeclient.location.Dev; -import net.kyori.adventure.text.Component; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ChatInputSuggestor; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -28,7 +27,6 @@ public class MChatInputSuggester { @Unique private OrderedText preview = null; - @Inject(method = "provideRenderText", at = @At("RETURN"), cancellable = true) private void provideRenderText(String partial, int position, CallbackInfoReturnable cir) { if (Objects.equals(partial, "")) return; @@ -56,5 +54,4 @@ private void renderPreview(DrawContext context, int mouseX, int mouseY, Callback preview = null; // prevents a preview from showing if the player deletes all text }); } - } diff --git a/src/main/java/dev/dfonline/codeclient/mixin/world/MWorldRenderer.java b/src/main/java/dev/dfonline/codeclient/mixin/world/MWorldRenderer.java index 86b9dd9a..87eb842c 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/world/MWorldRenderer.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/world/MWorldRenderer.java @@ -23,7 +23,7 @@ public class MWorldRenderer { @Nullable private ClientWorld world; - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isAir()Z")) + @Redirect(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isAir()Z")) private boolean isAir(BlockState instance) { if (client.crosshairTarget instanceof BlockHitResult hitResult) { if (InteractionManager.customVoxelShape(world, hitResult.getBlockPos()) != null) return false; diff --git a/src/main/java/dev/dfonline/codeclient/switcher/GenericSwitcher.java b/src/main/java/dev/dfonline/codeclient/switcher/GenericSwitcher.java index 68d4602a..8e752d84 100644 --- a/src/main/java/dev/dfonline/codeclient/switcher/GenericSwitcher.java +++ b/src/main/java/dev/dfonline/codeclient/switcher/GenericSwitcher.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.util.InputUtil; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; @@ -21,9 +22,9 @@ * It can reasonably hold up to 4 options. */ public abstract class GenericSwitcher extends Screen { - private static final Identifier TEXTURE = new Identifier("textures/gui/container/gamemode_switcher.png"); - private static final Identifier SLOT_TEXTURE = new Identifier("gamemode_switcher/slot"); - private static final Identifier SELECTED_TEXTURE = new Identifier("gamemode_switcher/selection"); + private static final Identifier TEXTURE = Identifier.ofVanilla("textures/gui/container/gamemode_switcher.png"); + private static final Identifier SLOT_TEXTURE = Identifier.ofVanilla("gamemode_switcher/slot"); + private static final Identifier SELECTED_TEXTURE = Identifier.ofVanilla("gamemode_switcher/selection"); /** * Key to hold down, generally F3. * The selected option will be run when this is released. @@ -76,7 +77,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { RenderSystem.enableBlend(); int centerX = this.width / 2 - 62; int centerY = this.height / 2 - 31 - 27; - context.drawTexture(TEXTURE, centerX, centerY, 0.0F, 0.0F, 125, 75, 128, 128); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, centerX, centerY, 0, 0, 125, 75, 128, 128); context.getMatrices().pop(); super.render(context, mouseX, mouseY, delta); @@ -102,8 +103,9 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { if (button.getX() < mouseX && button.getX() + 31 > mouseX) this.selected = i; } button.selected = this.selected == i; - context.drawGuiTexture(SLOT_TEXTURE, button.getX(), button.getY(), 26, 26); - if (button.selected) context.drawGuiTexture(SELECTED_TEXTURE, button.getX(), button.getY(), 26, 26); + context.drawGuiTexture(RenderLayer::getGuiTextured, SLOT_TEXTURE, button.getX(), button.getY(), 26, 26); + if (button.selected) + context.drawGuiTexture(RenderLayer::getGuiTextured, SELECTED_TEXTURE, button.getX(), button.getY(), 26, 26); button.render(context, mouseX, mouseY, delta); ++i; } @@ -196,16 +198,16 @@ public SelectableButtonWidget(Option option, int x, int y) { public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { context.getMatrices().push(); context.getMatrices().translate((float) this.getX(), (float) this.getY(), 0.0F); - context.drawTexture(TEXTURE, 0, 0, 0.0F, 75.0F, 26, 26, 128, 128); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, 0, 0, 0.0F, 75.0F, 26, 26, 128, 128); context.getMatrices().pop(); context.drawItem(option.icon, this.getX() + 5, this.getY() + 5); - context.drawItemInSlot(textRenderer, option.icon, this.getX() + 5, this.getY() + 5); + context.drawStackOverlay(textRenderer, option.icon, this.getX() + 5, this.getY() + 5); if (selected) { context.getMatrices().push(); context.getMatrices().translate((float) this.getX(), (float) this.getY(), 0.0F); - context.drawTexture(TEXTURE, 0, 0, 26.0F, 75.0F, 26, 26, 128, 128); + context.drawGuiTexture(RenderLayer::getGuiTextured, TEXTURE, 0, 0, 26, 75, 26, 26, 128, 128); context.getMatrices().pop(); } } diff --git a/src/main/java/dev/dfonline/codeclient/switcher/ScopeSwitcher.java b/src/main/java/dev/dfonline/codeclient/switcher/ScopeSwitcher.java index bc08f350..1bff81c2 100644 --- a/src/main/java/dev/dfonline/codeclient/switcher/ScopeSwitcher.java +++ b/src/main/java/dev/dfonline/codeclient/switcher/ScopeSwitcher.java @@ -4,13 +4,11 @@ import com.google.gson.JsonParser; import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.data.DFItem; +import dev.dfonline.codeclient.data.PublicBukkitValues; import dev.dfonline.codeclient.hypercube.item.Scope; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; -import net.minecraft.nbt.NbtString; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -21,7 +19,7 @@ import java.util.List; public class ScopeSwitcher extends GenericSwitcher { - private String option; + private final String option; public ScopeSwitcher(String option) { super(Text.translatable("codeclient.switcher.scope"), -1, GLFW.GLFW_KEY_SPACE); @@ -44,37 +42,30 @@ protected void init() { @Override List