use of buildcraft.api.transport.pipe.PipeDefinition in project BuildCraft by BuildCraft.
the class BlockPipeHolder method getPickBlock.
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TilePipeHolder tile = getPipe(world, pos, false);
if (tile == null || target == null) {
return ItemStack.EMPTY;
}
if (target.subHit <= 6) {
Pipe pipe = tile.getPipe();
if (pipe != null) {
PipeDefinition def = pipe.getDefinition();
Item item = (Item) PipeApi.pipeRegistry.getItemForPipe(def);
if (item != null) {
int meta = pipe.getColour() == null ? 0 : pipe.getColour().getMetadata() + 1;
return new ItemStack(item, 1, meta);
}
}
} else if (target.subHit <= 12) {
int pluggableHit = target.subHit - 7;
EnumFacing face = EnumFacing.VALUES[pluggableHit];
PipePluggable plug = tile.getPluggable(face);
if (plug != null) {
return plug.getPickStack();
}
} else {
EnumWirePart part = null;
EnumWireBetween between = null;
if (target.subHit > 6) {
part = getWirePartHit(target);
between = getWireBetweenHit(target);
}
if (part != null && tile.wireManager.getColorOfPart(part) != null) {
return new ItemStack(BCTransportItems.wire, 1, tile.wireManager.getColorOfPart(part).getMetadata());
} else if (between != null && tile.wireManager.getColorOfPart(between.parts[0]) != null) {
return new ItemStack(BCTransportItems.wire, 1, tile.wireManager.getColorOfPart(between.parts[0]).getMetadata());
}
}
return ItemStack.EMPTY;
}
use of buildcraft.api.transport.pipe.PipeDefinition 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.PipeDefinition in project BuildCraft by BuildCraft.
the class SchematicBlockPipe method computeRequiredItems.
@Nonnull
@Override
public List<ItemStack> computeRequiredItems() {
try {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
PipeDefinition definition = PipeRegistry.INSTANCE.loadDefinition(tileNbt.getCompoundTag("pipe").getString("def"));
EnumDyeColor color = NBTUtilBC.readEnum(tileNbt.getCompoundTag("pipe").getTag("col"), EnumDyeColor.class);
Item item = (Item) PipeApi.pipeRegistry.getItemForPipe(definition);
if (item != null) {
builder.add(new ItemStack(item, 1, color == null ? 0 : color.getMetadata() + 1));
}
return builder.build();
} catch (InvalidInputDataException e) {
throw new RuntimeException(e);
}
}
Aggregations