Search in sources :

Example 1 with InclusiveRange

use of net.minecraft.util.InclusiveRange in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method setSpawnerCustomRules.

@Override
public void setSpawnerCustomRules(CreatureSpawner spawner, int skyMin, int skyMax, int blockMin, int blockMax) {
    try {
        CraftCreatureSpawner bukkitSpawner = (CraftCreatureSpawner) spawner;
        SpawnerBlockEntity nmsSnapshot = (SpawnerBlockEntity) craftBlockEntityState_snapshot.get(bukkitSpawner);
        BaseSpawner nmsSpawner = nmsSnapshot.getSpawner();
        SpawnData toSpawn = nmsSpawner.nextSpawnData;
        SpawnData.CustomSpawnRules rules = skyMin == -1 ? null : new SpawnData.CustomSpawnRules(new InclusiveRange<>(skyMin, skyMax), new InclusiveRange<>(blockMin, blockMax));
        nmsSpawner.nextSpawnData = new SpawnData(toSpawn.entityToSpawn(), Optional.ofNullable(rules));
        nmsSpawner.spawnPotentials = SimpleWeightedRandomList.empty();
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) BaseSpawner(net.minecraft.world.level.BaseSpawner) SpawnData(net.minecraft.world.level.SpawnData) InclusiveRange(net.minecraft.util.InclusiveRange)

Aggregations

InclusiveRange (net.minecraft.util.InclusiveRange)1 BaseSpawner (net.minecraft.world.level.BaseSpawner)1 SpawnData (net.minecraft.world.level.SpawnData)1 SpawnerBlockEntity (net.minecraft.world.level.block.entity.SpawnerBlockEntity)1