Skip to content
Permalink
Browse files

Add event for ranged collectors that has item entity

  • Loading branch information...
BillyGalbreath authored and me4502 committed Aug 3, 2019
1 parent a77d3b4 commit 6d54ef3aab5f1ef16f3aaadf60ac591be1d3d9c1
@@ -8,7 +8,7 @@
import com.sk89q.craftbook.mechanics.ic.ChipState;
import com.sk89q.craftbook.mechanics.ic.IC;
import com.sk89q.craftbook.mechanics.ic.ICFactory;
import com.sk89q.craftbook.mechanics.pipe.PipeRequestEvent;
import com.sk89q.craftbook.mechanics.ranged.RangedCollectEvent;
import com.sk89q.craftbook.util.ICUtil;
import com.sk89q.craftbook.util.InventoryUtil;
import com.sk89q.craftbook.util.ItemSyntax;
@@ -136,7 +136,7 @@ public boolean collect() {
BlockFace back = SignUtil.getBack(CraftBookBukkitUtil.toSign(getSign()).getBlock());
Block pipe = getBackBlock().getRelative(back);

PipeRequestEvent event = new PipeRequestEvent(pipe, new ArrayList<>(Collections.singletonList(stack)), getBackBlock());
RangedCollectEvent event = new RangedCollectEvent(pipe, (Item) entity, new ArrayList<>(Collections.singletonList(stack)), getBackBlock());
Bukkit.getPluginManager().callEvent(event);

if (event.isCancelled()) {
@@ -0,0 +1,21 @@
package com.sk89q.craftbook.mechanics.ranged;

import com.sk89q.craftbook.mechanics.pipe.PipeRequestEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;

import java.util.List;

public class RangedCollectEvent extends PipeRequestEvent {
private final Item item;

public RangedCollectEvent(Block theBlock, Item item, List<ItemStack> itemstacks, Block sucked) {
super(theBlock, itemstacks, sucked);
this.item = item;
}

public Item getItem() {
return item;
}
}

0 comments on commit 6d54ef3

Please sign in to comment.
You can’t perform that action at this time.