Skip to content

Commit a2d82b1

Browse files
Move custom skulls handling to core project, switch to generating mappings instead of YAML file
1 parent 9a5c471 commit a2d82b1

16 files changed

Lines changed: 168 additions & 158 deletions

File tree

client/src/main/java/org/geysermc/rainbow/client/PackManager.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.geysermc.rainbow.RainbowIO;
1212
import org.geysermc.rainbow.client.mixin.SplashRendererAccessor;
1313
import org.geysermc.rainbow.client.render.MinecraftGeometryRenderer;
14-
import org.geysermc.rainbow.client.skull.CustomSkulls;
1514
import org.geysermc.rainbow.mapping.AssetCacheStats;
1615
import org.geysermc.rainbow.mapping.PackStats;
1716
import org.geysermc.rainbow.pack.BedrockPack;
@@ -29,9 +28,8 @@ public final class PackManager {
2928
#### READ THIS FIRST ####
3029
What do I do now?
3130
32-
In this folder, you'll find 4 important files/folders along with this one:
31+
In this folder, you'll find 3 important files/folders along with this one:
3332
34-
- custom-skulls.yml: put this in Geyser's config folder. These are the exported player skulls. The file may already exist in Geyser's config folder, be careful with overwriting it!
3533
- custom_mappings: you need to put the files in here in the `custom_mappings` folder in Geyser's config folder. These are the generated Geyser mappings.
3634
- pack.zip: put this in the "packs" folder in Geyser's config folder. This is the generated bedrock resourcepack.
3735
- lang: put all files in this folder in the "locales/overrides" folder in Geyser's config folder. These are the exported custom translation strings.
@@ -56,23 +54,23 @@ You can also open an issue report over at our issue tracker (https://github.com/
5654
"you are now blinking manually", "you're eligible for a free hug token! <3", "don't mind me!", "hissss", "Gayser and Floodgayte, my favourite plugins.",
5755
"meow", "we'll be done here soon™", "got anything else to say?", "we're done now!", "this will be fixed by v6053", "expect it to be done within 180 business days!",
5856
"any colour you like", "someone tell Mojang about this", "you can't unbake baked models, so we'll store the unbaked models", "soon fully datagen ready",
59-
"packconverter when", "codecs ftw");
57+
"packconverter when", "codecs ftw", "skull mappings >>> custom-skulls.yml",
58+
"now with the ultimate, greatest custom content ever, which everybody asked for: custom waypoints", "unable to handle the merge");
6059
private static final RandomSource RANDOM = RandomSource.create();
6160

6261
private static final Path EXPORT_DIRECTORY = FabricLoader.getInstance().getGameDir().resolve(Rainbow.MOD_ID);
6362
private static final Path PACK_DIRECTORY = Path.of("pack");
6463
private static final Path MAPPINGS_DIRECTORY = Path.of("custom_mappings");
6564
private static final Path PACK_ZIP_FILE = Path.of("pack.zip");
6665
private static final Path PACK_LANG_FOLDER = Path.of("lang");
67-
private static final Path SKULLS_FILE = Path.of("custom-skulls.yml");
6866
private static final Path REPORT_FILE = Path.of("report.txt");
6967

7068
private final ClientPackSerializer packSerializer = new ClientPackSerializer();
71-
private Optional<RainbowPack> currentPack = Optional.empty();
69+
private Optional<BedrockPack> currentPack = Optional.empty();
7270

