Search in sources :

Example 1 with EntityStackSettings

use of dev.rosewood.rosestacker.stack.settings.EntityStackSettings in project RoseStacker by Rosewood-Development.

the class InteractListener method onInteract.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) {
    Block clickedBlock = event.getClickedBlock();
    ItemStack item = event.getItem();
    if (item == null || event.getAction() != Action.RIGHT_CLICK_BLOCK || clickedBlock == null)
        return;
    StackManager stackManager = this.rosePlugin.getManager(StackManager.class);
    if (stackManager.isWorldDisabled(event.getPlayer().getWorld()))
        return;
    if (stackManager.isSpawnerStackingEnabled()) {
        // Handle spawner conversion before we try to spawn entities
        if (clickedBlock.getType() == Material.SPAWNER && ItemUtils.isSpawnEgg(item.getType()) && ItemUtils.getStackedItemStackAmount(item) == 1) {
            StackedSpawner stackedSpawner = stackManager.getStackedSpawner(clickedBlock);
            if (stackedSpawner == null)
                stackedSpawner = stackManager.createSpawnerStack(clickedBlock, 1, false);
            EntityStackSettings stackSettings = this.rosePlugin.getManager(StackSettingManager.class).getEntityStackSettings(item.getType());
            if (stackSettings != null && stackSettings.getEntityType() == stackedSpawner.getSpawnerTile().getSpawnedType()) {
                // Don't allow converting spawners if it's the exact same type... that just wastes spawn eggs
                event.setCancelled(true);
                return;
            }
            if (!event.getPlayer().hasPermission("rosestacker.spawnerconvert")) {
                event.setCancelled(true);
                return;
            }
            if (Setting.SPAWNER_CONVERT_REQUIRE_SAME_AMOUNT.getBoolean() && item.getAmount() < stackedSpawner.getStackSize() && event.getPlayer().getGameMode() != GameMode.CREATIVE) {
                event.setCancelled(true);
                this.rosePlugin.getManager(LocaleManager.class).sendMessage(event.getPlayer(), "spawner-convert-not-enough");
                return;
            }
            StackedSpawner finalStackedSpawner = stackedSpawner;
            Bukkit.getScheduler().runTask(this.rosePlugin, () -> {
                // Make sure spawners convert and update their display properly
                finalStackedSpawner.updateSpawnerProperties(false);
                finalStackedSpawner.updateDisplay();
                if (finalStackedSpawner.getStackSize() != 1 && event.getPlayer().getGameMode() != GameMode.CREATIVE)
                    item.setAmount(item.getAmount() - finalStackedSpawner.getStackSize() + 1);
            });
            return;
        }
    }
    Location spawnLocation = clickedBlock.getRelative(event.getBlockFace()).getLocation();
    // Center on block
    spawnLocation.add(0.5, 0, 0.5);
    if (this.spawnEntities(null, spawnLocation, item) && clickedBlock.getType() != Material.SPAWNER) {
        ItemUtils.takeOneItem(event.getPlayer(), event.getHand());
        event.setCancelled(true);
    }
}
Also used : EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) StackedSpawner(dev.rosewood.rosestacker.stack.StackedSpawner) StackManager(dev.rosewood.rosestacker.manager.StackManager) Block(org.bukkit.block.Block) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) LocaleManager(dev.rosewood.rosestacker.manager.LocaleManager) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 2 with EntityStackSettings

use of dev.rosewood.rosestacker.stack.settings.EntityStackSettings in project RoseStacker by Rosewood-Development.

the class StackingThread method tryStackEntity.

/**
 * Tries to stack a StackedEntity with all other StackedEntities
 *
 * @param stackedEntity the StackedEntity to try to stack
 */
