fix for picking up

This commit is contained in:
Brianna O'Keefe 2018-11-21 17:08:34 -05:00
parent 9ddb73ebc5
commit 37477d4263

View File

@ -25,7 +25,6 @@ public class InteractListeners implements Listener {
@EventHandler
public void onAccept(InventoryPickupItemEvent event) {
Bukkit.broadcastMessage("pickup");
ItemStack item = event.getItem().getItemStack();
instance.getStackingTask().setMax(item, 0, true);
int amt = item.getAmount();
@ -54,8 +53,34 @@ public class InteractListeners implements Listener {
@EventHandler
public void onPickup(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player)) return;
event.getItem().setItemStack(instance.getStackingTask().setMax(event.getItem().getItemStack(), 0, true));
ItemStack item = event.getItem().getItemStack();
int amt = item.getAmount();
int max = item.getMaxStackSize();
if (amt <= max) return;
event.setCancelled(true);
item.setAmount(max);
amt = amt - max;
while (amt > max) {
ItemStack newItem = new ItemStack(item);
newItem.setAmount(max);
event.getItem().getWorld().dropItemNaturally(event.getItem().getLocation(), newItem);
amt = amt - max;
}
ItemStack newItem = new ItemStack(item);
newItem.setAmount(amt);
event.getItem().getWorld().dropItemNaturally(event.getItem().getLocation(), newItem);
}
@EventHandler