|
1 | 1 | package org.cyclops.integrateddynamics.core.evaluate.variable; |
2 | 2 |
|
3 | 3 | import com.google.common.collect.Lists; |
| 4 | +import net.minecraft.nbt.ByteArrayTag; |
4 | 5 | import net.minecraft.nbt.CompoundTag; |
| 6 | +import net.minecraft.nbt.IntArrayTag; |
| 7 | +import net.minecraft.nbt.LongArrayTag; |
5 | 8 | import net.minecraft.nbt.Tag; |
6 | 9 | import org.cyclops.cyclopscore.helper.CyclopsCoreInstance; |
7 | 10 | import org.cyclops.integrateddynamics.ModBaseMocked; |
@@ -62,6 +65,48 @@ public void testMaterialized() throws IValueTypeListProxyFactoryTypeRegistry.Ser |
62 | 65 | )); |
63 | 66 | } |
64 | 67 |
|
| 68 | + @Test |
| 69 | + public void testMaterializedIntegerListFromIntArrayTag() throws IValueTypeListProxyFactoryTypeRegistry.SerializationException { |
| 70 | + // Simulate codec round-trip: ListTag<IntTag> -> IntArrayTag (as done by Minecraft's NbtOps) |
| 71 | + ValueTypeListProxyMaterialized<?, ?> proxy = new ValueTypeListProxyMaterialized<>( |
| 72 | + ValueTypes.INTEGER, |
| 73 | + Lists.newArrayList(ValueTypeInteger.ValueInteger.of(42)) |
| 74 | + ); |
| 75 | + Tag serialized = ValueTypeListProxyFactories.REGISTRY.serialize(ValueDeseralizationContextMocked.get(), proxy); |
| 76 | + CompoundTag tag = (CompoundTag) serialized; |
| 77 | + tag.put("values", new IntArrayTag(new int[]{42})); |
| 78 | + IValueTypeListProxy<?, ?> proxyNew = ValueTypeListProxyFactories.REGISTRY.deserialize(ValueDeseralizationContextMocked.get(), tag); |
| 79 | + assertThat(proxyNew, equalTo(proxy)); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void testMaterializedLongListFromLongArrayTag() throws IValueTypeListProxyFactoryTypeRegistry.SerializationException { |
| 84 | + // Simulate codec round-trip: ListTag<LongTag> -> LongArrayTag (as done by Minecraft's NbtOps) |
| 85 | + ValueTypeListProxyMaterialized<?, ?> proxy = new ValueTypeListProxyMaterialized<>( |
| 86 | + ValueTypes.LONG, |
| 87 | + Lists.newArrayList(ValueTypeLong.ValueLong.of(123L)) |
| 88 | + ); |
| 89 | + Tag serialized = ValueTypeListProxyFactories.REGISTRY.serialize(ValueDeseralizationContextMocked.get(), proxy); |
| 90 | + CompoundTag tag = (CompoundTag) serialized; |
| 91 | + tag.put("values", new LongArrayTag(new long[]{123L})); |
| 92 | + IValueTypeListProxy<?, ?> proxyNew = ValueTypeListProxyFactories.REGISTRY.deserialize(ValueDeseralizationContextMocked.get(), tag); |
| 93 | + assertThat(proxyNew, equalTo(proxy)); |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + public void testMaterializedBooleanListFromByteArrayTag() throws IValueTypeListProxyFactoryTypeRegistry.SerializationException { |
| 98 | + // Simulate codec round-trip: ListTag<ByteTag> -> ByteArrayTag (as done by Minecraft's NbtOps) |
| 99 | + ValueTypeListProxyMaterialized<?, ?> proxy = new ValueTypeListProxyMaterialized<>( |
| 100 | + ValueTypes.BOOLEAN, |
| 101 | + Lists.newArrayList(ValueTypeBoolean.ValueBoolean.of(true)) |
| 102 | + ); |
| 103 | + Tag serialized = ValueTypeListProxyFactories.REGISTRY.serialize(ValueDeseralizationContextMocked.get(), proxy); |
| 104 | + CompoundTag tag = (CompoundTag) serialized; |
| 105 | + tag.put("values", new ByteArrayTag(new byte[]{(byte) 1})); |
| 106 | + IValueTypeListProxy<?, ?> proxyNew = ValueTypeListProxyFactories.REGISTRY.deserialize(ValueDeseralizationContextMocked.get(), tag); |
| 107 | + assertThat(proxyNew, equalTo(proxy)); |
| 108 | + } |
| 109 | + |
65 | 110 | @Test |
66 | 111 | public void testNbtKeys() throws IValueTypeListProxyFactoryTypeRegistry.SerializationException { |
67 | 112 | testFactoryType(new ValueTypeListProxyNbtKeys( |
|
0 commit comments