private void tryStackEntity(StackedEntity stackedEntity) {
    EntityStackSettings stackSettings = stackedEntity.getStackSettings();
    if (stackSettings == null)
        return;
    if (stackedEntity.checkNPC()) {
        this.removeEntityStack(stackedEntity);
        return;
    }
    LivingEntity entity = stackedEntity.getEntity();
    if (this.isRemoved(entity))
        return;
    if (!WorldGuardHook.testLocation(entity.getLocation()))
        return;
    Collection<Entity> nearbyEntities;
    Predicate<Entity> predicate = x -> x.getType() == entity.getType();
    if (!Setting.ENTITY_MERGE_ENTIRE_CHUNK.getBoolean()) {
        nearbyEntities = this.entityCacheManager.getNearbyEntities(entity.getLocation(), stackSettings.getMergeRadius(), predicate);
    } else {
        nearbyEntities = this.entityCacheManager.getEntitiesInChunk(entity.getLocation(), predicate);
    }
    Set<StackedEntity> targetEntities = new HashSet<>();
    targetEntities.add(stackedEntity);
    for (Entity otherEntity : nearbyEntities) {
        if (entity == otherEntity || this.isRemoved(otherEntity))
            continue;
        StackedEntity other = this.stackedEntities.get(otherEntity.getUniqueId());
        if (other == null)
            continue;
        if (stackSettings.testCanStackWith(stackedEntity, other, false) && (!Setting.ENTITY_REQUIRE_LINE_OF_SIGHT.getBoolean() || EntityUtils.hasLineOfSight(entity, otherEntity, 0.75, false)) && WorldGuardHook.testLocation(otherEntity.getLocation()))
            targetEntities.add(other);
    }
    StackedEntity increased;
    int totalSize;
    List<StackedEntity> removable = new ArrayList<>(targetEntities.size());
    if (!Setting.ENTITY_MIN_STACK_COUNT_ONLY_INDIVIDUALS.getBoolean()) {
        increased = targetEntities.stream().max(StackedEntity::compareTo).orElse(stackedEntity);
        targetEntities.remove(increased);
        totalSize = increased.getStackSize();
        for (StackedEntity target : targetEntities) {
            if (totalSize + target.getStackSize() <= stackSettings.getMaxStackSize()) {
                totalSize += target.getStackSize();
                removable.add(target);
            }
        }
    } else {
        increased = stackedEntity;
        targetEntities.remove(increased);
        totalSize = 1;
        int totalStackSize = increased.getStackSize();
        for (StackedEntity target : targetEntities) {
            if (totalStackSize + target.getStackSize() <= stackSettings.getMaxStackSize()) {
                totalSize++;
                totalStackSize += target.getStackSize();
                removable.add(target);
            }
        }
    }
    if (removable.isEmpty() || totalSize < stackSettings.getMinStackSize())
        return;
    EntityStackEvent entityStackEvent = new EntityStackEvent(removable, increased);
    Bukkit.getPluginManager().callEvent(entityStackEvent);
    if (entityStackEvent.isCancelled())
        return;
    for (StackedEntity toStack : removable) {
        stackSettings.applyStackProperties(toStack.getEntity(), increased.getEntity());
        increased.increaseStackSize(toStack.getEntity());
        increased.increaseStackSize(toStack.getStackedEntityNBT());
        this.removeEntityStack(toStack);
    }
    Runnable removeTask = () -> removable.stream().map(StackedEntity::getEntity).forEach(Entity::remove);
    if (Bukkit.isPrimaryThread()) {
        removeTask.run();
    } else {
        Bukkit.getScheduler().runTask(this.rosePlugin, removeTask);
    }
}
Also used : EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) StackedEntityDataEntry(dev.rosewood.rosestacker.nms.storage.StackedEntityDataEntry) EntityUtils(dev.rosewood.rosestacker.utils.EntityUtils) Player(org.bukkit.entity.Player) ItemUtils(dev.rosewood.rosestacker.utils.ItemUtils) PreDropStackedItemsEvent(dev.rosewood.rosestacker.event.PreDropStackedItemsEvent) EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) Block(org.bukkit.block.Block) Location(org.bukkit.Location) World(org.bukkit.World) Map(java.util.Map) PersistentDataUtils(dev.rosewood.rosestacker.utils.PersistentDataUtils) Chunk(org.bukkit.Chunk) ItemStackSettings(dev.rosewood.rosestacker.stack.settings.ItemStackSettings) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) Setting(dev.rosewood.rosestacker.manager.ConfigurationManager.Setting) Entity(org.bukkit.entity.Entity) Predicate(java.util.function.Predicate) ItemStackClearEvent(dev.rosewood.rosestacker.event.ItemStackClearEvent) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) EntityCacheManager(dev.rosewood.rosestacker.manager.EntityCacheManager) Collectors(java.util.stream.Collectors) RosePlugin(dev.rosewood.rosegarden.RosePlugin) EntityUnstackEvent(dev.rosewood.rosestacker.event.EntityUnstackEvent) StackedEntityDataStorage(dev.rosewood.rosestacker.nms.storage.StackedEntityDataStorage) ItemStack(org.bukkit.inventory.ItemStack) Objects(java.util.Objects) StackManager(dev.rosewood.rosestacker.manager.StackManager) List(java.util.List) Entry(java.util.Map.Entry) BukkitTask(org.bukkit.scheduler.BukkitTask) Optional(java.util.Optional) StackerUtils(dev.rosewood.rosestacker.utils.StackerUtils) NPCsHook(dev.rosewood.rosestacker.hook.NPCsHook) DustOptions(org.bukkit.Particle.DustOptions) Item(org.bukkit.entity.Item) WorldGuardHook(dev.rosewood.rosestacker.hook.WorldGuardHook) HashMap(java.util.HashMap) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) DataUtils(dev.rosewood.rosestacker.utils.DataUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemStackEvent(dev.rosewood.rosestacker.event.ItemStackEvent) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) SpawnReason(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason) CreatureSpawner(org.bukkit.block.CreatureSpawner) Particle(org.bukkit.Particle) Vector(org.bukkit.util.Vector) EntityStackEvent(dev.rosewood.rosestacker.event.EntityStackEvent) EntityStackClearEvent(dev.rosewood.rosestacker.event.EntityStackClearEvent) ArmorStand(org.bukkit.entity.ArmorStand) NMSAdapter(dev.rosewood.rosestacker.nms.NMSAdapter) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) EntityStackEvent(dev.rosewood.rosestacker.event.EntityStackEvent) ArrayList(java.util.ArrayList) LivingEntity(org.bukkit.entity.LivingEntity) HashSet(java.util.HashSet)

