Height spawn limit
This commit is contained in:
parent
6cbd400636
commit
3c5d560981
1 changed files with 19 additions and 1 deletions
|
@ -52,12 +52,30 @@ public class SpawnRuleBulder<M extends Mob> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts entity spawn above world surface (flying mobs).
|
||||
* @param minHeight minimal spawn height.
|
||||
* @return same {@link SpawnRuleBulder} instance
|
||||
*/
|
||||
public SpawnRuleBulder aboveGround(int minHeight) {
|
||||
entryInstance = getFromCache("above_ground", () -> {
|
||||
return new SpawnRuleEntry(0, (type, world, spawnReason, pos, random) -> {
|
||||
if (pos.getY() < world.getMinBuildHeight() + 2) {
|
||||
return false;
|
||||
}
|
||||
return pos.getY() > world.getHeight(Types.WORLD_SURFACE, pos.getX(), pos.getZ()) + minHeight;
|
||||
});
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts entity spawn below world logical height (useful for Nether mobs).
|
||||
* @return same {@link SpawnRuleBulder} instance
|
||||
*/
|
||||
public SpawnRuleBulder belowMaxHeight() {
|
||||
entryInstance = getFromCache("not_peaceful", () -> {
|
||||
entryInstance = getFromCache("below_max_height", () -> {
|
||||
return new SpawnRuleEntry(0, (type, world, spawnReason, pos, random) -> pos.getY() < world.dimensionType().logicalHeight());
|
||||
});
|
||||
rules.add(entryInstance);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue