Hi, I'm trying to read a custom binary data saved at resources/data/<mode-id>/5.bin, which is build by myself with a python script. It consists of a series of 7-byte-length data. I'm now using IdentifiableResourceReloadListener to read the file and build a struct based on the data. Everything's good when I test it in IDE using runClient launch task, but after I build the jar file and add it to a new Minecraft game, the obtained struct is totally confusing.
Here are my code to load the data:
// public CompletableFuture<Void> reload(Synchronizer synchronizer, ResourceManager manager, Executor prepareExecutor, Executor applyExecutor)
...
try (InputStream stream = manager.open(Identifier.of(MyMod.MOD_ID, "5.bin"))) {
byte[] item_buffer = new byte[7];
List<Solution> s = new ArrayList<>();
while (stream.read(item_buffer) != -1) {
List<DyeColor> colors = new ArrayList<>();
int total = item_buffer[3];
for (int i = 4; i < 7; i++) {
int idx = (item_buffer[i] & 0xF0) >> 4;
colors.add(DyeColor.byIndex(idx));
if (colors.size() == total) {
break;
}
idx = (item_buffer[i] & 0x0F) >> 0;
colors.add(DyeColor.byIndex(idx));
if (colors.size() == total) {
break;
}
}
s.add(new Solution(new Vec3i(item_buffer[0] & 0xff, item_buffer[1] & 0xff, item_buffer[2] & 0xff), colors));
}
root = buildTree(s, new ArrayList<Integer>(IntStream.range(0, s.size()).boxed().toList()), 0).get();
} catch (Exception e) {
e.printStackTrace();
}
...