Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/dev/dfonline/codeclient/CodeClient.java
  • Loading branch information
GeorgeRNG committed Mar 4, 2024
2 parents 033e7de + c859ac6 commit c8db6d7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
14 changes: 8 additions & 6 deletions src/main/java/dev/dfonline/codeclient/ChatType.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package dev.dfonline.codeclient;

import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

public enum ChatType {
SUCCESS("§a§l»", Formatting.WHITE),
FAIL("§4§l»", Formatting.RED),
INFO("§9§l»", Formatting.AQUA);
SUCCESS(Text.literal("»").formatted(Formatting.GREEN, Formatting.BOLD), Formatting.WHITE),
FAIL(Text.literal("»").formatted(Formatting.DARK_RED, Formatting.BOLD), Formatting.RED),
INFO(Text.literal("»").formatted(Formatting.BLUE, Formatting.BOLD), Formatting.AQUA);

private final String prefix;
private final MutableText prefix;
private final Formatting trailing;

ChatType(String prefix, Formatting trailing) {
ChatType(MutableText prefix, Formatting trailing) {
this.prefix = prefix;
this.trailing = trailing;
}

public String getString() {
public MutableText getText() {
return this.prefix;
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/dev/dfonline/codeclient/CodeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dev.dfonline.codeclient.action.Action;
import dev.dfonline.codeclient.action.None;
import dev.dfonline.codeclient.config.Config;
import dev.dfonline.codeclient.dev.BuildClip;
import dev.dfonline.codeclient.dev.BuildPhaser;
import dev.dfonline.codeclient.dev.Debug.Debug;
import dev.dfonline.codeclient.dev.LastPos;
import dev.dfonline.codeclient.dev.NoClip;
Expand Down Expand Up @@ -71,15 +71,15 @@ public class CodeClient implements ModInitializer {
public static boolean shouldReload = false;

/**
* For all recieving packet events and debugging.
* For all receiving packet events and debugging.
* @return If the packet should be cancelled and not acted on. True to ignore.
* @param <T> Server2Client
*/
public static <T extends PacketListener> boolean handlePacket(Packet<T> packet) {

if(currentAction.onReceivePacket(packet)) return true;
if(Debug.handlePacket(packet)) return true;
if(BuildClip.handlePacket(packet)) return true;
if(BuildPhaser.handlePacket(packet)) return true;
if(ChestPeeker.handlePacket(packet)) return true;
Event.handlePacket(packet);
LastPos.handlePacket(packet);
Expand Down Expand Up @@ -113,7 +113,7 @@ public static boolean noClipOn() {
*/
public static <T extends PacketListener> boolean onSendPacket(Packet<T> packet) {
if(CodeClient.currentAction.onSendPacket(packet)) return true;
if(BuildClip.onPacket(packet)) return true;
if(BuildPhaser.onPacket(packet)) return true;
Event.onSendPacket(packet);
String name = packet.getClass().getName().replace("net.minecraft.network.packet.c2s.play.","");
if(packet instanceof CommandExecutionC2SPacket commandExecutionC2SPacket) {
Expand All @@ -130,7 +130,7 @@ public static void onTick() {

currentAction.onTick();
Debug.tick();
BuildClip.tick();
BuildPhaser.tick();
ChestPeeker.tick();
RecentChestInsert.tick();

Expand Down Expand Up @@ -195,8 +195,7 @@ public void onInitialize() {
autoJoin = AutoJoin.GAME;
}

editBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.codeclient.actionpallete",
editBind = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.codepalette",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_Y,
"category.codeclient.dev"
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/dev/dfonline/codeclient/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import dev.dfonline.codeclient.action.None;
import dev.dfonline.codeclient.action.impl.*;
import dev.dfonline.codeclient.config.Config;
import dev.dfonline.codeclient.dev.BuildClip;
import dev.dfonline.codeclient.dev.LastPos;
import dev.dfonline.codeclient.dev.BuildPhaser;
import dev.dfonline.codeclient.hypercube.actiondump.ActionDump;
import dev.dfonline.codeclient.hypercube.template.Template;
import dev.dfonline.codeclient.location.*;
Expand Down Expand Up @@ -72,7 +71,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
dispatcher.register(literal("fixcc").executes(context -> {
CodeClient.currentAction = new None();
CodeClient.location = null;
BuildClip.disableClipping();
BuildPhaser.disableClipping();
SocketHandler.setConnection(null);
ActionDump.clear();
Config.clear();
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/dev/dfonline/codeclient/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,25 @@ public static String compileTemplate(String data) throws IOException {
}

public static void sendMessage(String message, ChatType type) {
sendMessage(Text.of(message), type);
sendMessage(Text.literal(message), type);
}
public static void sendMessage(String message) {
sendMessage(Text.of(message), ChatType.INFO);
sendMessage(Text.literal(message), ChatType.INFO);
}
public static void sendMessage(Text message) {
public static void sendMessage(MutableText message) {
sendMessage(message, ChatType.INFO);
}

public static void sendMessage(Text message, @Nullable ChatType type) {
public static void sendMessage(MutableText message, @Nullable ChatType type) {
ClientPlayerEntity player = CodeClient.MC.player;
if (player == null) return;
if (type == null) {
player.sendMessage(message, false);
} else {
player.sendMessage(Text.literal(type.getString() + " ").append(message).setStyle(Style.EMPTY.withColor(type.getTrailing())), false);
player.sendMessage(Text.empty()
.append(type.getText())
.append(Text.literal(" "))
.append(message.formatted(Formatting.RESET, type.getTrailing())), false);
if (type == ChatType.FAIL) {
player.playSound(SoundEvent.of(new Identifier("minecraft:block.note_block.didgeridoo")), SoundCategory.PLAYERS, 2, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/dfonline/codeclient/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public YetAnotherConfigLib getLibConfig() {
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Auto Focus Search"))
.description(OptionDescription.of(Text.literal("When opening the Code Palette (").append(Text.keybind("key.codeclient.actionpallete")).append(") automatically select the search bar."),Text.literal("This is disabled because it interferes with navigation binds.")))
.description(OptionDescription.of(Text.literal("When opening the Code Palette (").append(Text.keybind("key.codeclient.codepalette")).append(") automatically select the search bar."),Text.literal("This is disabled because it interferes with navigation binds.")))
.binding(
false,
() -> FocusSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtString;
import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
Expand All @@ -30,7 +27,7 @@
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;

public class BuildClip {
public class BuildPhaser {
private static boolean clipping = false;
public static boolean isClipping() {
return clipping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.dfonline.codeclient.mixin.entity.player;

import dev.dfonline.codeclient.dev.BuildClip;
import dev.dfonline.codeclient.dev.BuildPhaser;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -11,6 +11,6 @@
public class MAbstractClientPlayerEntity {
@Inject(method = "isSpectator", at = @At("HEAD"), cancellable = true)
public void isSpectator(CallbackInfoReturnable<Boolean> cir) {
if(BuildClip.isClipping()) cir.setReturnValue(true);
if(BuildPhaser.isClipping()) cir.setReturnValue(true);
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/codeclient/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"category.codeclient.dev": "CodeClient",

"key.codeclient.codepalette": "Code Palette",
"key.codeclient.phaser": "Phaser"
}

0 comments on commit c8db6d7

Please sign in to comment.