Search in sources :

Example 1 with IConduit

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

the class AbstractConduit method onAfterRemovedFromBundle.

@Override
public void onAfterRemovedFromBundle() {
    TileEntity te = getBundle().getEntity();
    World world = te.getWorld();
    for (EnumFacing dir : conduitConnections) {
        IConduit neighbour = ConduitUtil.getConduit(world, te, dir, getBaseConduitType());
        if (neighbour instanceof IServerConduit) {
            ((IServerConduit) neighbour).conduitConnectionRemoved(dir.getOpposite());
            ((IServerConduit) neighbour).connectionsChanged();
        }
    }
    conduitConnections.clear();
    if (!externalConnections.isEmpty()) {
        world.notifyNeighborsOfStateChange(te.getPos(), te.getBlockType(), true);
    }
    externalConnections.clear();
    IConduitNetwork<?, ?> network = getNetwork();
    if (network != null) {
        network.destroyNetwork();
    }
    connectionsChanged();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IServerConduit(crazypants.enderio.base.conduit.IServerConduit) EnumFacing(net.minecraft.util.EnumFacing) IConduit(crazypants.enderio.base.conduit.IConduit) World(net.minecraft.world.World)

Example 2 with IConduit

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

the class AbstractConduitNetwork method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    for (IConduit con : conduits) {
        sb.append(con.getBundle().getLocation());
        sb.append(", ");
    }
    return "AbstractConduitNetwork@" + Integer.toHexString(hashCode()) + " [conduits=" + sb.toString() + "]";
}
Also used : IConduit(crazypants.enderio.base.conduit.IConduit)

Example 3 with IConduit

use of crazypants.enderio.base.conduit.IConduit 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)

Example 4 with IConduit

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

the class AbstractConduit method onAddedToBundle.

@Override
public void onAddedToBundle() {
    TileEntity te = bundle.getEntity();
    World world = te.getWorld();
    conduitConnections.clear();
    for (EnumFacing dir : EnumFacing.VALUES) {
        IConduit neighbour = ConduitUtil.getConduit(world, te, dir, getBaseConduitType());
        if (neighbour instanceof IServerConduit && ((IServerConduit) neighbour).canConnectToConduit(dir.getOpposite(), this)) {
            conduitConnections.add(dir);
            ((IServerConduit) neighbour).conduitConnectionAdded(dir.getOpposite());
            ((IServerConduit) neighbour).connectionsChanged();
        }
    }
    externalConnections.clear();
    for (EnumFacing dir : EnumFacing.VALUES) {
        if (!containsConduitConnection(dir) && canConnectToExternal(dir, false)) {
            externalConnectionAdded(dir);
        }
    }
    connectionsChanged();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IServerConduit(crazypants.enderio.base.conduit.IServerConduit) EnumFacing(net.minecraft.util.EnumFacing) IConduit(crazypants.enderio.base.conduit.IConduit) World(net.minecraft.world.World)

Example 5 with IConduit

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

the class BlockConduitBundle method addHitEffects.

@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(@Nonnull IBlockState state, @Nonnull World world, @Nonnull RayTraceResult target, @Nonnull ParticleManager effectRenderer) {
    TileConduitBundle cb = getTileEntity(world, target.getBlockPos());
    if (cb == null) {
        return false;
    }
    TextureAtlasSprite tex = null;
    if (YetaUtil.isSolidFacadeRendered(cb, Minecraft.getMinecraft().player)) {
        IBlockState paintSource = cb.getPaintSource();
        if (paintSource != null) {
            tex = RenderUtil.getTexture(paintSource);
        }
    } else if (target.hitInfo instanceof CollidableComponent) {
        CollidableComponent cc = (CollidableComponent) target.hitInfo;
        IConduit con = cb.getConduit(cc.conduitType);
        if (con != null && con instanceof IClientConduit.WithDefaultRendering) {
            tex = ((IClientConduit.WithDefaultRendering) con).getTextureForState(cc);
        }
    }
    if (tex == null) {
        tex = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(ModObject.block_machine_base.getBlockNN().getDefaultState());
    }
    lastHitIcon = tex;
    addBlockHitEffects(world, effectRenderer, target.hitVec.x, target.hitVec.y, target.hitVec.z, target.sideHit, tex);
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) IConduit(crazypants.enderio.base.conduit.IConduit) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IConduit (crazypants.enderio.base.conduit.IConduit)13 CollidableComponent (crazypants.enderio.base.conduit.geom.CollidableComponent)5 IServerConduit (crazypants.enderio.base.conduit.IServerConduit)4 Nonnull (javax.annotation.Nonnull)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)2 ArrayList (java.util.ArrayList)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 IBlockState (net.minecraft.block.state.IBlockState)2 World (net.minecraft.world.World)2 BoundingBox (com.enderio.core.client.render.BoundingBox)1 IClientConduit (crazypants.enderio.base.conduit.IClientConduit)1 RaytraceResult (crazypants.enderio.base.conduit.RaytraceResult)1 ConduitConnectorType (crazypants.enderio.base.conduit.geom.ConduitConnectorType)1 ConduitCacheKey (crazypants.enderio.conduits.render.BlockStateWrapperConduitBundle.ConduitCacheKey)1 HashSet (java.util.HashSet)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1