
Base64 Encoder and Decoder Overflow
LunatiK-ExpiX opened this issue ยท 1 comments
Hello
Me and my friend have been attempting to make larger custom player models, but have been running into issues with it failing to load, and I have managed to pin down the issue.
Looking through the code brought me to this function
public static void exportB64(Editor e, UI gui, Consumer<String> b64Out, boolean forceOut) {
byte[] buffer = new byte[200];
int[] size = new int[] {0};
exportSkin0(e, gui, new Result(() -> {
size[0] = 0;
return new BAOS(buffer, size);
}, () -> b64Out.accept(Base64.getEncoder().encodeToString(Arrays.copyOf(buffer, size[0]))),
(d, c) -> handleOverflow(d, c, "b64", gui, e)), forceOut);
}
This function seems has a major issue, and it most likely related to the Arrays.copyOf(buffer, size[0]))
.
While I'm not experienced with java, I think it might be possible to instead split the string into 8KB chunks, and then recombine them at the very end, hopefully circumventing the limit completely.
That's not how that works.
This is the base64 export option for loading models with the /cpm command
It has a strict limit due to it has to fit inside a command and Minecraft has limits on command length.
Normal exports don't use this at all.
Export limits exist for a reason due to the way Minecraft works.
You can only store so much in the unsued pixels of a 64x64 image.
And the packet system for minecraft limits modded data to 32kb, so cpmmodels have that as a limit.
(This is where I could do some packet splitting, but I don't think it's worth the effort. The current paste site system is much better suited for serving larger files than the minecraft server would be.)