Prevent entities from spawning if disabled
This commit is contained in:
parent
5be62802e8
commit
358c0099dd
1 changed files with 19 additions and 3 deletions
|
@ -45,11 +45,27 @@ public class SpawnRuleBuilder<M extends Mob> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts new rule building process.
|
* Starts new rule building process.
|
||||||
* @param entityType The entity you want to build a rule for
|
* @param wrapper The entity you want to build a rule for
|
||||||
* @return prepared {@link SpawnRuleBuilder} instance.
|
* @return prepared {@link SpawnRuleBuilder} instance.
|
||||||
*/
|
*/
|
||||||
public static SpawnRuleBuilder start(BCLEntityWrapper<? extends Mob> entityType) {
|
public static SpawnRuleBuilder start(BCLEntityWrapper<? extends Mob> wrapper) {
|
||||||
return start(entityType.type());
|
SpawnRuleBuilder builder = start(wrapper.type());
|
||||||
|
if (!wrapper.canSpawn()){
|
||||||
|
builder.preventSpawn();
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop entity spawn entierly
|
||||||
|
* @return same {@link SpawnRuleBuilder} instance.
|
||||||
|
*/
|
||||||
|
public SpawnRuleBuilder preventSpawn() {
|
||||||
|
entryInstance = getFromCache("prevent", () -> {
|
||||||
|
return new SpawnRuleEntry(-1, (type, world, spawnReason, pos, random) -> false);
|
||||||
|
});
|
||||||
|
rules.add(entryInstance);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue