Skip to content

Commit e286113

Browse files
authored
Update to 1.21.3
2 parents 486447f + 520127a commit e286113

99 files changed

Lines changed: 1537 additions & 702 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
A DiamondFire utility client for advanced coding.
1212

13-
A Fabric 1.20 mod for coding more efficiently with utility features including but not limited to:
13+
A Fabric 1.21.3 mod for coding more efficiently with utility features including but not limited to:
1414
* Automatically placing templates in inventory
1515
* Moving faster in codespace
1616
* A palette with all the actions
@@ -19,13 +19,14 @@ A Fabric 1.20 mod for coding more efficiently with utility features including bu
1919
1. Download the latest release of the mod from **[here](https://github.com/DFOnline/CodeClient/releases/latest)**.
2020
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)
2121
3. Move the downloaded mod files into the mods folder located at .minecraft/mods.
22-
4. Launch the game and try it out on [DiamondFire](mcdiamondfire.com).
22+
4. Launch the game and try it out on [DiamondFire](https://mcdiamondfire.com/).
2323

2424
## Useful Info
2525
There's a [discord](https://discord.gg/NqU6XnyVPA) for CodeClient, and a helpful [wiki](https://github.com/DFOnline/CodeClient/wiki)
2626

2727
## Versions
28-
* [1.20 (latest)](https://github.com/DFOnline/CodeClient/releases/latest)
28+
29+
* [1.21 (latest)](https://github.com/DFOnline/CodeClient/releases/latest)
2930

3031
## Contributing
3132

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

3738
<a href="https://github.com/DFOnline/CodeClient/graphs/contributors">
38-
<img src="https://contrib.rocks/image?repo=DFOnline/CodeClient" />
39+
<img src="https://contrib.rocks/image?repo=DFOnline/CodeClient" alt="CodeClient Contributors" />
3940
</a>
4041

4142
## License

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
17-
- name: Set up JDK 17
17+
- name: Set up JDK 21
1818
uses: actions/setup-java@v3
1919
with:
20-
java-version: 17
21-
distribution: "temurin"
20+
java-version: 21
21+
distribution: "temurin"
2222
- name: Build with Gradle
2323
run: ./gradlew build '-Pversion=${{ github.run_number }}'
2424
- name: Upload Artifact

build.gradle

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.1-SNAPSHOT'
2+
id 'fabric-loom' version '1.8-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -24,22 +24,23 @@ repositories {
2424
}
2525

2626
dependencies {
27-
// To change the versions see the gradle.properties file
27+
// To change the versions see the gradle.properties file.
2828
minecraft "com.mojang:minecraft:${project.minecraft_version}"
2929
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
3030
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
31-
// MixinExtras. Fabric Loader 0.15.0 and above should bundle it, but I don't have access to it for some reason.
32-
implementation annotationProcessor(include("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}"))
3331

34-
// Fabric API. This is technically optional, but you probably want it anyway.
32+
// Fabric API.
3533
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
36-
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}"
34+
// YetAnotherConfigLib.
35+
modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}"
36+
// ModMenu.
3737
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
3838

39-
// adventure api for minimessage parsing (see ExpressionHighlighter)
40-
// implementation "net.kyori:adventure-api:4.16.0"
41-
modImplementation include("net.kyori:adventure-platform-fabric:5.12.0")
39+
// Adventure for MiniMessage parsing.
40+
implementation("net.kyori:adventure-api:${project.adventure_api_version}")
41+
modImplementation include("net.kyori:adventure-platform-fabric:${project.adventure_fabric_version}")
4242

43+
// WebSocket for CodeClient API.
4344
implementation include("org.java-websocket:Java-WebSocket:1.5.3")
4445
}
4546

@@ -52,7 +53,7 @@ processResources {
5253
}
5354
}
5455

