Skip to content

Commit fa33dde

Browse files
authored
Merge pull request #9 from CgAu3/releases/1.21.1
🐛试图修复CodecUtil.NUMBER_PROVIDER_CODEC解码数据时的异常截断
2 parents ac9f980 + c893c43 commit fa33dde

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/dev/anvilcraft/lib/util/CodecUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,17 @@ public abstract class CodecUtil {
102102
);
103103

104104
public static final Codec<NumberProvider> NUMBER_PROVIDER_CODEC = Codec.either(
105+
NumberProviders.CODEC,
105106
Codec.INT.xmap(
106107
ConstantValue::new,
107108
value -> Math.round(value.value())
108-
), NumberProviders.CODEC
109+
)
109110
).xmap(
110111
Either::unwrap, provider -> {
111112
if (!(provider instanceof ConstantValue(float value)) || value - Math.floor(value) >= 1E-5) {
112-
return Either.right(provider);
113+
return Either.left(provider);
113114
}
114-
return Either.left((ConstantValue) provider);
115+
return Either.right((ConstantValue) provider);
115116
}
116117
);
117118

0 commit comments

Comments
 (0)