use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.
the class AbstractConduit method getCollidableComponents.
@Override
@Nonnull
public List<CollidableComponent> getCollidableComponents() {
if (collidables != null && !collidablesDirty) {
return collidables;
}
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
for (EnumFacing dir : EnumFacing.VALUES) {
Collection<CollidableComponent> col = getCollidables(dir);
if (col != null) {
result.addAll(col);
}
}
collidables = result;
collidablesDirty = false;
return result;
}
use of crazypants.enderio.base.conduit.geom.CollidableComponent 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);
}
use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method addCollisionBoxToList.
@Deprecated
@Override
public void addCollisionBoxToList(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB axisalignedbb, @Nonnull List<AxisAlignedBB> arraylist, @Nullable Entity par7Entity, boolean b) {
IConduitBundle con = getTileEntity(world, pos);
if (con == null) {
return;
}
if (con.hasFacade()) {
setBlockBounds(0, 0, 0, 1, 1, 1);
super.addCollisionBoxToList(state, world, pos, axisalignedbb, arraylist, par7Entity, b);
} else {
Collection<CollidableComponent> collidableComponents = con.getCollidableComponents();
for (CollidableComponent bnd : collidableComponents) {
setBlockBounds(bnd.bound.minX, bnd.bound.minY, bnd.bound.minZ, bnd.bound.maxX, bnd.bound.maxY, bnd.bound.maxZ);
super.addCollisionBoxToList(state, world, pos, axisalignedbb, arraylist, par7Entity, b);
}
if (con.getConduits().isEmpty()) {
// just in case
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxToList(state, world, pos, axisalignedbb, arraylist, par7Entity, b);
}
}
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method handleConduitProbeClick.
private boolean handleConduitProbeClick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, @Nonnull IConduitBundle bundle, @Nonnull ItemStack stack) {
if (stack.getItemDamage() != 1) {
// not in copy paste mode
return false;
}
RaytraceResult rr = doRayTrace(world, pos, player);
if (rr == null) {
return false;
}
CollidableComponent component = rr.component;
if (component == null) {
return false;
}
EnumFacing dir = component.dir;
if (dir == null) {
return false;
}
return ItemConduitProbe.copyPasteSettings(player, stack, bundle, dir);
}
use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method getPickBlock.
@Override
@Nonnull
public ItemStack getPickBlock(@Nonnull IBlockState bs, @Nonnull RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player) {
ItemStack ret = ItemStack.EMPTY;
if (target.hitInfo instanceof CollidableComponent) {
CollidableComponent cc = (CollidableComponent) target.hitInfo;
TileConduitBundle bundle = getTileEntity(world, pos);
if (bundle != null) {
IConduit conduit = bundle.getConduit(cc.conduitType);
if (conduit != null) {
ret = conduit.createItem();
} else if (cc.conduitType == null && bundle.hasFacade()) {
bundle.getFacadeType();
// use the facade
ret = new ItemStack(ModObject.itemConduitFacade.getItemNN(), 1, EnumFacadeType.getMetaFromType(bundle.getFacadeType()));
PaintUtil.setSourceBlock(ret, bundle.getPaintSource());
}
}
}
return ret;
}
Aggregations