mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Follow the API's move of MantleCodec to com.volmit.data.Codec
This commit is contained in:
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) {
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.data.Codec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
import com.volmit.placement.PlacedBlock;
|
||||
@@ -86,7 +86,7 @@ public class DimensionBottomTest {
|
||||
private static final BlockBox WHOLE_HEIGHT_AROUND_ONE_CHUNK = new BlockBox(-16, BOTTOM, -16, 32, DIMENSION_HEIGHT, 32);
|
||||
private static final BlockState STONE = BlockState.parse("minecraft:stone");
|
||||
private static final MantleKey<String> MARKS = new MantleKey<>("test:bottom/mark", String.class);
|
||||
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
|
||||
private static final Codec<String> TEXT = new Codec<>() {
|
||||
public int version() { return 1; }
|
||||
public void write(DataOutput output, String value) throws IOException { output.writeUTF(value); }
|
||||
public String read(DataInput input, int storedVersion) throws IOException { return input.readUTF(); }
|
||||
|
||||
@@ -12,7 +12,7 @@ import art.arcane.volmlib.util.mantle.runtime.MantleHooks;
|
||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.data.Codec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
@@ -55,7 +55,7 @@ public final class InMemoryMantle {
|
||||
}
|
||||
|
||||
/** What the layer holds at a block of the mantle's storage coordinates, or null. */
|
||||
public <T> T value(MantleKey<T> key, MantleCodec<T> codec, int x, int mantleY, int z) {
|
||||
public <T> T value(MantleKey<T> key, Codec<T> codec, int x, int mantleY, int z) {
|
||||
MantleChunk<Matter> chunk = chunk(x >> 4, z >> 4);
|
||||
if (!chunk.exists(mantleY >> 4) || !chunk.get(mantleY >> 4).hasSlice(ModuleLayerValues.class)) {
|
||||
return null;
|
||||
|
||||
@@ -47,7 +47,7 @@ import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.MantleRegistration;
|
||||
import com.volmit.host.ModuleHost;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
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;
|
||||
@@ -87,12 +87,12 @@ public class IrisModuleMantleTest {
|
||||
private static final int HEIGHT = SECTIONS * 16;
|
||||
private static final MantleKey<String> MARKS = new MantleKey<>("iris:marks/mark", String.class);
|
||||
private static final MantleKey<Integer> DEPTHS = new MantleKey<>("iris:marks/depth", Integer.class);
|
||||
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
|
||||
private static final Codec<String> TEXT = new Codec<>() {
|
||||
public int version() { return 1; }
|
||||
public void write(DataOutput output, String value) throws IOException { output.writeUTF(value); }
|
||||
public String read(DataInput input, int storedVersion) throws IOException { return input.readUTF(); }
|
||||
};
|
||||
private static final MantleCodec<Integer> NUMBER = new MantleCodec<>() {
|
||||
private static final Codec<Integer> NUMBER = new Codec<>() {
|
||||
public int version() { return 0; }
|
||||
public void write(DataOutput output, Integer value) throws IOException { output.writeInt(value); }
|
||||
public Integer read(DataInput input, int storedVersion) throws IOException { return input.readInt(); }
|
||||
|
||||
@@ -5,7 +5,7 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.host.MantleRegistration;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.data.Codec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
import org.junit.After;
|
||||
@@ -30,7 +30,7 @@ public class PlacementMantleTest {
|
||||
private static final int HEIGHT = 64;
|
||||
private static final int Y = 20;
|
||||
private static final MantleKey<String> MARKS = new MantleKey<>("iris:marks/mark", String.class);
|
||||
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
|
||||
private static final Codec<String> TEXT = new Codec<>() {
|
||||
public int version() { return 1; }
|
||||
public void write(DataOutput output, String value) throws IOException { output.writeUTF(value); }
|
||||
public String read(DataInput input, int storedVersion) throws IOException { return input.readUTF(); }
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ import com.volmit.ModuleSetup;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.data.Codec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
import com.volmit.host.LoadedPack;
|
||||
@@ -469,7 +469,7 @@ public class ObjectPlacementRegressionTest {
|
||||
}
|
||||
|
||||
private static final MantleKey<String> MARKS = new MantleKey<>("test:mark/spot", String.class);
|
||||
private static final MantleCodec<String> TEXT = new MantleCodec<>() {
|
||||
private static final Codec<String> TEXT = new Codec<>() {
|
||||
public int version() { return 1; }
|
||||
public void write(java.io.DataOutput output, String value) throws IOException { output.writeUTF(value); }
|
||||
public String read(java.io.DataInput input, int storedVersion) throws IOException { return input.readUTF(); }
|
||||
|
||||
Reference in new issue
Block a user