Example 3 with EntityStackSettings

use of dev.rosewood.rosestacker.stack.settings.EntityStackSettings in project RoseStacker by Rosewood-Development.

the class MobSpawningMethod method spawnEntitiesIntoNearbyStacks.

private int spawnEntitiesIntoNearbyStacks(StackedSpawner stackedSpawner, int spawnAmount, Set<Location> locations, List<StackedEntity> nearbyEntities, StackManager stackManager) {
    EntityStackSettings entityStackSettings = RoseStacker.getInstance().getManager(StackSettingManager.class).getEntityStackSettings(this.entityType);
    List<StackedEntity> stackedEntities = new ArrayList<>(nearbyEntities);
    List<Location> possibleLocations = new ArrayList<>(locations);
    if (this.entityType.getEntityClass() == null)
        return 0;
    boolean ageable = Ageable.class.isAssignableFrom(this.entityType.getEntityClass());
    int successfulSpawns = 0;
    if (stackManager.isEntityStackingEnabled() && entityStackSettings.isStackingEnabled() && Setting.SPAWNER_SPAWN_INTO_NEARBY_STACKS.getBoolean()) {
        List<StackedEntity> newStacks = new ArrayList<>();
        NMSHandler nmsHandler = NMSAdapter.getHandler();
        for (int i = 0; i < spawnAmount; i++) {
            if (possibleLocations.isEmpty())
                break;
            Location location = possibleLocations.get(this.random.nextInt(possibleLocations.size()));
            LivingEntity entity = nmsHandler.createNewEntityUnspawned(this.entityType, location, CreatureSpawnEvent.SpawnReason.SPAWNER);
            SpawnerFlagPersistenceHook.flagSpawnerSpawned(entity);
            if (ageable)
                ((Ageable) entity).setAdult();
            if ((stackedSpawner.getStackSettings().isMobAIDisabled() && (!Setting.SPAWNER_DISABLE_MOB_AI_ONLY_PLAYER_PLACED.getBoolean() || stackedSpawner.isPlacedByPlayer())) || Setting.ENTITY_DISABLE_ALL_MOB_AI.getBoolean())
                PersistentDataUtils.removeEntityAi(entity);
            PersistentDataUtils.tagSpawnedFromSpawner(entity);
            entityStackSettings.applySpawnerSpawnedProperties(entity);
            StackedEntity newStack = new StackedEntity(entity);
            Optional<StackedEntity> matchingEntity = stackedEntities.stream().filter(x -> WorldGuardHook.testLocation(x.getLocation()) && entityStackSettings.testCanStackWith(x, newStack, false, true)).findFirst();
            if (matchingEntity.isPresent()) {
                matchingEntity.get().increaseStackSize(entity);
            } else {
                stackedEntities.add(newStack);
                newStacks.add(newStack);
                possibleLocations.remove(location);
            }
            successfulSpawns++;
        }
        Bukkit.getScheduler().runTask(RoseStacker.getInstance(), () -> {
            stackManager.setEntityStackingTemporarilyDisabled(true);
            for (StackedEntity stackedEntity : newStacks) {
                LivingEntity entity = stackedEntity.getEntity();
                SpawnerSpawnEvent spawnerSpawnEvent = new SpawnerSpawnEvent(entity, stackedSpawner.getSpawner());
                Bukkit.getPluginManager().callEvent(spawnerSpawnEvent);
                if (spawnerSpawnEvent.isCancelled())
                    continue;
                nmsHandler.spawnExistingEntity(stackedEntity.getEntity(), CreatureSpawnEvent.SpawnReason.SPAWNER, Setting.SPAWNER_BYPASS_REGION_SPAWNING_RULES.getBoolean());
                entity.setVelocity(Vector.getRandom().multiply(0.01));
                stackManager.addEntityStack(stackedEntity);
            }
            stackManager.setEntityStackingTemporarilyDisabled(false);
            // Spawn particles for new entities and update nametags
            for (StackedEntity entity : newStacks) {
                entity.updateDisplay();
                World world = entity.getLocation().getWorld();
                if (world != null)
                    world.spawnParticle(Particle.EXPLOSION_NORMAL, entity.getLocation().clone().add(0, 0.75, 0), 5, 0.25, 0.25, 0.25, 0.01);
            }
        });
    } else {
        successfulSpawns = Math.min(spawnAmount, possibleLocations.size());
        Bukkit.getScheduler().runTask(RoseStacker.getInstance(), () -> {
            NMSHandler nmsHandler = NMSAdapter.getHandler();
            for (int i = 0; i < spawnAmount; i++) {
                if (possibleLocations.isEmpty())
                    break;
                Location location = possibleLocations.remove(this.random.nextInt(possibleLocations.size()));
                World world = location.getWorld();
                if (world == null)
                    continue;
                LivingEntity entity = nmsHandler.spawnEntityWithReason(this.entityType, location, CreatureSpawnEvent.SpawnReason.SPAWNER, Setting.SPAWNER_BYPASS_REGION_SPAWNING_RULES.getBoolean());
                entityStackSettings.applySpawnerSpawnedProperties(entity);
                SpawnerFlagPersistenceHook.flagSpawnerSpawned(entity);
                SpawnerSpawnEvent spawnerSpawnEvent = new SpawnerSpawnEvent(entity, stackedSpawner.getSpawner());
                Bukkit.getPluginManager().callEvent(spawnerSpawnEvent);
                if (spawnerSpawnEvent.isCancelled()) {
                    entity.remove();
                    continue;
                }
                // Spawn Particles
                if (entity.isValid())
                    entity.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, entity.getLocation().clone().add(0, 0.75, 0), 5, 0.25, 0.25, 0.25, 0.01);
            }
        });
    }
    return successfulSpawns;
}
Also used : EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) RoseStacker(dev.rosewood.rosestacker.RoseStacker) WorldGuardHook(dev.rosewood.rosestacker.hook.WorldGuardHook) StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) NoneConditionTag(dev.rosewood.rosestacker.spawner.conditions.tags.NoneConditionTag) Random(java.util.Random) SpawnerSpawnEvent(org.bukkit.event.entity.SpawnerSpawnEvent) StackedSpawner(dev.rosewood.rosestacker.stack.StackedSpawner) ArrayList(java.util.ArrayList) EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) HashSet(java.util.HashSet) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) Block(org.bukkit.block.Block) Location(org.bukkit.Location) NotPlayerPlacedConditionTag(dev.rosewood.rosestacker.spawner.conditions.tags.NotPlayerPlacedConditionTag) World(org.bukkit.World) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) StackedSpawnerTile(dev.rosewood.rosestacker.nms.spawner.StackedSpawnerTile) PersistentDataUtils(dev.rosewood.rosestacker.utils.PersistentDataUtils) Material(org.bukkit.Material) Ageable(org.bukkit.entity.Ageable) Bukkit(org.bukkit.Bukkit) Setting(dev.rosewood.rosestacker.manager.ConfigurationManager.Setting) ConditionTag(dev.rosewood.rosestacker.spawner.conditions.ConditionTag) Entity(org.bukkit.entity.Entity) Predicate(java.util.function.Predicate) CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent) Collection(java.util.Collection) Set(java.util.Set) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) EntityCacheManager(dev.rosewood.rosestacker.manager.EntityCacheManager) Collectors(java.util.stream.Collectors) Particle(org.bukkit.Particle) Vector(org.bukkit.util.Vector) StackManager(dev.rosewood.rosestacker.manager.StackManager) SpawnerFlagPersistenceHook(dev.rosewood.rosestacker.hook.SpawnerFlagPersistenceHook) List(java.util.List) Optional(java.util.Optional) StackerUtils(dev.rosewood.rosestacker.utils.StackerUtils) NMSAdapter(dev.rosewood.rosestacker.nms.NMSAdapter) SpawnerStackSettings(dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings) StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) ArrayList(java.util.ArrayList) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) SpawnerSpawnEvent(org.bukkit.event.entity.SpawnerSpawnEvent) World(org.bukkit.World) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) LivingEntity(org.bukkit.entity.LivingEntity) Location(org.bukkit.Location)

