mirror of
https://github.com/GeyserMC/Rainbow.git
synced 2025-12-19 14:59:16 +00:00
Log problems in datagen
This commit is contained in:
@@ -3,6 +3,7 @@ package org.geysermc.rainbow.client;
|
|||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.components.SplashRenderer;
|
import net.minecraft.client.gui.components.SplashRenderer;
|
||||||
|
import net.minecraft.util.ProblemReporter;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.util.StringUtil;
|
import net.minecraft.util.StringUtil;
|
||||||
import org.geysermc.rainbow.CodecUtil;
|
import org.geysermc.rainbow.CodecUtil;
|
||||||
@@ -81,7 +82,7 @@ public final class PackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String createPackSummary(BedrockPack pack) {
|
private static String createPackSummary(BedrockPack pack) {
|
||||||
String problems = pack.getReporter().getTreeReport();
|
String problems = ((ProblemReporter.Collector) pack.getReporter()).getTreeReport();
|
||||||
if (StringUtil.isBlank(problems)) {
|
if (StringUtil.isBlank(problems)) {
|
||||||
problems = "Well that's odd... there's nothing here!";
|
problems = "Well that's odd... there's nothing here!";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,18 @@ import net.minecraft.data.PackOutput;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
import net.minecraft.util.ProblemReporter;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.equipment.EquipmentAsset;
|
import net.minecraft.world.item.equipment.EquipmentAsset;
|
||||||
|
import org.geysermc.rainbow.Rainbow;
|
||||||
import org.geysermc.rainbow.mapping.AssetResolver;
|
import org.geysermc.rainbow.mapping.AssetResolver;
|
||||||
import org.geysermc.rainbow.mapping.PackSerializer;
|
import org.geysermc.rainbow.mapping.PackSerializer;
|
||||||
import org.geysermc.rainbow.pack.BedrockPack;
|
import org.geysermc.rainbow.pack.BedrockPack;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -39,6 +43,8 @@ import java.util.Optional;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public abstract class RainbowModelProvider extends FabricModelProvider {
|
public abstract class RainbowModelProvider extends FabricModelProvider {
|
||||||
|
private static final Logger PROBLEM_LOGGER = LoggerFactory.getLogger(Rainbow.MOD_ID);
|
||||||
|
|
||||||
private final CompletableFuture<HolderLookup.Provider> registries;
|
private final CompletableFuture<HolderLookup.Provider> registries;
|
||||||
private final Map<ResourceKey<EquipmentAsset>, EquipmentClientInfo> equipmentInfos;
|
private final Map<ResourceKey<EquipmentAsset>, EquipmentClientInfo> equipmentInfos;
|
||||||
private final Path outputRoot;
|
private final Path outputRoot;
|
||||||
@@ -84,7 +90,8 @@ public abstract class RainbowModelProvider extends FabricModelProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected BedrockPack.Builder createBedrockPack(Path outputRoot, PackSerializer serializer, AssetResolver resolver) {
|
protected BedrockPack.Builder createBedrockPack(Path outputRoot, PackSerializer serializer, AssetResolver resolver) {
|
||||||
return BedrockPack.builder("rainbow", outputRoot.resolve("geyser_mappings.json"), outputRoot.resolve("pack"), serializer, resolver);
|
return BedrockPack.builder("rainbow", outputRoot.resolve("geyser_mappings.json"), outputRoot.resolve("pack"), serializer, resolver)
|
||||||
|
.withReporter(path -> new ProblemReporter.ScopedCollector(path, PROBLEM_LOGGER));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Item getVanillaItem(Item modded);
|
protected abstract Item getVanillaItem(Item modded);
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public class BedrockPack {
|
|||||||
private final IntSet customModelDataMapped = new IntOpenHashSet();
|
private final IntSet customModelDataMapped = new IntOpenHashSet();
|
||||||
|
|
||||||
private final PackContext context;
|
private final PackContext context;
|
||||||
private final ProblemReporter.Collector reporter;
|
private final ProblemReporter reporter;
|
||||||
|
|
||||||
public BedrockPack(String name, PackManifest manifest, PackPaths paths, PackSerializer serializer, AssetResolver assetResolver,
|
public BedrockPack(String name, PackManifest manifest, PackPaths paths, PackSerializer serializer, AssetResolver assetResolver,
|
||||||
Optional<GeometryRenderer> geometryRenderer, ProblemReporter.Collector reporter,
|
Optional<GeometryRenderer> geometryRenderer, ProblemReporter reporter,
|
||||||
boolean reportSuccesses) {
|
boolean reportSuccesses) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.manifest = manifest;
|
this.manifest = manifest;
|
||||||
@@ -163,6 +163,12 @@ public class BedrockPack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reporter instanceof AutoCloseable closeable) {
|
||||||
|
try {
|
||||||
|
closeable.close();
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
|
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +184,7 @@ public class BedrockPack {
|
|||||||
return itemTextures.build().size();
|
return itemTextures.build().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProblemReporter.Collector getReporter() {
|
public ProblemReporter getReporter() {
|
||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,14 +213,14 @@ public class BedrockPack {
|
|||||||
private UnaryOperator<Path> itemAtlasPath = resolve(ITEM_ATLAS_FILE);
|
private UnaryOperator<Path> itemAtlasPath = resolve(ITEM_ATLAS_FILE);
|
||||||
private Path packZipFile = null;
|
private Path packZipFile = null;
|
||||||
private GeometryRenderer geometryRenderer = null;
|
private GeometryRenderer geometryRenderer = null;
|
||||||
private ProblemReporter.Collector reporter;
|
private Function<ProblemReporter.PathElement, ProblemReporter> reporter;
|
||||||
private boolean reportSuccesses = false;
|
private boolean reportSuccesses = false;
|
||||||
|
|
||||||
public Builder(String name, Path mappingsPath, Path packRootPath, PackSerializer packSerializer, AssetResolver assetResolver) {
|
public Builder(String name, Path mappingsPath, Path packRootPath, PackSerializer packSerializer, AssetResolver assetResolver) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mappingsPath = mappingsPath;
|
this.mappingsPath = mappingsPath;
|
||||||
this.packRootPath = packRootPath;
|
this.packRootPath = packRootPath;
|
||||||
this.reporter = new ProblemReporter.Collector(() -> "Bedrock pack " + name + " ");
|
this.reporter = ProblemReporter.Collector::new;
|
||||||
this.packSerializer = packSerializer;
|
this.packSerializer = packSerializer;
|
||||||
this.assetResolver = assetResolver;
|
this.assetResolver = assetResolver;
|
||||||
manifest = defaultManifest(name);
|
manifest = defaultManifest(name);
|
||||||
@@ -280,7 +286,7 @@ public class BedrockPack {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder withReporter(ProblemReporter.Collector reporter) {
|
public Builder withReporter(Function<ProblemReporter.PathElement, ProblemReporter> reporter) {
|
||||||
this.reporter = reporter;
|
this.reporter = reporter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -294,7 +300,7 @@ public class BedrockPack {
|
|||||||
PackPaths paths = new PackPaths(mappingsPath, packRootPath, attachablesPath.apply(packRootPath),
|
PackPaths paths = new PackPaths(mappingsPath, packRootPath, attachablesPath.apply(packRootPath),
|
||||||
geometryPath.apply(packRootPath), animationPath.apply(packRootPath), manifestPath.apply(packRootPath),
|
geometryPath.apply(packRootPath), animationPath.apply(packRootPath), manifestPath.apply(packRootPath),
|
||||||
itemAtlasPath.apply(packRootPath), Optional.ofNullable(packZipFile));
|
itemAtlasPath.apply(packRootPath), Optional.ofNullable(packZipFile));
|
||||||
return new BedrockPack(name, manifest, paths, packSerializer, assetResolver, Optional.ofNullable(geometryRenderer), reporter, reportSuccesses);
|
return new BedrockPack(name, manifest, paths, packSerializer, assetResolver, Optional.ofNullable(geometryRenderer), reporter.apply(() -> "Bedrock pack " + name + " "), reportSuccesses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UnaryOperator<Path> resolve(Path child) {
|
private static UnaryOperator<Path> resolve(Path child) {
|
||||||
|
|||||||
Reference in New Issue
Block a user