use of buildcraft.api.transport.pipe.PipeEventHandler in project BuildCraft by BuildCraft.
the class FilterEventHandler method sideCheck.
@PipeEventHandler
public static void sideCheck(PipeEventItem.SideCheck event) {
for (EnumFacing side : EnumFacing.VALUES) {
if (!event.isAllowed(side)) {
continue;
}
IPipe neighbour = event.holder.getNeighbourPipe(side);
if (neighbour == null) {
continue;
}
PipePluggable neighbourPlug = neighbour.getHolder().getPluggable(side.getOpposite());
PipePluggable atPlug = event.holder.getPluggable(side);
if (neighbourPlug instanceof PluggableLens) {
EnumDyeColor colourAt = event.colour;
if (atPlug instanceof PluggableLens) {
PluggableLens lens = (PluggableLens) atPlug;
if (!lens.isFilter) {
colourAt = lens.colour;
}
}
PluggableLens lens = (PluggableLens) neighbourPlug;
if (lens.isFilter) {
if (colourAt == lens.colour) {
event.increasePriority(side);
} else if (colourAt == null) {
event.decreasePriority(side);
}
}
}
}
}
use of buildcraft.api.transport.pipe.PipeEventHandler in project BuildCraft by BuildCraft.
the class PipeBehaviourStripes method onDrop.
@PipeEventHandler
public void onDrop(PipeEventItem.Drop event) {
if (direction == null) {
return;
}
IPipeHolder holder = pipe.getHolder();
World world = holder.getPipeWorld();
BlockPos pos = holder.getPipePos();
FakePlayer player = BuildCraftAPI.fakePlayerProvider.getFakePlayer((WorldServer) world, holder.getOwner(), pos);
player.inventory.clear();
// set the main hand of the fake player to the stack
player.inventory.setInventorySlotContents(player.inventory.currentItem, event.getStack());
if (PipeApi.stripeRegistry.handleItem(world, pos, direction, event.getStack(), player, this)) {
event.setStack(StackUtil.EMPTY);
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stack = player.inventory.removeStackFromSlot(i);
if (!stack.isEmpty()) {
sendItem(stack, direction);
}
}
}
}
Aggregations