Search in sources :

Example 1 with CollidableComponent

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;
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 2 with CollidableComponent

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);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) IRedstoneConduit(crazypants.enderio.conduits.conduit.redstone.IRedstoneConduit) RaytraceResult(crazypants.enderio.base.conduit.RaytraceResult) Nonnull(javax.annotation.Nonnull) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with CollidableComponent

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);
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle)

Example 4 with CollidableComponent

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);
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) EnumFacing(net.minecraft.util.EnumFacing) RaytraceResult(crazypants.enderio.base.conduit.RaytraceResult)

Example 5 with CollidableComponent

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;
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) IConduit(crazypants.enderio.base.conduit.IConduit) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

CollidableComponent (crazypants.enderio.base.conduit.geom.CollidableComponent)17 ArrayList (java.util.ArrayList)7 Nonnull (javax.annotation.Nonnull)7 EnumFacing (net.minecraft.util.EnumFacing)6 BoundingBox (com.enderio.core.client.render.BoundingBox)5 IConduit (crazypants.enderio.base.conduit.IConduit)5 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)4 RaytraceResult (crazypants.enderio.base.conduit.RaytraceResult)4 Vector4f (com.enderio.core.common.vecmath.Vector4f)2 IClientConduit (crazypants.enderio.base.conduit.IClientConduit)2 IConduitRenderer (crazypants.enderio.base.conduit.IConduitRenderer)2 HashSet (java.util.HashSet)2 ItemStack (net.minecraft.item.ItemStack)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 NNList (com.enderio.core.common.util.NNList)1 ConduitDisplayMode (crazypants.enderio.base.conduit.ConduitDisplayMode)1 ConduitConnectorType (crazypants.enderio.base.conduit.geom.ConduitConnectorType)1 IRedstoneConduit (crazypants.enderio.conduits.conduit.redstone.IRedstoneConduit)1