mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-27 04:25:21 +01:00
Wrong amount of eggs.
This commit is contained in:
parent
8122dd24d6
commit
667063a816
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user