mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +00:00
Use table for unanswered rules
- Fall back to the block table when the server rule cannot answer - Drop the INMSBinding default and the copied dead bush check - Take GroundSurvival from native-common in the headless build - Restore the placement table contract tests - Test unanswered rules, air ground and concurrent lookups
This commit is contained in:
5 files changed
+108
-27
No files matched your search
@@ -25,6 +25,7 @@ import art.arcane.iris.integration.ExternalDataSVC;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.volmlib.nativelib.terrain.BlockStateKey;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.SurvivalAnswer;
|
||||
import art.arcane.iris.generation.block.IrisCustomData;
|
||||
import art.arcane.iris.generation.geometry.IrisBlockVector;
|
||||
import art.arcane.iris.spi.IrisServices;
|
||||
@@ -429,17 +430,14 @@ public final class BukkitBlockState implements NativeBlockState {
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOnto(NativeBlockState onto) {
|
||||
BlockData ground = (BlockData) onto.nativeHandle();
|
||||
if (ground.getMaterial().isAir() || isDeadBushOnGrass(ground)) {
|
||||
return false;
|
||||
}
|
||||
return INMS.get().canSurviveOn(realBlockOf(data), realBlockOf(ground));
|
||||
}
|
||||
|
||||
// Vanilla allows this, but packs mix dead bushes with other plants for their sandy patches, and blacklisting grass
|
||||
// on such a decorator would take the other plants off the grass too.
|
||||
private boolean isDeadBushOnGrass(BlockData ground) {
|
||||
return data.getMaterial() == Material.DEAD_BUSH && ground.getMaterial() == Material.GRASS_BLOCK;
|
||||
BlockData plant = realBlockOf(data);
|
||||
BlockData ground = realBlockOf((BlockData) onto.nativeHandle());
|
||||
SurvivalAnswer serverRule = INMS.isBound() ? INMS.get().canSurviveOn(plant, ground) : SurvivalAnswer.UNANSWERED;
|
||||
return switch (serverRule) {
|
||||
case SURVIVES -> true;
|
||||
case FAILS -> false;
|
||||
case UNANSWERED -> BukkitBlockResolution.canPlaceOnto(plant.getMaterial(), ground.getMaterial());
|
||||
};
|
||||
}
|
||||
|
||||
private static BlockData realBlockOf(BlockData data) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import art.arcane.volmlib.nativelib.terrain.NativeSectionVolume;
|
||||
import art.arcane.volmlib.nativelib.terrain.BukkitTerrainBuffer;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
|
||||
import art.arcane.volmlib.util.nbt.mca.NBTWorldSupport;
|
||||
|
||||
@@ -323,11 +322,6 @@ public interface INMSBinding extends NativeTerrainAccess {
|
||||
|
||||
KMap<Material, List<BlockProperty>> getBlockProperties();
|
||||
|
||||
/** Whether the server lets {@code plant} stand on {@code ground}; without a native binding, Iris's own table of plants and grounds answers. */
|
||||
default boolean canSurviveOn(BlockData plant, BlockData ground) {
|
||||
return BukkitBlockResolution.canPlaceOnto(plant.getMaterial(), ground.getMaterial());
|
||||
}
|
||||
|
||||
private void validateDimensionTypes(WorldCreator c) {
|
||||
if (!(c.generator() instanceof PlatformChunkGenerator generator)) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user