Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ dependencies {

compileOnly 'com.demonwav.mcdev:annotations:2.0.0'

// modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}") {
// exclude group: 'net.fabricmc', module: 'fabric-loader'
// }
// productionRuntimeMods("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}") {
// exclude group: 'net.fabricmc', module: 'fabric-loader'
// }
modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}") {
exclude group: 'net.fabricmc', module: 'fabric-loader'
}
productionRuntimeMods("me.djtheredstoner:DevAuth-fabric:${project.devauth_version}") {
exclude group: 'net.fabricmc', module: 'fabric-loader'
}

include api("net.fabricmc:mapping-io:${project.mapping_io_version}")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ org.gradle.jvmargs=-Xmx2G
seedfinding_seed_version=1.171.2
latticg_version=1.07
mapping_io_version=0.7.1
devauth_version=1.2.1
devauth_version=1.2.2
checkstyle_version=11.0.0

jazzer_junit_version=0.24.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.ChunkPos;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -63,7 +64,7 @@ public static void disable() {

private static final Set<Identifier> packets = new HashSet<>();

private static PacketCallback callback;
private static @Nullable PacketCallback callback;

public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(literal("clisten")
Expand Down Expand Up @@ -171,7 +172,7 @@ private static void checkEnabled() throws CommandSyntaxException {
}
}

private static Component serialize(Object object, Set<Object> seen, int depth) {
private static Component serialize(@Nullable Object object, Set<@Nullable Object> seen, int depth) {
try {
if (depth <= Configs.maximumPacketFieldDepth && seen.add(object)) {
return serializeInner(object, seen, depth);
Expand All @@ -182,7 +183,7 @@ private static Component serialize(Object object, Set<Object> seen, int depth) {
}
}

private static Component serializeInner(Object object, Set<Object> seen, int depth) {
private static Component serializeInner(@Nullable Object object, Set<@Nullable Object> seen, int depth) {
return switch (object) {
case null -> Component.literal("null");
case Component component -> component;
Expand Down Expand Up @@ -276,6 +277,7 @@ public static void onPacket(Packet<?> packet, PacketFlow side) {
if (!packets.contains(packet.type().id())) {
return;
}
assert callback != null;
callback.apply(packet, side);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.fabricmc.mappingio.format.MappingFormat;
import net.fabricmc.mappingio.tree.MappingTree;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
import net.minecraft.DetectedVersion;
import net.minecraft.Optionull;
import net.minecraft.SharedConstants;
import net.minecraft.util.Util;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -59,80 +59,82 @@ public static void load() {
}

private static final CompletableFuture<MemoryMappingTree> mojmapOfficial = Util.make(() -> {
String version = DetectedVersion.BUILT_IN.name();
String version = SharedConstants.getCurrentVersion().id();
try (BufferedReader reader = Files.newBufferedReader(MAPPINGS_DIR.resolve(version + ".txt"))) {
MemoryMappingTree tree = new MemoryMappingTree();
MappingReader.read(reader, MappingFormat.PROGUARD_FILE, tree);
return CompletableFuture.completedFuture(tree);
} catch (IOException e) {
try (HttpClient httpClient = HttpClient.newHttpClient()) {
HttpRequest versionsRequest = HttpRequest.newBuilder()
.uri(URI.create("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(versionsRequest, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenCompose(versionsBody -> {
JsonObject versionsJson = JsonParser.parseString(versionsBody).getAsJsonObject();
String versionUrl = versionsJson.getAsJsonArray("versions").asList().stream()
.map(JsonElement::getAsJsonObject)
.filter(v -> v.get("id").getAsString().equals(version))
.map(v -> v.get("url").getAsString())
.findAny().orElseThrow();
//noinspection resource async requests do not lend themselves for auto-closure
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest versionsRequest = HttpRequest.newBuilder()
.uri(URI.create("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(versionsRequest, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenCompose(versionsBody -> {
JsonObject versionsJson = JsonParser.parseString(versionsBody).getAsJsonObject();
String versionUrl = versionsJson.getAsJsonArray("versions").asList().stream()
.map(JsonElement::getAsJsonObject)
.filter(v -> v.get("id").getAsString().equals(version))
.map(v -> v.get("url").getAsString())
.findAny().orElseThrow();

HttpRequest versionRequest = HttpRequest.newBuilder()
.uri(URI.create(versionUrl))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(versionRequest, HttpResponse.BodyHandlers.ofString());
})
.whenComplete((result, exception) -> {
if (exception != null) {
ListenCommand.disable();
}
})
.thenApply(HttpResponse::body)
.thenCompose(versionBody -> {
JsonObject versionJson = JsonParser.parseString(versionBody).getAsJsonObject();
String mappingsUrl = versionJson
.getAsJsonObject("downloads")
.getAsJsonObject("client_mappings")
.get("url").getAsString();
HttpRequest versionRequest = HttpRequest.newBuilder()
.uri(URI.create(versionUrl))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(versionRequest, HttpResponse.BodyHandlers.ofString());
})
.whenComplete((result, exception) -> {
if (exception != null) {
LOGGER.error("An error occurred while fetching mappings file", exception);
ListenCommand.disable();
}
})
.thenApply(HttpResponse::body)
.thenCompose(versionBody -> {
JsonObject versionJson = JsonParser.parseString(versionBody).getAsJsonObject();
String mappingsUrl = versionJson
.getAsJsonObject("downloads")
.getAsJsonObject("client_mappings")
.get("url").getAsString();

HttpRequest mappingsRequest = HttpRequest.newBuilder()
.uri(URI.create(mappingsUrl))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(mappingsRequest, HttpResponse.BodyHandlers.ofString());
})
.thenApply(HttpResponse::body)
.thenApply(body -> {
try (StringReader reader = new StringReader(body)) {
MemoryMappingTree tree = new MemoryMappingTree();
MappingReader.read(reader, MappingFormat.PROGUARD_FILE, tree);
return tree;
HttpRequest mappingsRequest = HttpRequest.newBuilder()
.uri(URI.create(mappingsUrl))
.GET()
.timeout(Duration.ofSeconds(5))
.build();
return httpClient.sendAsync(mappingsRequest, HttpResponse.BodyHandlers.ofString());
})
.thenApply(HttpResponse::body)
.thenApply(body -> {
try (StringReader reader = new StringReader(body)) {
MemoryMappingTree tree = new MemoryMappingTree();
MappingReader.read(reader, MappingFormat.PROGUARD_FILE, tree);
return tree;
} catch (IOException ex) {
LOGGER.error("Could not read ProGuard mappings file", ex);
ListenCommand.disable();
throw new UncheckedIOException(ex);
} finally {
try (BufferedWriter writer = Files.newBufferedWriter(MAPPINGS_DIR.resolve(version + ".txt"), StandardOpenOption.CREATE)) {
writer.write(body);
} catch (IOException ex) {
LOGGER.error("Could not read ProGuard mappings file", ex);
ListenCommand.disable();
throw new UncheckedIOException(ex);
} finally {
try (BufferedWriter writer = Files.newBufferedWriter(MAPPINGS_DIR.resolve(version + ".txt"), StandardOpenOption.CREATE)) {
writer.write(body);
} catch (IOException ex) {
LOGGER.error("Could not write ProGuard mappings file", ex);
}
LOGGER.error("Could not write ProGuard mappings file", ex);
}
});
}
}
});

}
});
private static final int SRC_OFFICIAL = 0;
private static final int DEST_OFFICIAL = 0;

private static final MemoryMappingTree officialIntermediaryNamed = Util.make(() -> {
private static final @Nullable MemoryMappingTree officialIntermediaryNamed = Util.make(() -> {
try (InputStream stream = FabricLoader.class.getClassLoader().getResourceAsStream("mappings/mappings.tiny")) {
if (stream == null) {
throw new IOException("Could not find mappings.tiny");
Expand Down