7371
public void startPack(String name) throws IOException {
7472
if (currentPack.isPresent()) {
75-
throw new IllegalStateException("Already started a pack (" + currentPack.get().resources.name() + ")");
73+
throw new IllegalStateException("Already started a pack (" + currentPack.get().name() + ")");
7674
}
7775
packSerializer.prepare(Objects.requireNonNull(Minecraft.getInstance().level).registryAccess());
7876

@@ -84,27 +82,25 @@ public void startPack(String name) throws IOException {
8482
.withGeometryRenderer(MinecraftGeometryRenderer.INSTANCE)
8583
.reportSuccesses()
8684
.build();
87-
currentPack = Optional.of(new RainbowPack(pack, new CustomSkulls()));
85+
currentPack = Optional.of(pack);
8886
}
8987

90-
public void run(Consumer<RainbowPack> consumer) {
88+
public void run(Consumer<BedrockPack> consumer) {
9189
currentPack.ifPresent(consumer);
9290
}
9391

94-
public void runOrElse(Consumer<RainbowPack> consumer, Runnable runnable) {
92+
public void runOrElse(Consumer<BedrockPack> consumer, Runnable runnable) {
9593
currentPack.ifPresentOrElse(consumer, runnable);
9694
}
9795

9896
public Optional<Path> getExportPath() {
99-
return currentPack.map(pack -> EXPORT_DIRECTORY.resolve(pack.resources.name()));
97+
return currentPack.map(pack -> EXPORT_DIRECTORY.resolve(pack.name()));
10098
}
10199

102100
public boolean finish(Runnable onFinish) {
103101
currentPack.ifPresent(pack -> {
104-
Path skullsPath = EXPORT_DIRECTORY.resolve(pack.resources.name()).resolve(SKULLS_FILE);
105-
Path reportPath = EXPORT_DIRECTORY.resolve(pack.resources.name()).resolve(REPORT_FILE);
106-
pack.resources.save().thenRun(() -> {
107-
RainbowIO.safeIO(() -> Files.writeString(skullsPath, pack.skulls.createConfig()));
102+
Path reportPath = EXPORT_DIRECTORY.resolve(pack.name()).resolve(REPORT_FILE);
103+
pack.save().thenRun(() -> {
108104
RainbowIO.safeIO(() -> Files.writeString(reportPath, createPackSummary(pack, packSerializer)));
109105
onFinish.run();
110106
});
@@ -114,17 +110,15 @@ public boolean finish(Runnable onFinish) {
114110
return wasPresent;
115111
}
116112

117-
public record RainbowPack(BedrockPack resources, CustomSkulls skulls) {}
118-
119113
// TODO: clean this up
120-
private static String createPackSummary(RainbowPack pack, ClientPackSerializer packSerializer) {
121-
String problems = ((ProblemReporter.Collector) pack.resources.getReporter()).getTreeReport();
114+
private static String createPackSummary(BedrockPack pack, ClientPackSerializer packSerializer) {
115+
String problems = ((ProblemReporter.Collector) pack.getReporter()).getTreeReport();
122116
if (StringUtil.isBlank(problems)) {
123117
problems = "Well that's odd... there's nothing here!";
124118
}
125119

126-
long attachables = pack.resources.getBedrockItems().stream().filter(item -> item.attachableContext().attachable().isPresent()).count();
127-
PackStats stats = pack.resources.stats();
120+
long attachables = pack.getBedrockItems().stream().filter(item -> item.attachableContext().attachable().isPresent()).count();
121+
PackStats stats = pack.stats();
128122
AssetCacheStats cacheStats = stats.cacheStats();
129123

130124
StringBuilder report = new StringBuilder(REPORT_HEADER);
@@ -134,7 +128,7 @@ private static String createPackSummary(RainbowPack pack, ClientPackSerializer p
134128
report.append('\n');
135129
report.append("\nVersion of Rainbow: ").append(RainbowClient.getVersion());
136130
report.append("\n");
137-
report.append("\nGenerated pack: ").append(pack.resources.name());
131+
report.append("\nGenerated pack: ").append(pack.name());
138132
report.append("\nBlock mappings written: ").append(stats.blockMappings());
139133
report.append("\nItem mappings written: ").append(stats.itemMappings());
140134
report.append("\n");
@@ -148,9 +142,9 @@ private static String createPackSummary(RainbowPack pack, ClientPackSerializer p
148142
report.append("\nJSON-files written: ").append(packSerializer.jsonExported());
149143
report.append("\nTextures written: ").append(packSerializer.texturesExported());
150144
report.append("\n");
151-
report.append("\nUsername skulls exported: ").append(pack.skulls.usernames());
152-
report.append("\nUUID skulls exported: ").append(pack.skulls.uuids());
153-
report.append("\nStatic texture skulls exported: ").append(pack.skulls.textures());
145+
report.append("\nUsername skulls exported: ").append("TODO");//.append(pack.skulls.usernames());
146+
report.append("\nUUID skulls exported: ").append("TODO");//.append(pack.skulls.uuids());
147+
report.append("\nStatic texture skulls exported: ").append("TODO");//.append(pack.skulls.textures());
154148
report.append("\n");
155149
report.append("\n-- ASSET CACHE STATS --");
156150
report.append("\nGeometry cache: %d written, %d cache hits ".formatted(cacheStats.geometry().size(), cacheStats.geometry().hits()));

client/src/main/java/org/geysermc/rainbow/client/command/PackGeneratorCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
6060
BlockPos pos = clientCoordinatesToBlockPos(context.getSource(), context.getArgument("target", Coordinates.class));
6161
BlockState state = context.getSource().getLevel().getBlockState(pos);
6262
return runWithPack(packManager, (source, pack) -> {
63-
switch (pack.resources().mapBlockStateExplicitly(state)) {
63+
switch (pack.mapBlockStateExplicitly(state)) {
6464
case NONE_MAPPED -> source.sendError(Component.translatable("commands.rainbow.no_block_mapped"));
6565
case PROBLEMS_OCCURRED -> source.sendFeedback(Component.translatable("commands.rainbow.mapped_target_block_problems"));
6666
case MAPPED_SUCCESSFULLY -> source.sendFeedback(Component.translatable("commands.rainbow.mapped_target_block"));
@@ -89,7 +89,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
8989
.executes(context -> {
9090
String namespace = StringArgumentType.getString(context, "namespace");
9191
return runWithPack(packManager, (source, pack) -> {
92-
if (pack.resources().mapSounds(namespace)) {
92+
if (pack.mapSounds(namespace)) {
9393
source.sendFeedback(Component.translatable("commands.rainbow.mapped_sounds_of_namespace", namespace));
9494
} else {
9595
source.sendError(Component.translatable("commands.rainbow.no_sounds_mapped"));
@@ -145,7 +145,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
145145
*/
146146
.then(ClientCommands.literal("blocks")
147147
.executes(runWithPack(packManager, (source, pack) -> {
148-
BedrockPack.MappingResults results = pack.resources().tryMapAllVanillaBlocks();
148+
BedrockPack.MappingResults results = pack.tryMapAllVanillaBlocks();
149149
switch (results.toSingleResult()) {
150150
case NONE_MAPPED -> source.sendFeedback(Component.translatable("commands.rainbow.no_blocks_mapped"));
151151
case MAPPED_SUCCESSFULLY, PROBLEMS_OCCURRED -> {
@@ -171,7 +171,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
171171
)
172172
.then(ClientCommands.literal("sounds")
173173
.executes(runWithPack(packManager, (source, pack) -> {
174-
if (pack.resources().mapAllSounds()) {
174+
if (pack.mapAllSounds()) {
175175
source.sendFeedback(Component.translatable("commands.rainbow.mapped_all_sounds"));
176176
} else {
177177
source.sendError(Component.translatable("commands.rainbow.no_sounds_mapped"));
@@ -200,7 +200,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
200200
);
201201
}
202202

203-
private static Command<FabricClientCommandSource> runWithPack(PackManager manager, BiConsumer<FabricClientCommandSource, PackManager.RainbowPack> executor) {
203+
private static Command<FabricClientCommandSource> runWithPack(PackManager manager, BiConsumer<FabricClientCommandSource, BedrockPack> executor) {
204204
return context -> {
205205
manager.runOrElse(pack -> executor.accept(context.getSource(), pack),
206206
() -> context.getSource().sendError(NO_PACK_CREATED));

client/src/main/java/org/geysermc/rainbow/client/mapper/PackMapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ public void tick(Minecraft minecraft) {
5151
}
5252
}
5353

54-
public MappingResults mapItems(PackManager.RainbowPack pack, Collection<ItemStackTemplate> items) {
54+
public MappingResults mapItems(BedrockPack pack, Collection<ItemStackTemplate> items) {
5555
long skullsMapped = items.stream()
5656
.filter(stack -> {
5757
ResolvableProfile profile = stack.get(DataComponents.PROFILE);
58-
return profile != null && pack.skulls().withProfile(profile);
58+
return profile != null && pack.mapSkull(profile) == BedrockPack.MappingResult.MAPPED_SUCCESSFULLY;
5959
})
6060
.count();
6161

6262
int itemsMapped = 0;
6363
int problems = 0;
6464
for (ItemStackTemplate stack : items) {
65-
switch (pack.resources().mapItem(stack)) {
65+
switch (pack.mapItem(stack)) {
6666
case MAPPED_SUCCESSFULLY -> itemsMapped++;
6767
case PROBLEMS_OCCURRED -> {
6868
itemsMapped++;

client/src/main/java/org/geysermc/rainbow/client/skull/CustomSkulls.java

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
accessWidener v2 official
22
accessible class net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture
33
accessible class net/minecraft/client/renderer/texture/SpriteContents$FrameInfo
4-
accessible class net/minecraft/world/item/component/ResolvableProfile$Partial

client/src/main/resources/rainbow-client.mixins.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99
"ModelManagerMixin",
1010
"PictureInPictureRendererAccessor",
1111
"PictureInPictureRendererMixin",
12+
"SoundManagerMixin",
1213
"SplashRendererAccessor",
1314
"SpriteContentsAnimatedTextureAccessor",
1415
"SpriteContentsClientAccessor"
1516
],
1617
"injectors": {
1718
"defaultRequire": 1
18-
},
19-
"mixins": [
20-
"ResolvableProfileAccessor",
21-
"SoundManagerMixin"
22-
]
19+
}
2320
}

rainbow/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ plugins {
44
}
55

66
loom {
7+
accessWidenerPath = file("src/main/resources/rainbow.accesswidener")
8+
79
runs.clear()
810
}

rainbow/src/main/java/org/geysermc/rainbow/definition/GeyserMappings.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import org.geysermc.rainbow.definition.block.GeyserBlockMappings;
44
import org.geysermc.rainbow.definition.item.GeyserItemMappings;
5+
import org.geysermc.rainbow.definition.skull.GeyserSkullMappings;
56

6-
public record GeyserMappings(GeyserBlockMappings blocks, GeyserItemMappings items) {
7+
public record GeyserMappings(GeyserBlockMappings blocks, GeyserItemMappings items,
8+
GeyserSkullMappings skulls) {
79

810
public GeyserMappings() {
9-
this(new GeyserBlockMappings(), new GeyserItemMappings());
11+
this(new GeyserBlockMappings(), new GeyserItemMappings(), new GeyserSkullMappings());
1012
}
1113
}

0 commit comments

Comments
 (0)