Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0aa5d78
feat: update to 1.21
RedVortexDev Nov 7, 2024
4ac6caa
docs: document DFItem, ItemData, etc.
RedVortexDev Nov 7, 2024
6459ef1
fix: minor fixes when setting custom data when it doesn't exist
RedVortexDev Nov 7, 2024
7f3663c
feat: remove item ID from count_above_max in /dfgive due to customiza…
RedVortexDev Nov 7, 2024
7b1b1ed
fix: italic text in a few places
RedVortexDev Nov 7, 2024
b27e604
docs: update readme
RedVortexDev Nov 7, 2024
bc72eb0
fix: crash when getting reference book tooltip
RedVortexDev Nov 7, 2024
7bbd7f7
feat: start 1.21.3 migration
RedVortexDev Nov 14, 2024
2274d76
fix adventure features
sylviameows Nov 16, 2024
7b6e823
fix action viewer
sylviameows Nov 17, 2024
58ebf22
re-enabled expression highlighter
sylviameows Nov 17, 2024
6cdd4b9
fix custom chest menu
sylviameows Nov 18, 2024
3f90b14
fix space and newline tags in chat bar
sylviameows Nov 18, 2024
99cb925
fix chest highlighting blinking
sylviameows Nov 18, 2024
ee1bf85
fix code palette gui
sylviameows Nov 18, 2024
97613bc
switch to plot tp command for phaser
sylviameows Nov 18, 2024
ebe6b3c
remove unused imports
sylviameows Nov 18, 2024
4af078c
fix destroy item mode not saving
sylviameows Nov 19, 2024
d499318
add rate limiting
sylviameows Nov 19, 2024
73f6c0b
add clear queue command
sylviameows Nov 19, 2024
c29803e
enable build phaser in build mode
sylviameows Nov 19, 2024
e0ba265
fix highlighter edgecase
sylviameows Nov 19, 2024
0cfb01f
update dark mode pack format
sylviameows Nov 19, 2024
ca4079c
disable access widener
sylviameows Nov 19, 2024
74bf364
fix workflow syntax
sylviameows Nov 19, 2024
061861a
phaser keep velocity
sylviameows Nov 19, 2024
f8c15c1
dedupe ratelimiting increase
sylviameows Nov 19, 2024
9d890d6
remove debug log
sylviameows Nov 19, 2024
b239807
Merge pull request #121 from sylviameows/1.21
RedVortexDev Nov 19, 2024
72619da
chore: bump to 2.0.0-beta.2
RedVortexDev Nov 19, 2024
21da946
fix: attempt at recentvalues crash fix
RedVortexDev Nov 19, 2024
0386160
fix: non-string item tags don't show up in tag preview
RedVortexDev Nov 19, 2024
22dc3a8
feat: preview sounds in code chest keybind
RedVortexDev Nov 19, 2024
bf53e57
fix: crash with recentvalues 2: electric boogaloo
RedVortexDev Nov 20, 2024
0ab8b6e
fix: scope switcher not changing lore
RedVortexDev Nov 20, 2024
520127a
fix: switchers having a missing texture background
RedVortexDev Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -35,7 +36,7 @@ Feel free to help! [Open an issue](https://github.com/DFOnline/CodeClient/issues
Thanks to all the people who contribute.

<a href="https://github.com/DFOnline/CodeClient/graphs/contributors">
<img src="https://contrib.rocks/image?repo=DFOnline/CodeClient" />
<img src="https://contrib.rocks/image?repo=DFOnline/CodeClient" alt="CodeClient Contributors" />
</a>

## License
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 15 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -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")
}

Expand All @@ -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
Expand All @@ -76,6 +77,10 @@ java {
// withSourcesJar()
}

loom {
accessWidenerPath = file("src/main/resources/codeclient.accesswidener")
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
Expand Down
17 changes: 9 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
86 changes: 57 additions & 29 deletions src/main/java/dev/dfonline/codeclient/CodeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
);
}
}
});
Expand Down Expand Up @@ -189,6 +198,7 @@ private static void loadFeatures() {
feat(new CPUDisplay());
feat(new MessageHiding());
feat(new ExpressionHighlighter());
feat(new PreviewSoundChest());
}

/**
Expand All @@ -205,6 +215,16 @@ private static Stream<ChestFeature> 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;
}
Expand All @@ -216,6 +236,12 @@ public static <T extends Feature> Optional<T> getFeature(Class<T> clazz) {
}

public static <T extends PacketListener> boolean handlePacket(Packet<T> 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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/dev/dfonline/codeclient/Event.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,11 +25,11 @@ public static <T extends PacketListener> void handlePacket(Packet<T> 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());
}
}
Expand All @@ -52,10 +54,14 @@ public static <T extends PacketListener> void handlePacket(Packet<T> packet) {

public static <T extends PacketListener> void onSendPacket(Packet<T> 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) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/dfonline/codeclient/ItemSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
private record Search(ItemStack item, int x, int y) {
}

;
}
24 changes: 12 additions & 12 deletions src/main/java/dev/dfonline/codeclient/MoveToLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
Loading