Wrong amount of eggs.

This commit is contained in:
Brianna O'Keefe 2019-03-07 14:44:28 -05:00
parent 8122dd24d6
commit 667063a816

View File

@ -49,6 +49,30 @@ public class EntityListeners implements Listener {
}
}
@EventHandler
public void onEgg(ItemSpawnEvent event) {
if (event.getEntity().getItemStack().getType() != Material.EGG) return;
Location location = event.getLocation();
List<Entity> entities = new ArrayList<>(location.getWorld().getNearbyEntities(location, .1, .5, .1));
if (entities.isEmpty()) return;
Entity entity = entities.get(0);
EntityStackManager stackManager = instance.getEntityStackManager();
if (!stackManager.isStacked(entity)) return;
EntityStack stack = stackManager.getStack(entity);
ItemStack item = event.getEntity().getItemStack();
item.setAmount((stack.getAmount() - 1) + item.getAmount() > item.getMaxStackSize() ? item.getMaxStackSize()
: item.getAmount() + (stack.getAmount() - 1));
event.getEntity().setItemStack(item);
}
@EventHandler
public void onPickup(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player)) return;