use of crazypants.enderio.conduits.conduit.redstone.IRedstoneConduit in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method getSelectedBoundingBox.
@Override
@SideOnly(Side.CLIENT)
@Nonnull
public AxisAlignedBB getSelectedBoundingBox(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos) {
TileConduitBundle te = getTileEntity(world, pos);
EntityPlayer player = Minecraft.getMinecraft().player;
if (te == null) {
// FIXME is this valid?
return new AxisAlignedBB(0, 0, 0, 0, 0, 0);
}
IConduitBundle con = te;
BoundingBox minBB = null;
if (!YetaUtil.isSolidFacadeRendered(con, player)) {
List<RaytraceResult> results = doRayTraceAll(world, pos, player);
Iterator<RaytraceResult> iter = results.iterator();
while (iter.hasNext()) {
CollidableComponent component = iter.next().component;
if (component != null && component.conduitType == null && component.data != ConduitConnectorType.EXTERNAL) {
iter.remove();
}
}
// This is an ugly special case, TODO fix this
for (RaytraceResult hit : results) {
IRedstoneConduit cond = con.getConduit(IRedstoneConduit.class);
CollidableComponent component = hit.component;
EnumFacing dir = component == null ? null : component.dir;
if (cond != null && component != null && dir != null && cond.getExternalConnections().contains(dir) && component.data == InsulatedRedstoneConduit.COLOR_CONTROLLER_ID) {
minBB = component.bound;
}
}
if (minBB == null) {
RaytraceResult hit = RaytraceResult.getClosestHit(Util.getEyePosition(player), results);
CollidableComponent component = hit == null ? null : hit.component;
if (component != null) {
EnumFacing dir = component.dir;
minBB = component.bound;
if (dir != null && component.conduitType == null) {
dir = dir.getOpposite();
float trans = 0.0125f;
minBB = minBB.translate(dir.getFrontOffsetX() * trans, dir.getFrontOffsetY() * trans, dir.getFrontOffsetZ() * trans);
float scale = 0.7f;
minBB = minBB.scale(1 + Math.abs(dir.getFrontOffsetX()) * scale, 1 + Math.abs(dir.getFrontOffsetY()) * scale, 1 + Math.abs(dir.getFrontOffsetZ()) * scale);
} else {
minBB = minBB.scale(1.09, 1.09, 1.09);
}
}
}
} else {
minBB = new BoundingBox(0, 0, 0, 1, 1, 1);
}
if (minBB == null) {
minBB = new BoundingBox(0, 0, 0, 1, 1, 1);
}
return new AxisAlignedBB(pos.getX() + minBB.minX, pos.getY() + minBB.minY, pos.getZ() + minBB.minZ, pos.getX() + minBB.maxX, pos.getY() + minBB.maxY, pos.getZ() + minBB.maxZ);
}
Aggregations