use of buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem in project BuildCraft by BuildCraft.
the class PipeTransportItem_BC8 method itemInsertion.
@BCPipeEventHandler
public void itemInsertion(IPipeEventContents_BC8.Enter enter) {
// If somebody else has already handled this then don't even bother to handle it
if (enter.hasBeenHandled())
return;
// if we are the limit then don't add it either
int stacks = enter.getPipe().getProperties().getValue(PipeAPI_BC8.STACK_COUNT);
// Note that a travelling item will probably add it to itself at this point.
if (stacks >= PipeTransportItems.MAX_PIPE_STACKS)
return;
// Setup the item to make it tick immediately
IPipeContentsEditableItem item = (IPipeContentsEditableItem) enter.getContents();
item.setJourneyPart(EnumContentsJourneyPart.JUST_ENTERED);
item.setDirection(enter.getFrom().getOpposite());
long now = pipe.getWorld().getTotalWorldTime();
TravellingItem_BC8 travellingItem = new TravellingItem_BC8(pipe, item, now, now);
/* Actually add the item to the bus, which will make it render itself, tick itself, send client updates, etc. */
if (pipe.addEventListener(travellingItem)) {
// Tell the event that we have consumed the item, but only if it was actually added to the bus
enter.handle();
}
}
Aggregations