use of buildcraft.transport.tile.TilePipeHolder 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.transport.tile.TilePipeHolder in project BuildCraft by BuildCraft.
the class BlockPipeHolder method getSelectedBoundingBox.
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
TilePipeHolder tile = getPipe(world, pos, false);
if (tile == null) {
return FULL_BLOCK_AABB;
}
RayTraceResult trace = Minecraft.getMinecraft().objectMouseOver;
if (trace == null || trace.subHit < 0 || !pos.equals(trace.getBlockPos())) {
// Perhaps we aren't the object the mouse is over
return FULL_BLOCK_AABB;
}
int part = trace.subHit;
AxisAlignedBB aabb = FULL_BLOCK_AABB;
if (part == 0) {
aabb = BOX_CENTER;
} else if (part < 1 + 6) {
aabb = BOX_FACES[part - 1];
Pipe pipe = tile.getPipe();
if (pipe != null) {
EnumFacing face = EnumFacing.VALUES[part - 1];
float conSize = pipe.getConnectedDist(face);
if (conSize > 0 && conSize != 0.25f) {
Vec3d center = VecUtil.offset(new Vec3d(0.5, 0.5, 0.5), face, 0.25 + (conSize / 2));
Vec3d radius = new Vec3d(0.25, 0.25, 0.25);
radius = VecUtil.replaceValue(radius, face.getAxis(), conSize / 2);
Vec3d min = center.subtract(radius);
Vec3d max = center.add(radius);
aabb = BoundingBoxUtil.makeFrom(min, max);
}
}
} else if (part < 1 + 6 + 6) {
EnumFacing side = EnumFacing.VALUES[part - 1 - 6];
PipePluggable pluggable = tile.getPluggable(side);
if (pluggable != null) {
aabb = pluggable.getBoundingBox();
}
} else if (part < 1 + 6 + 6 + 8) {
EnumWirePart wirePart = EnumWirePart.VALUES[part - 1 - 6 - 6];
aabb = wirePart.boundingBox;
} else if (part < 1 + 6 + 6 + 6 + 8 + 36) {
EnumWireBetween wireBetween = EnumWireBetween.VALUES[part - 1 - 6 - 6 - 8];
aabb = wireBetween.boundingBox;
}
if (part >= 1 + 6 + 6) {
return aabb.offset(pos);
} else {
return (aabb == FULL_BLOCK_AABB ? aabb : aabb.grow(1 / 32.0)).offset(pos);
}
}
use of buildcraft.transport.tile.TilePipeHolder in project BuildCraft by BuildCraft.
the class BlockPipeHolder method attemptPaint.
// paint
@Override
public EnumActionResult attemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, EnumFacing hitSide, EnumDyeColor paintColour) {
TilePipeHolder tile = getPipe(world, pos, true);
if (tile == null) {
return EnumActionResult.PASS;
}
Pipe pipe = tile.getPipe();
if (pipe == null) {
return EnumActionResult.FAIL;
}
if (pipe.getColour() == paintColour || !pipe.definition.canBeColoured) {
return EnumActionResult.FAIL;
} else {
pipe.setColour(paintColour);
return EnumActionResult.SUCCESS;
}
}
use of buildcraft.transport.tile.TilePipeHolder in project BuildCraft by BuildCraft.
the class BlockPipeHolder method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
TilePipeHolder tile = getPipe(world, pos, false);
if (tile == null) {
return;
}
Pipe pipe = tile.getPipe();
if (pipe != null) {
pipe.getBehaviour().onEntityCollide(entity);
}
}
Aggregations