mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Let the server decide where decorators fit
Ported from v3e (af333cc93). Whether a plant stands on a ground block is now the server's own canSurvive rule, asked in a two-block level, so custom ground (CraftEngine and others) grows plants too. Plants that fail on every ground, like wall and ceiling blocks, keep fitting as before. Dead bushes stay off grass, as packs expect. Without the NMS binding Iris's own table answers. Test server, world v3eports (seed 1337, radius 500): 4,225 chunks, 0 failed, no errors; plants 70,161 vs 68,905 in iriswave6 over the same 961 sampled chunks, every plant type present.
This commit is contained in:
1 parent
6429b6ea5e
commit
d5e75114ab
4 files changed
+143
-1
No files matched your search
@@ -47,6 +47,8 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
@@ -276,6 +278,11 @@ public interface INMSBinding {
|
||||
|
||||
KMap<Material, List<BlockProperty>> getBlockProperties();
|
||||
|
||||
/** Whether the server lets {@code plant} stand on {@code ground}; without a 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;
|
||||
|
||||
@@ -414,7 +414,21 @@ public final class BukkitBlockState implements PlatformBlockState {
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOnto(PlatformBlockState onto) {
|
||||
return BukkitBlockResolution.canPlaceOnto(data.getMaterial(), ((BlockData) onto.nativeHandle()).getMaterial());
|
||||
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;
|
||||
}
|
||||
|
||||
private static BlockData realBlockOf(BlockData data) {
|
||||
return data instanceof IrisCustomData custom ? custom.getBase() : data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user