Example 4 with EntityStackSettings

use of dev.rosewood.rosestacker.stack.settings.EntityStackSettings in project RoseStacker by Rosewood-Development.

the class ItemUtils method getEntityAsStackedItemStack.

public static ItemStack getEntityAsStackedItemStack(EntityType entityType, int amount) {
    EntityStackSettings stackSettings = RoseStacker.getInstance().getManager(StackSettingManager.class).getEntityStackSettings(entityType);
    Material spawnEggMaterial = stackSettings.getEntityTypeData().getSpawnEggMaterial();
    if (spawnEggMaterial == null)
        return null;
    ItemStack itemStack = new ItemStack(spawnEggMaterial);
    if (amount == 1)
        return itemStack;
    ItemMeta itemMeta = itemStack.getItemMeta();
    if (itemMeta == null)
        return itemStack;
    StringPlaceholders placeholders = StringPlaceholders.builder("amount", amount).addPlaceholder("name", stackSettings.getDisplayName()).build();
    String displayString = RoseStacker.getInstance().getManager(LocaleManager.class).getLocaleMessage("entity-stack-display-spawn-egg", placeholders);
    itemMeta.setDisplayName(displayString);
    // Set the lore, if defined
    List<String> lore = RoseStacker.getInstance().getManager(LocaleManager.class).getLocaleMessages("stack-item-lore-entity", placeholders);
    if (!lore.isEmpty())
        itemMeta.setLore(lore);
    itemStack.setItemMeta(itemMeta);
    // Set stack size
    NMSHandler nmsHandler = NMSAdapter.getHandler();
    itemStack = nmsHandler.setItemStackNBT(itemStack, "StackSize", amount);
    return itemStack;
}
Also used : EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) StringPlaceholders(dev.rosewood.rosegarden.utils.StringPlaceholders) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) Material(org.bukkit.Material) LocaleManager(dev.rosewood.rosestacker.manager.LocaleManager) ItemStack(org.bukkit.inventory.ItemStack) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 5 with EntityStackSettings

