Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void fromChestCustomHopper(InventoryMoveItemEvent event) {
- if (event.getDestination().getHolder() instanceof Hopper) {
- ChestRegistry registry = ChestRegistry.getInstance();
- Location location = event.getDestination().getLocation();
- if (!craftingrecipes(location, event.getItem()) && registry.isRegistered(location) && registry.getTypeofContainer(location).equals(ChestRegistry.TypeOfContainer.LINKEDCONTAINER)) {
- event.setCancelled(true);
- int numberOfItems = event.getItem().getAmount();
- for (int i = 0; i < event.getSource().getSize(); i++) {
- ItemStack items = event.getSource().getItem(i);
- if (items != null && craftingrecipes(location, items)) {
- ItemStack itemsstack = items.clone();
- int totalofItems = Math.min(numberOfItems, items.getAmount());
- itemsstack.setAmount(totalofItems);
- items.setAmount(items.getAmount() - totalofItems);
- if (items.getAmount() == 0)
- event.getSource().setItem(i, new ItemStack(CompMaterial.AIR.toItem()));
- //System.out.println(event.getItem());
- //System.out.println(Arrays.toString(registry.getFiltreritems(location)));
- event.getDestination().addItem(itemsstack);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement