use of buildcraft.api.transport.pipe.IFlowItems in project BuildCraft by BuildCraft.
the class GuiDiamondWoodPipe method initGui.
@Override
public void initGui() {
super.initGui();
this.whiteListButton = new GuiImageButton(mainGui, WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, 18, TEXTURE_BUTTON, 19, 19);
this.whiteListButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.whitelist"));
this.whiteListButton.registerListener(this);
this.mainGui.shownElements.add(this.whiteListButton);
this.blackListButton = new GuiImageButton(mainGui, BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, 18, TEXTURE_BUTTON, 37, 19);
this.blackListButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.blacklist"));
this.blackListButton.registerListener(this);
this.mainGui.shownElements.add(this.blackListButton);
if (pipe.pipe.getFlow() instanceof IFlowItems) {
// Don't show round robin for the fluid pipe - its not yet implemented
this.roundRobinButton = new GuiImageButton(mainGui, ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, 18, TEXTURE_BUTTON, 55, 19);
this.roundRobinButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.roundrobin"));
this.roundRobinButton.registerListener(this);
this.mainGui.shownElements.add(this.roundRobinButton);
IButtonBehaviour.createAndSetRadioButtons(whiteListButton, blackListButton, roundRobinButton);
} else {
IButtonBehaviour.createAndSetRadioButtons(whiteListButton, blackListButton);
}
switch(pipe.filterMode) {
case WHITE_LIST:
this.whiteListButton.activate();
break;
case BLACK_LIST:
this.blackListButton.activate();
break;
case ROUND_ROBIN:
if (roundRobinButton != null) {
this.roundRobinButton.activate();
}
break;
}
}
use of buildcraft.api.transport.pipe.IFlowItems in project BuildCraft by BuildCraft.
the class TilePipeHolder method onPlacedBy.
// Misc
@Override
public void onPlacedBy(EntityLivingBase placer, ItemStack stack) {
super.onPlacedBy(placer, stack);
Item item = stack.getItem();
if (item instanceof IItemPipe) {
PipeDefinition definition = ((IItemPipe) item).getDefinition();
this.pipe = new Pipe(this, definition);
eventBus.registerHandler(pipe.behaviour);
eventBus.registerHandler(pipe.flow);
if (pipe.flow instanceof IFlowItems) {
eventBus.registerHandler(FilterEventHandler.class);
}
int meta = stack.getMetadata();
if (meta > 0 && meta <= 16) {
pipe.setColour(EnumDyeColor.byMetadata(meta - 1));
}
}
scheduleRenderUpdate();
}
use of buildcraft.api.transport.pipe.IFlowItems in project BuildCraft by BuildCraft.
the class PluggablePulsar method onTick.
@Override
public void onTick() {
if (holder.getPipeWorld().isRemote) {
if (isPulsing) {
pulseStage++;
if (pulseStage == PULSE_STAGE) {
pulseStage = 0;
}
} else {
// pulseStage--;
// if (pulseStage < 0) {
pulseStage = 0;
// }
}
setModelVariables(1);
clientModelData.tick();
return;
}
boolean isOn = isPulsing();
if (isOn) {
pulseStage++;
} else {
// pulseStage--;
// if (pulseStage < 0) {
pulseStage = 0;
// }
}
if (gateEnabledTicks > 0) {
gateEnabledTicks--;
}
if (pulseStage == PULSE_STAGE) {
pulseStage = 0;
IMjRedstoneReceiver rsRec = (IMjRedstoneReceiver) holder.getPipe().getBehaviour();
if (gateSinglePulses > 0) {
long power = MjAPI.MJ;
if (holder.getPipe().getFlow() instanceof IFlowFluid) {
// Special extration logic for fluids:
// Always extract either 1 bucket, or nothing.
power = BCTransportConfig.mjPerMillibucket * 1000;
} else if (holder.getPipe().getFlow() instanceof IFlowItems) {
power = BCTransportConfig.mjPerItem;
} else {
power = MjAPI.MJ;
}
long excess = rsRec.receivePower(power, true);
if (excess == 0) {
rsRec.receivePower(power, false);
} else {
// Nothing was extracted, so lets extract in the future
gateSinglePulses++;
// ParticleUtil.spawnFailureParticles
}
} else {
rsRec.receivePower(MjAPI.MJ, false);
}
if (gateSinglePulses > 0) {
gateSinglePulses--;
}
}
if (isOn != lastPulsing) {
lastPulsing = isOn;
scheduleNetworkUpdate();
}
}
use of buildcraft.api.transport.pipe.IFlowItems in project BuildCraft by BuildCraft.
the class PipeBehaviourWood method extract.
protected long extract(long power, boolean simulate) {
if (power > 0) {
if (pipe.getFlow() instanceof IFlowItems) {
IFlowItems flow = (IFlowItems) pipe.getFlow();
int maxItems = (int) (power / BCTransportConfig.mjPerItem);
if (maxItems > 0) {
int extracted = extractItems(flow, getCurrentDir(), maxItems, simulate);
if (extracted > 0) {
return power - extracted * BCTransportConfig.mjPerItem;
}
}
} else if (pipe.getFlow() instanceof IFlowFluid) {
IFlowFluid flow = (IFlowFluid) pipe.getFlow();
int maxMillibuckets = (int) (power / BCTransportConfig.mjPerMillibucket);
if (maxMillibuckets > 0) {
FluidStack extracted = extractFluid(flow, getCurrentDir(), maxMillibuckets, simulate);
if (extracted != null && extracted.amount > 0) {
return power - extracted.amount * BCTransportConfig.mjPerMillibucket;
}
}
}
}
return power;
}
use of buildcraft.api.transport.pipe.IFlowItems in project BuildCraft by BuildCraft.
the class PipeFlowItems method onItemReachEnd.
private void onItemReachEnd(TravellingItem item) {
IPipeHolder holder = pipe.getHolder();
PipeEventItem.ReachEnd reachEnd = new PipeEventItem.ReachEnd(holder, this, item.colour, item.stack, item.side);
holder.fireEvent(reachEnd);
item.colour = reachEnd.colour;
item.stack = reachEnd.getStack();
ItemStack excess = item.stack;
if (excess.isEmpty()) {
return;
}
if (pipe.isConnected(item.side)) {
ConnectedType type = pipe.getConnectedType(item.side);
EnumFacing oppositeSide = item.side.getOpposite();
switch(type) {
case PIPE:
{
IPipe oPipe = pipe.getConnectedPipe(item.side);
if (oPipe == null) {
break;
}
PipeFlow flow = oPipe.getFlow();
if (flow instanceof IFlowItems) {
IFlowItems oFlow = (IFlowItems) flow;
ItemStack before = excess;
excess = oFlow.injectItem(excess.copy(), true, oppositeSide, item.colour, item.speed);
if (!excess.isEmpty()) {
before.shrink(excess.getCount());
}
excess = fireEventEjectIntoPipe(oFlow, item.side, before, excess);
}
break;
}
case TILE:
{
TileEntity tile = pipe.getConnectedTile(item.side);
IInjectable injectable = ItemTransactorHelper.getInjectable(tile, oppositeSide);
ItemStack before = excess;
excess = injectable.injectItem(excess.copy(), true, oppositeSide, item.colour, item.speed);
if (!excess.isEmpty()) {
IItemTransactor transactor = ItemTransactorHelper.getTransactor(tile, oppositeSide);
excess = transactor.insert(excess, false, false);
}
excess = fireEventEjectIntoTile(tile, item.side, before, excess);
break;
}
}
}
if (excess.isEmpty()) {
return;
}
item.tried.add(item.side);
item.toCenter = true;
item.stack = excess;
item.genTimings(holder.getPipeWorld().getTotalWorldTime(), getPipeLength(item.side));
items.add(item.timeToDest, item);
sendItemDataToClient(item);
}
Aggregations