use of dev.rosewood.rosestacker.stack.settings.EntityStackSettings in project RoseStacker by Rosewood-Development.

the class BreedingListener method onBreed.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBreed(PlayerInteractEntityEvent event) {
    Entity entity = event.getRightClicked();
    if (!Setting.ENTITY_CUMULATIVE_BREEDING.getBoolean() || !(entity instanceof Animals))
        return;
    Animals animal = (Animals) entity;
    if (!animal.canBreed())
        return;
    StackManager stackManager = this.rosePlugin.getManager(StackManager.class);
    if (!stackManager.isEntityStackingEnabled())
        return;
    StackedEntity stackedEntity = stackManager.getStackedEntity(animal);
    if (stackedEntity == null)
        return;
    Player player = event.getPlayer();
    EntityStackSettings stackSettings = stackedEntity.getStackSettings();
    ItemStack breedingItem = player.getInventory().getItem(event.getHand());
    if (!stackSettings.getEntityTypeData().isValidBreedingMaterial(breedingItem.getType()) || (player.getGameMode() != GameMode.CREATIVE && breedingItem.getAmount() < 2))
        return;
    if (PersistentDataUtils.isAiDisabled(animal) && Setting.SPAWNER_DISABLE_MOB_AI_OPTIONS_DISABLE_BREEDING.getBoolean()) {
        event.setCancelled(true);
        return;
    }
    int stackSize = stackedEntity.getStackSize();
    if (stackSize < 2)
        return;
    Class<? extends Entity> entityClass = animal.getType().getEntityClass();
    if (entityClass == null)
        return;
    event.setCancelled(true);
    // Take the items for breeding
    int totalChildren;
    if (player.getGameMode() != GameMode.CREATIVE) {
        int requiredFood = Math.min(stackSize, breedingItem.getAmount());
        breedingItem.setAmount(breedingItem.getAmount() - requiredFood);
        totalChildren = requiredFood / 2;
    } else {
        // Creative mode should allow the entire stack to breed half as many babies as the total size
        totalChildren = stackSize / 2;
    }
    // Reset breeding timer and play the breeding effect
    animal.setAge(6000);
    animal.setBreedCause(player.getUniqueId());
    animal.playEffect(EntityEffect.LOVE_HEARTS);
    boolean disableAi = PersistentDataUtils.isAiDisabled(animal);
    // Drop experience and spawn entities a few ticks later
    int f_totalChildren = totalChildren;
    Bukkit.getScheduler().runTaskLater(this.rosePlugin, () -> {
        for (int i = 0; i < f_totalChildren; i++) animal.getWorld().spawn(animal.getLocation(), entityClass, x -> {
            Ageable baby = (Ageable) x;
            baby.setBaby();
            if (disableAi)
                PersistentDataUtils.removeEntityAi(baby);
        });
        StackerUtils.dropExperience(animal.getLocation(), totalChildren, 7 * totalChildren, totalChildren);
    }, 30);
}
Also used : EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) Setting(dev.rosewood.rosestacker.manager.ConfigurationManager.Setting) EntityEffect(org.bukkit.EntityEffect) Entity(org.bukkit.entity.Entity) StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) Animals(org.bukkit.entity.Animals) Player(org.bukkit.entity.Player) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) RosePlugin(dev.rosewood.rosegarden.RosePlugin) ItemStack(org.bukkit.inventory.ItemStack) EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) EventHandler(org.bukkit.event.EventHandler) StackManager(dev.rosewood.rosestacker.manager.StackManager) GameMode(org.bukkit.GameMode) EventPriority(org.bukkit.event.EventPriority) PersistentDataUtils(dev.rosewood.rosestacker.utils.PersistentDataUtils) StackerUtils(dev.rosewood.rosestacker.utils.StackerUtils) Ageable(org.bukkit.entity.Ageable) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) Entity(org.bukkit.entity.Entity) StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) Player(org.bukkit.entity.Player) Animals(org.bukkit.entity.Animals) StackManager(dev.rosewood.rosestacker.manager.StackManager) ItemStack(org.bukkit.inventory.ItemStack) Ageable(org.bukkit.entity.Ageable) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EntityStackSettings (dev.rosewood.rosestacker.stack.settings.EntityStackSettings)9 StackManager (dev.rosewood.rosestacker.manager.StackManager)6 StackSettingManager (dev.rosewood.rosestacker.manager.StackSettingManager)6 Material (org.bukkit.Material)6 EntityType (org.bukkit.entity.EntityType)6 StackerUtils (dev.rosewood.rosestacker.utils.StackerUtils)5 Bukkit (org.bukkit.Bukkit)5 Block (org.bukkit.block.Block)5 ItemStack (org.bukkit.inventory.ItemStack)5 RosePlugin (dev.rosewood.rosegarden.RosePlugin)4 Setting (dev.rosewood.rosestacker.manager.ConfigurationManager.Setting)4 NMSHandler (dev.rosewood.rosestacker.nms.NMSHandler)4 PersistentDataUtils (dev.rosewood.rosestacker.utils.PersistentDataUtils)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Entity (org.bukkit.entity.Entity)4 LivingEntity (org.bukkit.entity.LivingEntity)4 Location (org.bukkit.Location)3