mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Answer the GRAVITY, LOG and LEAVES traits, block tags and attachment to a face from the platform layer, with Bukkit, modded and stub implementations
This commit is contained in:
1 parent
818dbef261
commit
563c2cd276
15 files changed
+344
-35
No files matched your search
@@ -28,6 +28,7 @@ import art.arcane.iris.spi.PlatformBiomeWriter;
|
||||
import art.arcane.iris.spi.PlatformBlockProperty;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformEntityType;
|
||||
import art.arcane.iris.spi.PlatformFace;
|
||||
import art.arcane.iris.spi.PlatformItem;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.iris.spi.PlatformScheduler;
|
||||
@@ -166,13 +167,33 @@ public final class StubPlatform implements IrisPlatform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreeBlock() {
|
||||
public boolean isLog() {
|
||||
String blockKey = blockKey();
|
||||
return blockKey.endsWith("_log")
|
||||
|| blockKey.endsWith("_wood")
|
||||
|| blockKey.endsWith("_stem")
|
||||
|| blockKey.endsWith("_hyphae")
|
||||
|| blockKey.endsWith("_leaves");
|
||||
|| blockKey.endsWith("_hyphae");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves() {
|
||||
return blockKey().endsWith("_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity() {
|
||||
String blockKey = blockKey();
|
||||
return blockKey.endsWith(":sand")
|
||||
|| blockKey.endsWith(":red_sand")
|
||||
|| blockKey.endsWith(":gravel")
|
||||
|| blockKey.endsWith("_concrete_powder")
|
||||
|| blockKey.endsWith("anvil");
|
||||
}
|
||||
|
||||
/** The stub has no shapes: every solid block is sturdy on every face. */
|
||||
@Override
|
||||
public boolean canAttach(PlatformBlockState support, PlatformFace face) {
|
||||
return support.isSolid();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -567,6 +588,17 @@ public final class StubPlatform implements IrisPlatform {
|
||||
return StubBlockState.of(key);
|
||||
}
|
||||
|
||||
/** The stub knows the tags of the block traits it has: logs, leaves and the falling blocks. */
|
||||
@Override
|
||||
public boolean isInTag(PlatformBlockState block, String tag) {
|
||||
return switch (tag) {
|
||||
case "minecraft:logs" -> block.isLog();
|
||||
case "minecraft:leaves" -> block.isLeaves();
|
||||
case "minecraft:sand" -> block.key().endsWith(":sand") || block.key().endsWith(":red_sand");
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformBlockState air() {
|
||||
return StubBlockState.of("minecraft:air");
|
||||
|
||||
@@ -3,6 +3,8 @@ package art.arcane.iris.probe;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformFace;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -59,6 +61,29 @@ public final class StubPlatformStateTest {
|
||||
assertTrue(stone.isSolid());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void answersLogLeavesGravityTagsAndFaceSupport() {
|
||||
PlatformBlockState log = state("minecraft:oak_log[axis=y]");
|
||||
PlatformBlockState leaves = state("minecraft:oak_leaves[distance=7]");
|
||||
PlatformBlockState sand = state("minecraft:sand");
|
||||
PlatformBlockState stone = state("minecraft:stone");
|
||||
PlatformBlockState torch = state("minecraft:wall_torch");
|
||||
|
||||
assertTrue(log.isLog());
|
||||
assertFalse(log.isLeaves());
|
||||
assertTrue(leaves.isLeaves());
|
||||
assertTrue(log.isTreeBlock() && leaves.isTreeBlock());
|
||||
assertFalse(stone.isTreeBlock());
|
||||
assertTrue(sand.hasGravity());
|
||||
assertFalse(stone.hasGravity());
|
||||
PlatformRegistries registries = IrisPlatforms.get().registries();
|
||||
assertTrue(registries.isInTag(log, "minecraft:logs"));
|
||||
assertFalse(registries.isInTag(leaves, "minecraft:logs"));
|
||||
assertFalse(registries.isInTag(log, "pack:unknown"));
|
||||
assertTrue(torch.canAttach(stone, PlatformFace.NORTH));
|
||||
assertFalse(torch.canAttach(state("minecraft:air"), PlatformFace.NORTH));
|
||||
}
|
||||
|
||||
private PlatformBlockState state(String key) {
|
||||
return IrisPlatforms.get().registries().block(key);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user