55-
def targetJavaVersion = 17
56+
def targetJavaVersion = 21
5657
tasks.withType(JavaCompile).configureEach {
5758
// ensure that the encoding is set to UTF-8, no matter what the system default is
5859
// this fixes some edge cases with special characters not displaying correctly
@@ -76,6 +77,10 @@ java {
7677
// withSourcesJar()
7778
}
7879

80+
loom {
81+
accessWidenerPath = file("src/main/resources/codeclient.accesswidener")
82+
}
83+
7984
jar {
8085
from("LICENSE") {
8186
rename { "${it}_${project.archivesBaseName}" }

gradle.properties

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
## Check these on https://fabricmc.net/develop/
6-
minecraft_version=1.20.4
7-
yarn_mappings=1.20.4+build.3
8-
loader_version=0.15.3
9-
mixin_extras_version=0.4.1
6+
minecraft_version=1.21.3
7+
yarn_mappings=1.21.3+build.2
8+
loader_version=0.16.9
109

1110
# Mod Properties
12-
mod_version=1.7.2
11+
mod_version=2.0.0-beta.2
1312
maven_group=dev.dfonline
1413
archives_base_name=CodeClient
1514

1615
# Dependencies
17-
fabric_version=0.92.1+1.20.4
18-
modmenu_version=9.0.0-pre.1
19-
yacl_version=3.3.1+1.20.4
16+
fabric_version=0.108.0+1.21.3
17+
modmenu_version=12.0.0-beta.1
18+
yacl_version=3.6.1+1.21.2-fabric
19+
adventure_api_version=4.17.0
20+
adventure_fabric_version=6.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/dev/dfonline/codeclient/CodeClient.java

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
import dev.dfonline.codeclient.action.None;
66
import dev.dfonline.codeclient.action.impl.DevForBuild;
77
import dev.dfonline.codeclient.command.CommandManager;
8+
import dev.dfonline.codeclient.command.CommandSender;
89
import dev.dfonline.codeclient.config.Config;
910
import dev.dfonline.codeclient.config.KeyBinds;
11+
import dev.dfonline.codeclient.data.DFItem;
12+
import dev.dfonline.codeclient.data.ItemData;
13+
import dev.dfonline.codeclient.data.PublicBukkitValues;
14+
import dev.dfonline.codeclient.data.value.DataValue;
15+
import dev.dfonline.codeclient.data.value.NumberDataValue;
16+
import dev.dfonline.codeclient.data.value.StringDataValue;
1017
import dev.dfonline.codeclient.dev.*;
1118
import dev.dfonline.codeclient.dev.debug.Debug;
1219
import dev.dfonline.codeclient.dev.highlighter.ExpressionHighlighter;
@@ -42,17 +49,13 @@
4249
import net.minecraft.client.render.VertexConsumerProvider;
4350
import net.minecraft.client.util.math.MatrixStack;
4451
import net.minecraft.item.ItemStack;
45-
import net.minecraft.nbt.AbstractNbtNumber;
46-
import net.minecraft.nbt.NbtCompound;
47-
import net.minecraft.nbt.NbtElement;
48-
import net.minecraft.nbt.NbtString;
4952
import net.minecraft.network.listener.PacketListener;
5053
import net.minecraft.network.packet.Packet;
5154
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
55+
import net.minecraft.network.packet.s2c.play.BundleS2CPacket;
5256
import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket;
5357
import net.minecraft.screen.slot.Slot;
5458
import net.minecraft.screen.slot.SlotActionType;
55-
import net.minecraft.text.MutableText;
5659
import net.minecraft.text.Text;
5760
import net.minecraft.util.Formatting;
5861
import net.minecraft.util.Identifier;
@@ -82,7 +85,7 @@ public class CodeClient implements ClientModInitializer {
8285
public static Action confirmingAction = null;
8386
public static Location lastLocation = null;
8487
public static Location location = null;
85-
/***
88+
/**
8689
* Used to open a screen on the next tick.
8790
*/
8891
public static Screen screenToOpen = null;
@@ -112,7 +115,9 @@ public void onInitializeClient() {
112115
BlockRenderLayerMap.INSTANCE.putBlock(Blocks.STRUCTURE_VOID, RenderLayer.getTranslucent());
113116
BlockRenderLayerMap.INSTANCE.putBlock(Blocks.LIGHT, RenderLayer.getTranslucent());
114117

115-
ClientLifecycleEvents.CLIENT_STOPPING.register(new Identifier(MOD_ID, "close"), client -> API.stop());
118+
ClientLifecycleEvents.CLIENT_STOPPING.register(Identifier.of(MOD_ID, "close"), client -> API.stop());
119+
120+
ClientTickEvents.END_CLIENT_TICK.register(client -> CommandSender.tick());
116121

117122
if (Config.getConfig().CodeClientAPI) {
118123
try {
@@ -129,29 +134,33 @@ public void onInitializeClient() {
129134

130135
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> CommandManager.init(dispatcher, registryAccess));
131136

132-
ItemTooltipCallback.EVENT.register((stack, context, lines) -> {
137+
ItemTooltipCallback.EVENT.register((stack, context, type, lines) -> {
133138
if (isPreviewingItemTags) {
134-
if (!stack.hasNbt()) return;
135-
NbtCompound nbt = stack.getNbt();
136-
if (nbt == null) return;
137-
if (!nbt.contains("PublicBukkitValues")) return;
138-
NbtCompound publicBukkit = nbt.getCompound("PublicBukkitValues");
139-
for (var key : publicBukkit.getKeys()) {
140-
if (key.startsWith("hypercube:")) {
141-
NbtElement element = publicBukkit.get(key);
142-
143-
// Any type = yellow, number = red, string = aqua.
144-
MutableText value = Text.literal(publicBukkit.get(key).toString()).formatted(Formatting.GREEN);
145-
if (element instanceof NbtString) value.formatted(Formatting.AQUA);
146-
if (element instanceof AbstractNbtNumber) value.formatted(Formatting.RED);
147-
148-
lines.add(
149-
Text.literal(key.replace("hypercube:", ""))
150-
.withColor(0xAAFF55)
151-
.append(Text.literal(" = ").formatted(Formatting.DARK_GRAY))
152-
.append(value)
153-
);
139+
DFItem item = DFItem.of(stack);
140+
ItemData itemData = item.getItemData();
141+
if (itemData == null) return;
142+
PublicBukkitValues publicBukkit = itemData.getPublicBukkitValues();
143+
if (publicBukkit == null) return;
144+
for (var key : publicBukkit.getHypercubeKeys()) {
145+
DataValue element = publicBukkit.getHypercubeValue(key);
146+
147+
// Any type = yellow, number = red, string = aqua.
148+
Formatting formatting = Formatting.GREEN;
149+
String stringElement = element.getValue() == null ? "?" : element.getValue().toString();
150+
if (element instanceof StringDataValue) {
151+
formatting = Formatting.AQUA;
154152
}
153+
if (element instanceof NumberDataValue numberDataValue) {
154+
formatting = Formatting.RED;
155+
stringElement = String.valueOf(numberDataValue.getValue());
156+
}
157+
158+
lines.add(
159+
Text.literal(key)
160+
.withColor(0xAAFF55)
161+
.append(Text.literal(" = ").formatted(Formatting.DARK_GRAY))
162+
.append(Text.literal(stringElement).formatted(formatting))
163+
);
155164
}
156165
}
157166
});
@@ -189,6 +198,7 @@ private static void loadFeatures() {
189198
feat(new CPUDisplay());
190199
feat(new MessageHiding());
191200
feat(new ExpressionHighlighter());
201+
feat(new PreviewSoundChest());
192202
}
193203

194204
/**
@@ -205,6 +215,16 @@ private static Stream<ChestFeature> chestFeatures() {
205215
return features().map(Feature::getChest).filter(Optional::isPresent).map(Optional::get);
206216
}
207217

218+
/**
219+
* Get an identifier using the mod id as the namespace.
220+
*
221+
* @param path The path to the resource.
222+
* @return Identifier under the mod id's namespace and the provided path as the path.
223+
*/
224+
public static Identifier getId(String path) {
225+
return Identifier.of(MOD_ID, path);
226+
}
227+
208228
public static void isCodeChest() {
209229
isCodeChest = true;
210230
}
@@ -216,6 +236,12 @@ public static <T extends Feature> Optional<T> getFeature(Class<T> clazz) {
216236
}
217237

218238
public static <T extends PacketListener> boolean handlePacket(Packet<T> packet) {
239+
if (packet instanceof BundleS2CPacket bundle) {
240+
bundle.getPackets().forEach(CodeClient::handlePacket);
241+
return false;
242+
}
243+
244+
219245
if (currentAction.onReceivePacket(packet)) return true;
220246
for (var feature : features().toList()) {
221247
if (feature.onReceivePacket(packet)) return true;
@@ -263,6 +289,8 @@ public static void onTick() {
263289
features().forEach(Feature::tick);
264290
KeyBinds.tick();
265291

292+
// System.out.println(location.name());
293+
266294
if (!(location instanceof Dev) || !(MC.currentScreen instanceof HandledScreen<?>)) {
267295
isCodeChest = false;
268296
features().forEach(Feature::closeChest);
@@ -455,7 +483,7 @@ private boolean registerResourcePack(String id, Text name) throws NullPointerExc
455483
private boolean registerResourcePack(String id, Text name, ResourcePackActivationType type) throws NullPointerException {
456484
var prefix = String.format("[%s] ", MOD_NAME);
457485
return ResourceManagerHelper.registerBuiltinResourcePack(
458-
new Identifier(CodeClient.MOD_ID, id),
486+
getId(id),
459487
getModContainer(),
460488
Text.literal(prefix).formatted(Formatting.GRAY).append(name),
461489
type

src/main/java/dev/dfonline/codeclient/Event.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package dev.dfonline.codeclient;
22

3+
import dev.dfonline.codeclient.command.CommandSender;
34
import dev.dfonline.codeclient.config.Config;
45
import dev.dfonline.codeclient.location.*;
56
import net.minecraft.network.listener.PacketListener;
67
import net.minecraft.network.packet.Packet;
8+
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
79
import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
810
import net.minecraft.network.packet.s2c.play.*;
911
import net.minecraft.util.math.Vec3d;
@@ -23,11 +25,11 @@ public static <T extends PacketListener> void handlePacket(Packet<T> packet) {
2325
if (clear.shouldReset()) step = Sequence.WAIT_FOR_POS;
2426
}
2527
if (packet instanceof PlayerPositionLookS2CPacket pos) {
26-
tp = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
28+
tp = new Vec3d(pos.change().position().x, pos.change().position().y, pos.change().position().z);
2729
if (step == Sequence.WAIT_FOR_POS) step = Sequence.WAIT_FOR_MESSAGE;
2830
}
2931
if (packet instanceof OverlayMessageS2CPacket overlay) {
30-
if (step == Sequence.WAIT_FOR_MESSAGE && overlay.getMessage().getString().startsWith("DiamondFire - ")) {
32+
if (step == Sequence.WAIT_FOR_MESSAGE && overlay.text().getString().startsWith("DiamondFire - ")) {
3133
updateLocation(new Spawn());
3234
}
3335
}
@@ -52,10 +54,14 @@ public static <T extends PacketListener> void handlePacket(Packet<T> packet) {
5254

5355
public static <T extends PacketListener> void onSendPacket(Packet<T> packet) {
5456
if (packet instanceof CommandExecutionC2SPacket command) {
57+
CommandSender.registerCommandSend();
5558
if (List.of("play", "build", "code", "dev").contains(command.command().replaceFirst("mode ", ""))) {
5659
switchingMode = true;
5760
}
5861
}
62+
if (packet instanceof ChatMessageC2SPacket) {
63+
CommandSender.registerCommandSend();
64+
}
5965
}
6066

6167
public static void updateLocation(Location location) {

src/main/java/dev/dfonline/codeclient/ItemSelector.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,4 @@ protected void appendClickableNarrations(NarrationMessageBuilder builder) {
131131
private record Search(ItemStack item, int x, int y) {
132132
}
133133

134-
;
135134
}

src/main/java/dev/dfonline/codeclient/MoveToLocation.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ public void setPos(double x, double y, double z) {
4040
if (CodeClient.MC.getNetworkHandler() == null) return;
4141
if (new Vec3d(x, y, x).distanceTo(player.getPos()) > 10) {
4242
// I've always done it like this, problems?
43-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
44-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
45-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
46-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
47-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
48-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
49-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
50-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
51-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
52-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false));
43+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
44+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
45+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
46+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
47+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
48+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
49+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
50+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
51+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
52+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, true));
5353
}
5454
this.player.setPos(x, y, z);
55-
this.player.teleport(x, y, z);
56-
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false));
55+
this.player.teleport(x, y, z, false);
56+
CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false, true));
5757
}
5858

5959
/**

0 commit comments

Comments
 (0)