mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Vwoop
This commit is contained in:
1 parent
55b7460b9a
commit
699247b1de
327 files changed
+30138
-3934
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.iris.engine.object.IrisObjectRotation;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class StubPlatformStateTest {
|
||||
@BeforeClass
|
||||
public static void bindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
IrisPlatforms.bind(new StubPlatform());
|
||||
StubPlatform.bindGenerationStateHandlers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rotatesFacingAxisAndConnectedFaces() {
|
||||
IrisObjectRotation rotation = IrisObjectRotation.of(0, 90, 0);
|
||||
|
||||
assertEquals("minecraft:oak_stairs[facing=west,half=bottom]",
|
||||
StubPlatform.rotateForTest(rotation, state("minecraft:oak_stairs[facing=north,half=bottom]")).key());
|
||||
assertEquals("minecraft:oak_log[axis=x]",
|
||||
StubPlatform.rotateForTest(rotation, state("minecraft:oak_log[axis=z]")).key());
|
||||
assertEquals("minecraft:oak_fence[north=false,east=false,south=false,west=true]",
|
||||
StubPlatform.rotateForTest(rotation,
|
||||
state("minecraft:oak_fence[north=true,east=false,south=false,west=false]")).key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyUpdatesAndMergesPreserveCanonicalState() {
|
||||
PlatformBlockState base = state("minecraft:oak_leaves[distance=7,persistent=false]");
|
||||
PlatformBlockState updated = base.withProperty("distance", "2").withProperty("persistent", "true");
|
||||
|
||||
assertEquals("minecraft:oak_leaves[distance=2,persistent=true]", updated.key());
|
||||
|
||||
PlatformBlockState merged = StubPlatform.mergeForTest(
|
||||
base, state("minecraft:oak_leaves[persistent=true]"));
|
||||
assertEquals("minecraft:oak_leaves[distance=7,persistent=true]", merged.key());
|
||||
}
|
||||
|
||||
private PlatformBlockState state(String key) {
|
||||
return IrisPlatforms.get().registries().block(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class StubTileDataTest {
|
||||
@Test
|
||||
public void modernTilePayloadRoundTripsWithoutBukkit() throws Exception {
|
||||
KMap<String, Object> properties = new KMap<>();
|
||||
properties.put("LootTable", "minecraft:chests/ancient_city");
|
||||
StubTileData original = StubTileData.fromProperties(
|
||||
StubPlatform.blockStateForTest("minecraft:chest[facing=north]"), properties);
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
try (DataOutputStream output = new DataOutputStream(bytes)) {
|
||||
original.toBinary(output);
|
||||
}
|
||||
|
||||
StubTileData decoded;
|
||||
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
|
||||
decoded = StubTileData.read(input);
|
||||
}
|
||||
|
||||
assertEquals("minecraft:chest", decoded.blockKey());
|
||||
assertEquals("minecraft:chests/ancient_city", decoded.getProperties().get("LootTable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void legacyLootablePayloadPreservesItsCompleteFrame() throws Exception {
|
||||
byte[] payload = encode(output -> {
|
||||
output.writeShort(3);
|
||||
output.writeUTF("minecraft:chest");
|
||||
output.writeUTF("minecraft:chests/ancient_city");
|
||||
output.writeLong(998877L);
|
||||
});
|
||||
|
||||
StubTileData decoded = decode(payload);
|
||||
|
||||
assertEquals("minecraft:chest", decoded.blockKey());
|
||||
assertEquals("minecraft:chests/ancient_city", decoded.getProperties().get("LootTable"));
|
||||
assertArrayEquals(payload, encode(decoded::toBinary));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void legacySpawnerAndBannerFramesRemainUnambiguous() throws Exception {
|
||||
byte[] ordinalSpawner = encode(output -> {
|
||||
output.writeShort(1);
|
||||
output.writeShort(42);
|
||||
});
|
||||
byte[] keyedBanner = encode(output -> {
|
||||
output.writeShort(2);
|
||||
output.writeByte(11);
|
||||
output.writeByte(1);
|
||||
output.writeByte(3);
|
||||
output.writeUTF("minecraft:base");
|
||||
});
|
||||
|
||||
assertArrayEquals(ordinalSpawner, encode(decode(ordinalSpawner)::toBinary));
|
||||
assertArrayEquals(keyedBanner, encode(decode(keyedBanner)::toBinary));
|
||||
}
|
||||
|
||||
private static StubTileData decode(byte[] payload) throws Exception {
|
||||
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(payload))) {
|
||||
return StubTileData.read(input);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] encode(BinaryWriter writer) throws Exception {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
try (DataOutputStream output = new DataOutputStream(bytes)) {
|
||||
writer.write(output);
|
||||
}
|
||||
return bytes.toByteArray();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface BinaryWriter {
|
||||
void write(DataOutputStream output) throws Exception;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user