Skip to content

Commit

Permalink
[endec] write type of each EDM element in a sequence individually (ne…
Browse files Browse the repository at this point in the history
…cessary since lists don't enforce that each element have the same type. in fact, this is highly untrue in general)
  • Loading branch information
gliscowo committed Jan 17, 2024
1 parent 9ec6445 commit 4b2ee66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.0
# Mod Properties
mod_version=0.12.1
mod_version=0.12.2
maven_group=io.wispforest
archives_base_name=owo-lib
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static void encodeElementData(DataOutput output, EdmElement<?> data) thro

output.writeInt(list.size());
if (!list.isEmpty()) {
output.writeByte(list.get(0).type().ordinal());
for (var element : list) {
output.writeByte(element.type().ordinal());
encodeElementData(output, element);
}
}
Expand Down Expand Up @@ -88,10 +88,9 @@ private static EdmElement<?> decodeElementData(DataInput input, byte type) throw
var length = input.readInt();
if (length != 0) {
var result = new ArrayList<EdmElement<?>>(length);
var listType = input.readByte();

for (int i = 0; i < length; i++) {
result.add(decodeElementData(input, listType));
result.add(decodeElementData(input, input.readByte()));
}

yield EdmElement.wrapSequence(result);
Expand Down

0 comments on commit 4b2ee66

Please sign in to comment.