Follow the API's move of MantleCodec to com.volmit.data.Codec

This commit is contained in:
piexel committed 2026-11-06 11:39:54 +01:00
1 parent a905dc24e7
commit 7c90040924
7 files changed
+24 -24

No files matched your search

@@ -30,7 +30,7 @@ import com.volmit.host.MantleRegistration;
import art.arcane.iris.builtin.MatterMantle;
import com.volmit.geometry.BlockBox;
import com.volmit.mantle.Mantle;
import com.volmit.mantle.MantleCodec;
import com.volmit.data.Codec;
import com.volmit.mantle.MantleEdit;
import com.volmit.mantle.MantleKey;
import com.volmit.mantle.MantleLayer;
@@ -142,7 +142,7 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
}
@SuppressWarnings("unchecked") // The registration's type was compared with the key's.
private <T> MantleCodec<T> codecOf(MantleKey<T> key) {
private <T> Codec<T> codecOf(MantleKey<T> key) {
Objects.requireNonNull(key, "key");
MantleRegistration<?> registration = registrations.get(key.id());
if (registration == null) {
@@ -152,16 +152,16 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
throw new IllegalArgumentException("Mantle layer " + key.id() + " is registered as " + registration.key().type().getName()
+ ", not " + key.type().getName());
}
return (MantleCodec<T>) registration.codec();
return (Codec<T>) registration.codec();
}
private record Stored<T>(int x, int y, int z, T value) {}
private final class Layer<T> implements MantleLayer<T> {
private final MantleKey<T> key;
private final MantleCodec<T> codec;
private final Codec<T> codec;
Layer(MantleKey<T> key, MantleCodec<T> codec) {
Layer(MantleKey<T> key, Codec<T> codec) {
this.key = key;
this.codec = codec;
}
@@ -236,7 +236,7 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
ModuleLayerValues applyTo(ModuleLayerValues values);
}
private record Put<T>(MantleKey<T> key, MantleCodec<T> codec, T value) implements Change {
private record Put<T>(MantleKey<T> key, Codec<T> codec, T value) implements Change {
@Override
public ModuleLayerValues applyTo(ModuleLayerValues values) {
return values.with(key, codec, value);
@@ -18,7 +18,7 @@
package art.arcane.iris.core.modules;
import com.volmit.mantle.MantleCodec;
import com.volmit.data.Codec;
import com.volmit.mantle.MantleKey;
import java.io.ByteArrayInputStream;
@@ -49,7 +49,7 @@ public final class ModuleLayerValues {
}
/** The value of {@code key}, decoded with {@code codec} if it was read from disk; null when the layer holds none. */
public <T> T get(MantleKey<T> key, MantleCodec<T> codec) {
public <T> T get(MantleKey<T> key, Codec<T> codec) {
LayerValue value = layers.get(key.id());
return value == null ? null : key.type().cast(value.decode(key, codec));
}
@@ -63,7 +63,7 @@ public final class ModuleLayerValues {
}
/** These values with {@code key} holding {@code value}. */
public <T> ModuleLayerValues with(MantleKey<T> key, MantleCodec<T> codec, T value) {
public <T> ModuleLayerValues with(MantleKey<T> key, Codec<T> codec, T value) {
TreeMap<String, LayerValue> changed = new TreeMap<>(layers);
changed.put(key.id(), new Decoded<>(value, codec));
return new ModuleLayerValues(changed);
@@ -118,14 +118,14 @@ public final class ModuleLayerValues {
}
private sealed interface LayerValue permits Decoded, Encoded {
Object decode(MantleKey<?> key, MantleCodec<?> codec);
Object decode(MantleKey<?> key, Codec<?> codec);
Encoded encoded() throws IOException;
}
private record Decoded<T>(T value, MantleCodec<T> codec) implements LayerValue {
private record Decoded<T>(T value, Codec<T> codec) implements LayerValue {
@Override
public Object decode(MantleKey<?> key, MantleCodec<?> requested) {
public Object decode(MantleKey<?> key, Codec<?> requested) {
return value;
}
@@ -152,7 +152,7 @@ public final class ModuleLayerValues {
}
@Override
public Object decode(MantleKey<?> key, MantleCodec<?> codec) {
public Object decode(MantleKey<?> key, Codec<?> codec) {
try {
return codec.read(new DataInputStream(new ByteArrayInputStream(payload)), version);
} catch (IOException failure) {