Search in sources :

Example 6 with CollidableComponent

use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.

the class InsulatedRedstoneConduit method createCollidables.

@Override
@Nonnull
public Collection<CollidableComponent> createCollidables(@Nonnull CacheKey key) {
    Collection<CollidableComponent> baseCollidables = super.createCollidables(key);
    if (key.dir == null) {
        return baseCollidables;
    }
    BoundingBox bb = ConduitGeometryUtil.instance.createBoundsForConnectionController(key.dir, key.offset);
    CollidableComponent cc = new CollidableComponent(IRedstoneConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
    List<CollidableComponent> result = new ArrayList<CollidableComponent>();
    result.addAll(baseCollidables);
    result.add(cc);
    return result;
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 7 with CollidableComponent

use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.

the class ConduitBundleRenderer method addBreakingQuads.

private void addBreakingQuads(@Nonnull IConduitBundle bundle, @Nonnull List<BakedQuad> quads) {
    Class<? extends IConduit> conduitType = null;
    RayTraceResult hit = Minecraft.getMinecraft().objectMouseOver;
    if (NullHelper.untrust(hit) != null && (hit.hitInfo instanceof CollidableComponent)) {
        conduitType = ((CollidableComponent) hit.hitInfo).conduitType;
    }
    if (breakingAnimOnWholeConduit) {
        for (IClientConduit c : bundle.getClientConduits()) {
            if (conduitType == c.getClass() || conduitType == c.getBaseConduitType()) {
                IConduitRenderer renderer = getRendererForConduit(c);
                renderer.addBakedQuads(this, bundle, (IClientConduit.WithDefaultRendering) c, 1, BlockRenderLayer.CUTOUT, quads);
            }
        }
    }
    List<CollidableComponent> connectors = bundle.getConnectors();
    for (CollidableComponent component : connectors) {
        if (component != null) {
            if (component.conduitType == conduitType || conduitType == null) {
                IClientConduit.WithDefaultRendering conduit = (IClientConduit.WithDefaultRendering) bundle.getConduit(component.conduitType);
                if (conduit != null) {
                    TextureAtlasSprite tex = conduit.getTextureForState(component);
                    BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
                }
            }
        }
    }
}
Also used : IClientConduit(crazypants.enderio.base.conduit.IClientConduit) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) RayTraceResult(net.minecraft.util.math.RayTraceResult) IConduitRenderer(crazypants.enderio.base.conduit.IConduitRenderer)

Example 8 with CollidableComponent

use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.

the class DefaultConduitRenderer method renderDynamicEntity.

// ------------ Dynamic ---------------------------------------------
@Override
public void renderDynamicEntity(@Nonnull TileEntitySpecialRenderer conduitBundleRenderer, @Nonnull IConduitBundle te, @Nonnull IClientConduit.WithDefaultRendering conduit, double x, double y, double z, float partialTick, float worldLight) {
    Collection<CollidableComponent> components = conduit.getCollidableComponents();
    transmissionScaleFactor = conduit.getTransmitionGeometryScale();
    for (CollidableComponent component : components) {
        if (renderComponent(component)) {
            float selfIllum = Math.max(worldLight, conduit.getSelfIlluminationForState(component));
            final TextureAtlasSprite transmitionTextureForState = conduit.getTransmitionTextureForState(component);
            if (isNSEWUD(component.dir) && transmitionTextureForState != null) {
                Vector4f color = conduit.getTransmitionTextureColorForState(component);
                renderTransmissionDynamic(conduit, transmitionTextureForState, color, component, selfIllum);
            }
            TextureAtlasSprite tex = conduit.getTextureForState(component);
            if (tex == null) {
                tex = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
            }
            renderConduitDynamic(tex, conduit, component, selfIllum);
        }
    }
}
Also used : Vector4f(com.enderio.core.common.vecmath.Vector4f) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 9 with CollidableComponent

use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.

the class PowerConduit method createCollidables.

@Override
@Nonnull
public Collection<CollidableComponent> createCollidables(@Nonnull CacheKey key) {
    Collection<CollidableComponent> baseCollidables = super.createCollidables(key);
    if (key.dir == null) {
        return baseCollidables;
    }
    BoundingBox bb = ConduitGeometryUtil.instance.createBoundsForConnectionController(key.dir, key.offset);
    CollidableComponent cc = new CollidableComponent(IPowerConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
    List<CollidableComponent> result = new ArrayList<CollidableComponent>();
    result.addAll(baseCollidables);
    result.add(cc);
    return result;
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 10 with CollidableComponent

use of crazypants.enderio.base.conduit.geom.CollidableComponent in project EnderIO by SleepyTrousers.

the class ConduitBundleRenderer method addConduitQuads.

private void addConduitQuads(@Nonnull IBlockStateWrapper state, @Nonnull IConduitBundle bundle, float brightness, @Nonnull BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
    // Conduits
    Set<EnumFacing> externals = new HashSet<EnumFacing>();
    List<BoundingBox> wireBounds = new ArrayList<BoundingBox>();
    if (bundle.hasFacade() && state.getYetaDisplayMode().isHideFacades()) {
        wireBounds.add(BoundingBox.UNIT_CUBE);
    }
    for (IClientConduit c : bundle.getClientConduits()) {
        // TODO Temporary Workaround
        IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
        if (state.getYetaDisplayMode().renderConduit(con)) {
            IConduitRenderer renderer = getRendererForConduit(con);
            renderer.addBakedQuads(this, bundle, con, brightness, layer, quads);
            Set<EnumFacing> extCons = con.getExternalConnections();
            for (EnumFacing dir : extCons) {
                if (con.getConnectionMode(dir) != ConnectionMode.DISABLED && con.getConnectionMode(dir) != ConnectionMode.NOT_SET) {
                    externals.add(dir);
                }
            }
        } else if (con != null) {
            Collection<CollidableComponent> components = con.getCollidableComponents();
            for (CollidableComponent component : components) {
                addWireBounds(wireBounds, component);
            }
        }
    }
    // Internal connectors between conduits
    List<CollidableComponent> connectors = bundle.getConnectors();
    for (CollidableComponent component : connectors) {
        if (component != null) {
            if (component.conduitType != null) {
                // TODO Make an actual check before assuming a default render
                IClientConduit.WithDefaultRendering conduit = (IClientConduit.WithDefaultRendering) bundle.getConduit(component.conduitType);
                if (conduit != null) {
                    if (state.getYetaDisplayMode().renderConduit(component.conduitType)) {
                        TextureAtlasSprite tex = conduit.getTextureForState(component);
                        if (tex == null) {
                            tex = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
                        }
                        BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
                    } else {
                        addWireBounds(wireBounds, component);
                    }
                }
            } else if (state.getYetaDisplayMode().getDisplayMode().isAll()) {
                TextureAtlasSprite tex = ConduitBundleRenderManager.instance.getConnectorIcon(component.data);
                BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
            }
        }
    }
    // render these after the 'normal' conduits so help with proper blending
    for (BoundingBox wireBound : wireBounds) {
        BakedQuadBuilder.addBakedQuads(quads, wireBound, ConduitBundleRenderManager.instance.getWireFrameIcon());
    }
    // External connection terminations
    for (EnumFacing dir : externals) {
        addQuadsForExternalConnection(dir, quads);
    }
    if (quads.isEmpty() && !bundle.hasFacade()) {
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.10), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.15), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.20), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.25), ConduitBundleRenderManager.instance.getWireFrameIcon());
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) IClientConduit(crazypants.enderio.base.conduit.IClientConduit) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) Collection(java.util.Collection) IConduitRenderer(crazypants.enderio.base.conduit.IConduitRenderer) HashSet(java.util.HashSet)

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