Search in sources :

Example 1 with EnumContentsJourneyPart

use of buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart in project BuildCraft by BuildCraft.

the class TravellingItem_BC8 method tick.

@BCPipeEventHandler
public void tick(IPipeEvent_BC8.Tick tick) {
    if (item.getProperties().getValue(PipeAPI_BC8.ITEM_PAUSED)) {
        // Just so we render them properly, and so we need to stop this from ticking in the near future
        tickStarted++;
        tickFinished++;
        return;
    }
    if (tick instanceof IPipeEvent_BC8.Tick.Client)
        return;
    EnumContentsJourneyPart direction = item.getJourneyPart();
    if (direction == EnumContentsJourneyPart.JUST_ENTERED) {
        // Setup ourselves NOW, but tick the rest later
        double normalizedSpeed = item.getSpeed() * PipeTransportItem_BC8.SPEED_NORMALIZER;
        IPipeEventContents_BC8.ChangeSpeed changeSpeed = null;
        pipe.fireEvent(changeSpeed);
        // normalizedSpeed = changeSpeed.getNormalizedSpeed();
        item.setSpeed(normalizedSpeed / PipeTransportItem_BC8.SPEED_NORMALIZER);
        double distance = 0.25;
        IConnection_BC8 connection = pipe.getConnections().get(item.getDirection().getOpposite());
        if (connection != null)
            distance += connection.getLength();
        // generate our new timings (when we will next tick)
        genTimings(pipe.getWorld().getTotalWorldTime(), distance);
        // Update the client with our new timings
        pipe.sendClientUpdate(this);
        // Tick next tick not this tick
        return;
    }
    if (tick.getCurrentTick() < tickFinished)
        return;
    if (direction == EnumContentsJourneyPart.TO_CENTER) {
    // We need to find out where we are going, and the new speed of ourselves
    } else {
    /* We must be going to the end of the pipe, so we need to insert ourselves into the next pipe, or into an
             * inventory (if one exists) */
    }
}
Also used : IPipeEvent_BC8(buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEvent_BC8) EnumContentsJourneyPart(buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart) IConnection_BC8(buildcraft.api.transport.pipe_bc8.IConnection_BC8) IPipeEventContents_BC8(buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventContents_BC8) BCPipeEventHandler(buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)

Example 2 with EnumContentsJourneyPart

use of buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart in project BuildCraft by BuildCraft.

the class PipeContentsEditableItem method readFromNBT.

@Override
public IPipeContentsEditableItem readFromNBT(NBTBase nbt) {
    NBTTagCompound tag = (NBTTagCompound) nbt;
    ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("stack"));
    EnumContentsJourneyPart journeyPart = NBTUtilBC.readEnum(tag.getTag("journeyPart"), EnumContentsJourneyPart.class);
    EnumFacing direction = NBTUtilBC.readEnum(tag.getTag("direction"), EnumFacing.class);
    double speed = tag.getDouble("speed");
    IPipePropertyProviderEditable provider = propertyProvider.readFromNBT(tag.getTag("properties"));
    return new PipeContentsEditableItem(provider, stack, journeyPart, direction, speed);
}
Also used : IPipePropertyProviderEditable(buildcraft.api.transport.pipe_bc8.IPipePropertyProvider.IPipePropertyProviderEditable) IPipeContentsEditableItem(buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumContentsJourneyPart(buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumContentsJourneyPart (buildcraft.api.transport.pipe_bc8.EnumContentsJourneyPart)2 BCPipeEventHandler (buildcraft.api.transport.pipe_bc8.BCPipeEventHandler)1 IConnection_BC8 (buildcraft.api.transport.pipe_bc8.IConnection_BC8)1 IPipeContentsEditableItem (buildcraft.api.transport.pipe_bc8.IPipeContentsEditable.IPipeContentsEditableItem)1 IPipePropertyProviderEditable (buildcraft.api.transport.pipe_bc8.IPipePropertyProvider.IPipePropertyProviderEditable)1 IPipeEventContents_BC8 (buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventContents_BC8)1 IPipeEvent_BC8 (buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEvent_BC8)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumFacing (net.minecraft.util.EnumFacing)1