mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-26 02:17:38 +01:00
fix for picking up
This commit is contained in:
parent
9ddb73ebc5
commit
37477d4263
@ -25,7 +25,6 @@ public class InteractListeners implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAccept(InventoryPickupItemEvent event) {
|
public void onAccept(InventoryPickupItemEvent event) {
|
||||||
Bukkit.broadcastMessage("pickup");
|
|
||||||
ItemStack item = event.getItem().getItemStack();
|
ItemStack item = event.getItem().getItemStack();
|
||||||
instance.getStackingTask().setMax(item, 0, true);
|
instance.getStackingTask().setMax(item, 0, true);
|
||||||
int amt = item.getAmount();
|
int amt = item.getAmount();
|
||||||
@ -54,8 +53,34 @@ public class InteractListeners implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPickup(EntityPickupItemEvent event) {
|
public void onPickup(EntityPickupItemEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player)) return;
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
|
||||||
event.getItem().setItemStack(instance.getStackingTask().setMax(event.getItem().getItemStack(), 0, true));
|
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
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user