Advertisement
broken-arrow

Untitled

Jun 24th, 2021
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1.     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  2.     public void fromChestCustomHopper(InventoryMoveItemEvent event) {
  3.         if (event.getDestination().getHolder() instanceof Hopper) {
  4.             ChestRegistry registry = ChestRegistry.getInstance();
  5.             Location location = event.getDestination().getLocation();
  6.             if (!craftingrecipes(location, event.getItem()) && registry.isRegistered(location) && registry.getTypeofContainer(location).equals(ChestRegistry.TypeOfContainer.LINKEDCONTAINER)) {
  7.                 event.setCancelled(true);
  8.                 int numberOfItems = event.getItem().getAmount();
  9.                
  10.  
  11.                 for (int i = 0; i < event.getSource().getSize(); i++) {
  12.                     ItemStack items = event.getSource().getItem(i);
  13.                     if (items != null && craftingrecipes(location, items)) {
  14.                         ItemStack itemsstack = items.clone();
  15.                         int totalofItems = Math.min(numberOfItems, items.getAmount());
  16.                         itemsstack.setAmount(totalofItems);
  17.                         items.setAmount(items.getAmount() - totalofItems);
  18.                         if (items.getAmount() == 0)
  19.                             event.getSource().setItem(i, new ItemStack(CompMaterial.AIR.toItem()));
  20.  
  21.                         //System.out.println(event.getItem());
  22.                         //System.out.println(Arrays.toString(registry.getFiltreritems(location)));
  23.                         event.getDestination().addItem(itemsstack);
  24.                         break;
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement