use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.
the class PersistentDataUtils method getTotalSpawnCount.
public static long getTotalSpawnCount(StackedSpawnerTile spawner) {
RosePlugin rosePlugin = RoseStacker.getInstance();
PersistentDataContainer persistentDataContainer = spawner.getPersistentDataContainer();
if (persistentDataContainer == null)
return 0;
NamespacedKey key = new NamespacedKey(rosePlugin, TOTAL_SPAWNS_METADATA_NAME);
Long amount = persistentDataContainer.get(key, PersistentDataType.LONG);
return amount != null ? amount : 0;
}
use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.
the class PersistentDataUtils method increaseSpawnCount.
public static void increaseSpawnCount(StackedSpawnerTile spawner, long amount) {
RosePlugin rosePlugin = RoseStacker.getInstance();
PersistentDataContainer dataContainer = spawner.getPersistentDataContainer();
if (dataContainer != null) {
NamespacedKey key = new NamespacedKey(rosePlugin, TOTAL_SPAWNS_METADATA_NAME);
if (!dataContainer.has(key, PersistentDataType.LONG)) {
dataContainer.set(key, PersistentDataType.LONG, amount);
} else {
dataContainer.set(key, PersistentDataType.LONG, getTotalSpawnCount(spawner) + amount);
}
}
}
use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.
the class PersistentDataUtils method tagSpawnedFromSpawner.
public static void tagSpawnedFromSpawner(LivingEntity entity) {
RosePlugin rosePlugin = RoseStacker.getInstance();
entity.getPersistentDataContainer().set(new NamespacedKey(rosePlugin, SPAWNED_FROM_SPAWNER_METADATA_NAME), PersistentDataType.INTEGER, 1);
}
use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.
the class PersistentDataUtils method setEntitySpawnReason.
/**
* Sets the spawn reason for the given LivingEntity.
* Does not overwrite an existing spawn reason.
*
* @param entity The entity to set the spawn reason of
* @param spawnReason The spawn reason to set
*/
public static void setEntitySpawnReason(LivingEntity entity, SpawnReason spawnReason) {
RosePlugin rosePlugin = RoseStacker.getInstance();
PersistentDataContainer dataContainer = entity.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(rosePlugin, SPAWN_REASON_METADATA_NAME);
if (!dataContainer.has(key, PersistentDataType.STRING))
dataContainer.set(key, PersistentDataType.STRING, spawnReason.name());
}
use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.
the class PersistentDataUtils method removeEntityAi.
public static void removeEntityAi(LivingEntity entity) {
RosePlugin rosePlugin = RoseStacker.getInstance();
PersistentDataContainer dataContainer = entity.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(rosePlugin, NO_AI_METADATA_NAME);
if (!dataContainer.has(key, PersistentDataType.INTEGER))
dataContainer.set(key, PersistentDataType.INTEGER, 1);
applyDisabledAi(entity);
}
Aggregations