diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2860bb89..87eb9d6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: 21 - distribution: "temurin" + 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 0979f1ab..01623479 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ dependencies { modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" // 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. diff --git a/gradle.properties b/gradle.properties index 25ac0e7c..858a2321 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,5 @@ archives_base_name=CodeClient 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/src/main/java/dev/dfonline/codeclient/CodeClient.java b/src/main/java/dev/dfonline/codeclient/CodeClient.java index d01d7a53..d7939985 100644 --- a/src/main/java/dev/dfonline/codeclient/CodeClient.java +++ b/src/main/java/dev/dfonline/codeclient/CodeClient.java @@ -5,6 +5,7 @@ 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; @@ -15,6 +16,7 @@ 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; import dev.dfonline.codeclient.dev.menu.InsertOverlayFeature; import dev.dfonline.codeclient.dev.menu.RecentValues; import dev.dfonline.codeclient.dev.menu.SlotGhostManager; @@ -50,6 +52,7 @@ 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; @@ -115,6 +118,8 @@ public void onInitializeClient() { 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 { API.start(); @@ -187,7 +192,7 @@ private static void loadFeatures() { feat(new ChatAutoEdit()); feat(new CPUDisplay()); feat(new MessageHiding()); - //FIXME: feat(new ExpressionHighlighter()); + feat(new ExpressionHighlighter()); } /** @@ -225,6 +230,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; @@ -272,6 +283,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); diff --git a/src/main/java/dev/dfonline/codeclient/Event.java b/src/main/java/dev/dfonline/codeclient/Event.java index d55494cb..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; @@ -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/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 d7fc635c..6f3180aa 100644 --- a/src/main/java/dev/dfonline/codeclient/Utility.java +++ b/src/main/java/dev/dfonline/codeclient/Utility.java @@ -7,6 +7,7 @@ import dev.dfonline.codeclient.action.impl.GetActionDump; import dev.dfonline.codeclient.data.DFItem; import dev.dfonline.codeclient.hypercube.template.Template; +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; @@ -17,6 +18,7 @@ import net.minecraft.text.*; import net.minecraft.util.Formatting; import org.jetbrains.annotations.Nullable; +import net.kyori.adventure.text.Component; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,8 +28,6 @@ import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; -//FIXME: 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. @@ -174,7 +174,6 @@ 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) { - assert CodeClient.MC.world != null; JsonElement json = TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, text).getOrThrow(); if (json.isJsonObject()) { JsonObject obj = (JsonObject) json; @@ -299,25 +298,24 @@ public static String fromTrimmed(String trimmedUUID) { return builder.toString(); } - /* FIXME: */ -// /** -// * Turns a {@link 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(); -// } -// -// /** -// * Turns a {@link 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); -// } + /** + * 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 NonWrappingComponentSerializer.INSTANCE.serialize(component).asOrderedText(); + } + + /** + * 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 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/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 94416a9c..d13b341a 100644 --- a/src/main/java/dev/dfonline/codeclient/command/CommandManager.java +++ b/src/main/java/dev/dfonline/codeclient/command/CommandManager.java @@ -27,7 +27,7 @@ public class CommandManager { new CommandName(), new CommandNode(), new CommandPing(), - //FIXME: new CommandPreview(), + new CommandPreview(), new CommandSave(), new CommandScanFor(), new CommandScanPlot(), @@ -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..06a90925 --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/CommandSender.java @@ -0,0 +1,69 @@ +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, int delay, Runnable callback) { + rateLimiter.increment(); + for (int i = 0; i < delay; i++) { + } + commandQueue.add(command); + if (callback != null) { + callback.run(); + } + } + + public static void queue(String command, int delay) { + queue(command, delay, null); + } + + public static void queue(String command) { + queue(command, 0, null); + } + */ + + public static void queue(String command) { +// rateLimiter.increment(); + 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/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/CommandPreview.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java index fed5a6d1..f6813e37 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandPreview.java @@ -1,6 +1,5 @@ package dev.dfonline.codeclient.command.impl; -/*FIXME import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; @@ -50,5 +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 +} \ 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 a045a6af..c42cb94e 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -71,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; @@ -156,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); @@ -555,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( @@ -563,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/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 6e4ce06b..bb490b20 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java +++ b/src/main/java/dev/dfonline/codeclient/dev/BuildPhaser.java @@ -1,33 +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.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 { @@ -36,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() { @@ -48,6 +40,7 @@ public void reset() { waitForTP = false; dontSpamBuildWarn = false; heldKeyCheck = false; + velocity = null; } public boolean isClipping() { @@ -59,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")); @@ -96,19 +89,19 @@ public void tick() { 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) { @@ -116,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.teleportId())); +// CodeClient.MC.getNetworkHandler().sendPacket(new TeleportConfirmC2SPacket(move.teleportId())); + + updateVelocity = true; return true; } if (packet instanceof EntityAnimationS2CPacket) return true; @@ -144,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(); @@ -167,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/RecentChestInsert.java b/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java index 8e445080..dba92ca4 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java +++ b/src/main/java/dev/dfonline/codeclient/dev/RecentChestInsert.java @@ -36,7 +36,9 @@ 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; - color = (int) (alpha * 255) << 24 | (color & 0x00FFFFFF); + 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/highlighter/ExpressionHighlighter.java b/src/main/java/dev/dfonline/codeclient/dev/highlighter/ExpressionHighlighter.java index 51e8363c..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; -/** FIXME 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 6cfbb2dc..9c4674a4 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java +++ b/src/main/java/dev/dfonline/codeclient/dev/highlighter/MiniMessageHighlighter.java @@ -1,6 +1,5 @@ package dev.dfonline.codeclient.dev.highlighter; -/* FIXME import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.hypercube.HypercubeMiniMessage; import net.kyori.adventure.text.Component; @@ -28,6 +27,9 @@ // / 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 @@ -45,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)) @@ -54,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<>()); @@ -77,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()) { @@ -157,5 +160,4 @@ public boolean has(@NotNull String name) { } } -} -*/ \ No newline at end of file +} \ No newline at end of file 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 1567d07d..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 @@ -22,6 +22,7 @@ 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; @@ -30,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,7 +91,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { 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 ( @@ -95,12 +100,18 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { && relY > y && relY < y + 18 ) { - /* FIXME: render - 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.drawGuiTexture(RenderLayer::getGuiTextured, 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.drawGuiTexture(RenderLayer::getGuiTextured, Size.TEXTURE, centerX, centerY, 0, 0, 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.drawGuiTexture(RenderLayer::getGuiTextured, 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/devinventory/DevInventoryScreen.java b/src/main/java/dev/dfonline/codeclient/dev/menu/devinventory/DevInventoryScreen.java index 69a0200c..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 @@ -16,16 +16,18 @@ import net.minecraft.client.gui.DrawContext; 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.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.resource.featuretoggle.FeatureSet; import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenTexts; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.ClickEvent; @@ -45,10 +47,10 @@ import static dev.dfonline.codeclient.dev.menu.devinventory.DevInventoryGroup.*; @Environment(EnvType.CLIENT) -public class DevInventoryScreen extends CreativeInventoryScreen { +public class DevInventoryScreen extends HandledScreen { static final SimpleInventory Inventory = new SimpleInventory(45); private static final Identifier TEXTURE = CodeClient.getId("textures/gui/container/dev_inventory/tabs.png"); - private static final String TAB_TEXTURE_PREFIX = "textures/gui/container/creative_inventory/tab_"; +// 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,7 +66,10 @@ public class DevInventoryScreen extends CreativeInventoryScreen { private boolean scrolling = false; public DevInventoryScreen(ClientPlayerEntity player) { - super(player, FeatureSet.empty(), CodeClient.MC.options.getOperatorItemsTab().getValue()); + super(new CreativeInventoryScreen.CreativeScreenHandler(player), player.getInventory(), ScreenTexts.EMPTY); + + +// super(player, FeatureSet.empty(), CodeClient.MC.options.getOperatorItemsTab().getValue()); player.currentScreenHandler = this.handler; this.backgroundHeight = 136; this.backgroundWidth = 195; @@ -377,7 +382,7 @@ protected void drawBackground(DrawContext context, float delta, int mouseX, int String texture = "item_search"; if (!itemGroup.hasSearchBar()) texture = "items"; if (itemGroup == INVENTORY) texture = "inventory"; - context.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.ofVanilla(TAB_TEXTURE_PREFIX + texture + ".png"), this.x, this.y, this.backgroundWidth, this.backgroundHeight); + context.drawTexture(RenderLayer::getGuiTextured, ItemGroup.getTabTextureId(texture), this.x, this.y, 0.0f, 0.0f, this.backgroundWidth, this.backgroundHeight, 256, 256); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, TEXTURE); this.renderTabIcon(context, itemGroup); @@ -387,9 +392,9 @@ protected void drawBackground(DrawContext context, float delta, int mouseX, int int scrollbarX = this.x + 175; int scrollbarY = this.y + 18; if (scrollHeight == 0) - context.drawGuiTexture(RenderLayer::getGuiTextured, TEXTURE, scrollbarX, scrollbarY, 244, 0, 256, 256, 12, 15); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, scrollbarX, scrollbarY, 244, 0, 12, 15, 256, 256); else - context.drawGuiTexture(RenderLayer::getGuiTextured, TEXTURE, scrollbarX, scrollbarY + (95 * (int) (this.scrollPosition * 9) / (scrollHeight)), 256, 256, 232, 0, 12, 15); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, scrollbarX, scrollbarY + (95 * (int) (this.scrollPosition * 9) / (scrollHeight)), 232, 0, 12, 15, 256, 256); } else { if (this.client != null && this.client.player != null) InventoryScreen.drawEntity(context, this.x + 73, this.y + 6, this.x + 105, this.y + 49, 20, 0.0625F, (float) mouseX, (float) mouseY, this.client.player); @@ -416,7 +421,7 @@ protected void renderTabIcon(DrawContext context, DevInventoryGroup group) { if (isSelected) mapY += 32; if (!isTopRow) mapY += 64; - context.drawGuiTexture(RenderLayer::getGuiTextured, TEXTURE, originX, originY, mapX, mapY, 256, 256, TAB_WIDTH, 32); + context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, originX, originY, mapX, mapY, TAB_WIDTH, 32, 256, 256); // this.itemRenderer.zOffset = 100.0F; originX += 6; originY += 8 + (isTopRow ? 2 : -2); diff --git a/src/main/java/dev/dfonline/codeclient/dev/overlay/ActionViewer.java b/src/main/java/dev/dfonline/codeclient/dev/overlay/ActionViewer.java index c1f44bd2..94033218 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/overlay/ActionViewer.java +++ b/src/main/java/dev/dfonline/codeclient/dev/overlay/ActionViewer.java @@ -18,7 +18,6 @@ import net.minecraft.client.gui.tooltip.TooltipBackgroundRenderer; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.gui.tooltip.TooltipPositioner; -import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.item.Item; import net.minecraft.item.tooltip.TooltipType; @@ -160,7 +159,7 @@ private void drawTooltip(DrawContext context, HandledScreen handledScreen, Li tooltipComponent = components.get(index); TooltipComponent finalTooltipComponent = tooltipComponent; int finalTextY = textY; - context.draw(consumer -> finalTooltipComponent.drawText(textRenderer, vector.x(), finalTextY, context.getMatrices().peek().getPositionMatrix(), (VertexConsumerProvider.Immediate) consumer.getBuffer(RenderLayer.getGui()))); + context.draw(consumer -> finalTooltipComponent.drawText(textRenderer, vector.x(), finalTextY, context.getMatrices().peek().getPositionMatrix(), (VertexConsumerProvider.Immediate) consumer)); textY += tooltipComponent.getHeight(textRenderer) + (index == 0 ? 2 : 0); } diff --git a/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java b/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java index 8eb99215..58ef9291 100644 --- a/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java +++ b/src/main/java/dev/dfonline/codeclient/hypercube/HypercubeMiniMessage.java @@ -1,5 +1,5 @@ package dev.dfonline.codeclient.hypercube; -/* FIXME + import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.tag.Tag; @@ -38,5 +38,4 @@ private static TagResolver repetitionTagResolver(String name, String literal) { }); } } -} -*/ \ No newline at end of file +} \ 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/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/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/screen/MCreativeInventoryScreen.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java index 886ff68b..40cfa83b 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/screen/MCreativeInventoryScreen.java @@ -26,11 +26,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); + CodeClient.MC.getNetworkHandler().sendChatCommand(cmd); ci.cancel(); } 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/chat/MChatInputSuggester.java b/src/main/java/dev/dfonline/codeclient/mixin/screen/chat/MChatInputSuggester.java index 502f6657..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 @@ -1,12 +1,23 @@ package dev.dfonline.codeclient.mixin.screen.chat; +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.dev.highlighter.ExpressionHighlighter; +import dev.dfonline.codeclient.location.Dev; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ChatInputSuggestor; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.text.OrderedText; +import org.apache.commons.lang3.IntegerRange; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Objects; @Mixin(ChatInputSuggestor.class) public class MChatInputSuggester { @@ -15,8 +26,7 @@ public class MChatInputSuggester { TextFieldWidget textField; @Unique - private final OrderedText preview = null; -/* + 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; @@ -44,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/websocket/SocketServer.java b/src/main/java/dev/dfonline/codeclient/websocket/SocketServer.java index 1cad91c0..56d452e5 100644 --- a/src/main/java/dev/dfonline/codeclient/websocket/SocketServer.java +++ b/src/main/java/dev/dfonline/codeclient/websocket/SocketServer.java @@ -11,7 +11,7 @@ import java.net.InetSocketAddress; public class SocketServer extends WebSocketServer { - private SocketHandler handler; + private final SocketHandler handler; public SocketServer(InetSocketAddress address, SocketHandler socketHandler) { super(address); diff --git a/src/main/resources/assets/codeclient/lang/en_us.json b/src/main/resources/assets/codeclient/lang/en_us.json index 356b3473..4b3bcc06 100644 --- a/src/main/resources/assets/codeclient/lang/en_us.json +++ b/src/main/resources/assets/codeclient/lang/en_us.json @@ -319,5 +319,7 @@ "codeclient.command.itemdata.copy.unformatted": "Unformatted", "codeclient.command.itemdata.copy.dfgive": "/dfgive", "codeclient.command.calc.success": "%s = %s", - "codeclient.command.calc.failure": "%s failed to parse" + "codeclient.command.calc.failure": "%s failed to parse", + "codeclient.action.clearqueue.success": "Command queue cleared.", + "codeclient.action.clearqueue.empty": "Command queue was empty!" } \ No newline at end of file diff --git a/src/main/resources/codeclient.accesswidener b/src/main/resources/codeclient.accesswidener index f2a21754..1ebb9894 100644 --- a/src/main/resources/codeclient.accesswidener +++ b/src/main/resources/codeclient.accesswidener @@ -1,8 +1,8 @@ accessWidener v2 named -accessible method net/minecraft/client/gui/screen/ingame/HandeledScreen drawSlotHighlightFront(Lnet/minecraft/client/guiContext;)V private -accessible method net/minecraft/client/gui/screen/ingame/HandeledScreen drawSlotHighlightBack(Lnet/minecraft/client/guiContext;)V private +#accessible method net/minecraft/client/gui/screen/ingame/HandledScreen drawSlotHighlightFront (Lnet/minecraft/client/gui/DrawContext;)V +#accessible method net/minecraft/client/gui/screen/ingame/HandledScreen drawSlotHighlightBack (Lnet/minecraft/client/gui/DrawContext;)V + # class # method -# field - +# field \ No newline at end of file diff --git a/src/main/resources/resourcepacks/dark_mode/pack.mcmeta b/src/main/resources/resourcepacks/dark_mode/pack.mcmeta index a7914773..046a2218 100644 --- a/src/main/resources/resourcepacks/dark_mode/pack.mcmeta +++ b/src/main/resources/resourcepacks/dark_mode/pack.mcmeta @@ -1,9 +1,9 @@ { "pack": { - "pack_format": 22, + "pack_format": 57, "supported_formats": { "min_inclusive": 22, - "max_inclusive": 34 + "max_inclusive": 57 }, "description": "Darkens the UI of CodeClient (use with DefaultDarkMode)\n" }