Level Spawners
LevelSpawners are used to control
the spawning of entities around players or specific areas in a world. These are completely separate from BiomeSpawners
and are tied directly to the world itself. By default, LevelCreator will not have
any spawners attached to it.
In Wyck, you can reference existing built-in LevelSpawners
or author your own.
SpawnTick (For Custom Spawners)
Section titled “SpawnTick (For Custom Spawners)”A SpawnTick is a single tick of spawning for a given
world. It contains the world itself and a boolean indicating whether or not to spawn hostile mobs.
Example Usage
Section titled “Example Usage”import dev.wyck.keys.ResourceKey;
import dev.wyck.model.level.LevelCreator;
import dev.wyck.wrapper.level.spawner.LevelSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
// Referencing an existing LevelSpawner
LevelSpawner phantomSpawner = LevelSpawner.phantom();
// Creating a custom LevelSpawner
LevelSpawner customSpawner = LevelSpawner.custom((world, spawnEnemies) -> {
for (Player player : world.getPlayers()) {
player.getScheduler().run(this, _ -> {
EntityType type = spawnEnemies ? EntityType.ZOMBIE : EntityType.PIG;
world.spawnEntity(player.getLocation(), type);
}, null);
}
});
// Adding the spawners to a LevelCreator
LevelCreator level = LevelCreator.builder()
.levelKey(ResourceKey.of("test", "example"))
.addSpawner(phantomSpawner)
.addSpawner(customSpawner)
.build();
}
}