Search in sources :

Example 1 with ChickenStackSettings

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

the class EntityListener method onChickenLayEgg.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onChickenLayEgg(EntityDropItemEvent event) {
    if (event.getEntityType() != EntityType.CHICKEN || event.getItemDrop().getItemStack().getType() != Material.EGG)
        return;
    if (this.stackManager.isWorldDisabled(event.getEntity().getWorld()))
        return;
    if (!this.stackManager.isEntityStackingEnabled())
        return;
    Chicken chickenEntity = (Chicken) event.getEntity();
    StackedEntity stackedEntity = this.stackManager.getStackedEntity(chickenEntity);
    if (stackedEntity == null || stackedEntity.getStackSize() == 1)
        return;
    ChickenStackSettings chickenStackSettings = (ChickenStackSettings) stackedEntity.getStackSettings();
    if (!chickenStackSettings.shouldMultiplyEggDropsByStackSize())
        return;
    event.getItemDrop().remove();
    List<ItemStack> items = GuiUtil.getMaterialAmountAsItemStacks(Material.EGG, stackedEntity.getStackSize());
    this.stackManager.preStackItems(items, event.getEntity().getLocation());
}
Also used : StackedEntity(dev.rosewood.rosestacker.stack.StackedEntity) ChickenStackSettings(dev.rosewood.rosestacker.stack.settings.entity.ChickenStackSettings) Chicken(org.bukkit.entity.Chicken) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Aggregations

StackedEntity (dev.rosewood.rosestacker.stack.StackedEntity)1 ChickenStackSettings (dev.rosewood.rosestacker.stack.settings.entity.ChickenStackSettings)1 Chicken (org.bukkit.entity.Chicken)1 EventHandler (org.bukkit.event.EventHandler)1 ItemStack (org.bukkit.inventory.ItemStack)1