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());
}
Aggregations