Search in sources :

Example 6 with IPipeContentsEditableItem

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();
    }
}
Also used : IPipeContentsEditableItem(buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem) BCPipeEventHandler(buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)

Aggregations

IPipeContentsEditableItem (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem)6 BCPipeEventHandler (buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 EnumContentsJourneyPart (buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart)1 IConnection_BC8 (buildcraft.api.transport.pipe_bc8.IConnection_BC8)1 IExtractable_BC8 (buildcraft.api.transport.pipe_bc8.IExtractionManager.IExtractable_BC8)1 IInsertable_BC8 (buildcraft.api.transport.pipe_bc8.IInsertionManager.IInsertable_BC8)1 IPipeContentsEditable (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable)1 IPipeContentsEditableFluid (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableFluid)1 IPipePropertyProviderEditable (buildcraft.api.transport.pipe_bc8.IPipePropertyProvider.IPipePropertyProviderEditable)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1