mirror of
https://github.com/GeyserMC/Rainbow.git
synced 2025-12-19 14:59:16 +00:00
Provide more info in pack report
This commit is contained in:
@@ -11,13 +11,14 @@ import java.util.List;
|
|||||||
public final class ItemSuggestionMapper {
|
public final class ItemSuggestionMapper {
|
||||||
private static final ItemSuggestionMapper INSTANCE = new ItemSuggestionMapper();
|
private static final ItemSuggestionMapper INSTANCE = new ItemSuggestionMapper();
|
||||||
|
|
||||||
private List<String> remainingCommands = new ArrayList<>();
|
private final List<String> remainingCommands = new ArrayList<>();
|
||||||
private boolean waitingOnItem = false;
|
private boolean waitingOnItem = false;
|
||||||
private boolean waitingOnClear = false;
|
private boolean waitingOnClear = false;
|
||||||
private int mapped = 0;
|
private int mapped = 0;
|
||||||
|
|
||||||
private ItemSuggestionMapper() {}
|
private ItemSuggestionMapper() {}
|
||||||
|
|
||||||
|
// TODO
|
||||||
public boolean start(List<String> commands) {
|
public boolean start(List<String> commands) {
|
||||||
if (remainingCommands.isEmpty()) {
|
if (remainingCommands.isEmpty()) {
|
||||||
remainingCommands.addAll(commands);
|
remainingCommands.addAll(commands);
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public class PackGeneratorCommand {
|
|||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
if (!PackManager.getInstance().finish()) {
|
if (!PackManager.getInstance().finish()) {
|
||||||
context.getSource().sendError(Component.literal("Errors occurred whilst trying to write the pack to disk!"));
|
context.getSource().sendError(Component.literal("Errors occurred whilst trying to write the pack to disk!"));
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
context.getSource().sendFeedback(Component.literal("Wrote pack to disk"));
|
context.getSource().sendFeedback(Component.literal("Wrote pack to disk"));
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ public class GeyserMappings {
|
|||||||
mappings.put(item, mapping);
|
mappings.put(item, mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return mappings.size();
|
||||||
|
}
|
||||||
|
|
||||||
public void map(ItemStack stack, ProblemReporter reporter, Consumer<GeyserMapping> mappingConsumer) {
|
public void map(ItemStack stack, ProblemReporter reporter, Consumer<GeyserMapping> mappingConsumer) {
|
||||||
Optional<? extends ResourceLocation> patchedModel = stack.getComponentsPatch().get(DataComponents.ITEM_MODEL);
|
Optional<? extends ResourceLocation> patchedModel = stack.getComponentsPatch().get(DataComponents.ITEM_MODEL);
|
||||||
//noinspection OptionalAssignedToNull - annoying Mojang
|
//noinspection OptionalAssignedToNull - annoying Mojang
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.geysermc.packgenerator.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.components.SplashRenderer;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(SplashRenderer.class)
|
||||||
|
public interface SplashRendererAccessor {
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
String getSplash();
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package org.geysermc.packgenerator.pack;
|
|||||||
|
|
||||||
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.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.ProblemReporter;
|
import net.minecraft.util.ProblemReporter;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -10,6 +11,7 @@ import org.geysermc.packgenerator.CodecUtil;
|
|||||||
import org.geysermc.packgenerator.PackConstants;
|
import org.geysermc.packgenerator.PackConstants;
|
||||||
import org.geysermc.packgenerator.mapping.attachable.AttachableMapper;
|
import org.geysermc.packgenerator.mapping.attachable.AttachableMapper;
|
||||||
import org.geysermc.packgenerator.mapping.geyser.GeyserMappings;
|
import org.geysermc.packgenerator.mapping.geyser.GeyserMappings;
|
||||||
|
import org.geysermc.packgenerator.mixin.SplashRendererAccessor;
|
||||||
import org.geysermc.packgenerator.pack.attachable.BedrockAttachable;
|
import org.geysermc.packgenerator.pack.attachable.BedrockAttachable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -132,13 +134,38 @@ public class BedrockPack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.writeString(exportPath.resolve(REPORT_FILE), reporter.getTreeReport());
|
Files.writeString(exportPath.resolve(REPORT_FILE), createPackSummary());
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
// TODO log
|
// TODO log
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createPackSummary() {
|
||||||
|
return """
|
||||||
|
-- PACK GENERATION REPORT --
|
||||||
|
// %s
|
||||||
|
|
||||||
|
Generated pack: %s
|
||||||
|
Mappings written: %d
|
||||||
|
Item texture atlas size: %d
|
||||||
|
Attachables: %d
|
||||||
|
Textures tried to export: %d
|
||||||
|
|
||||||
|
-- PROBLEM REPORT --
|
||||||
|
%s
|
||||||
|
""".formatted(randomSummaryComment(), name, mappings.size(), itemTextures.build().size(),
|
||||||
|
attachables.size(), texturesToExport.size(), reporter.getTreeReport());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String randomSummaryComment() {
|
||||||
|
SplashRenderer splash = Minecraft.getInstance().getSplashManager().getSplash();
|
||||||
|
if (splash == null) {
|
||||||
|
return "Undefined Undefined :(";
|
||||||
|
}
|
||||||
|
return ((SplashRendererAccessor) splash).getSplash();
|
||||||
|
}
|
||||||
|
|
||||||
private static Path createPackDirectory(String name) throws IOException {
|
private static Path createPackDirectory(String name) throws IOException {
|
||||||
Path path = EXPORT_DIRECTORY.resolve(name);
|
Path path = EXPORT_DIRECTORY.resolve(name);
|
||||||
CodecUtil.ensureDirectoryExists(path);
|
CodecUtil.ensureDirectoryExists(path);
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ public record BedrockTextures(Map<String, String> textures) {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return textures.size();
|
||||||
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
"EntityRenderDispatcherAccessor",
|
"EntityRenderDispatcherAccessor",
|
||||||
"SelectItemModelAccessor",
|
"SelectItemModelAccessor",
|
||||||
"SelectItemModelMixin",
|
"SelectItemModelMixin",
|
||||||
"SelectItemModelMixin$UnbakedSwitchMixin"
|
"SelectItemModelMixin$UnbakedSwitchMixin",
|
||||||
|
"SplashRendererAccessor"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user