Search in sources :

Example 1 with TileConduitBundle

use of crazypants.enderio.conduits.conduit.TileConduitBundle in project EnderIO by SleepyTrousers.

the class TileInventoryPanel method scanNetwork.

private void scanNetwork() {
    EnumFacing facingDir = getFacing();
    EnumFacing backside = facingDir.getOpposite();
    ItemConduitNetwork icn = null;
    BlockPos p = pos.offset(backside);
    TileEntity te = world.getTileEntity(p);
    if (te instanceof TileConduitBundle) {
        TileConduitBundle teCB = (TileConduitBundle) te;
        ItemConduit conduit = teCB.getConduit(ItemConduit.class);
        if (conduit != null) {
            icn = (ItemConduitNetwork) conduit.getNetwork();
        }
    }
    if (icn != null) {
        dbServer = icn.getDatabase();
        dbServer.sendChangeLogs();
        refuelPower(dbServer);
        if (active != dbServer.isOperational()) {
            active = dbServer.isOperational();
            updateClients = true;
        }
    } else {
        if (active) {
            updateClients = true;
        }
        dbServer = null;
        active = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileConduitBundle(crazypants.enderio.conduits.conduit.TileConduitBundle) ItemConduitNetwork(crazypants.enderio.conduits.conduit.item.ItemConduitNetwork) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemConduit(crazypants.enderio.conduits.conduit.item.ItemConduit)

Example 2 with TileConduitBundle

use of crazypants.enderio.conduits.conduit.TileConduitBundle in project EnderIO by SleepyTrousers.

the class AbstractConduitPacket method getConduit.

@SuppressWarnings("unchecked")
@Nullable
public T getConduit(MessageContext ctx) {
    if (ctx.side == Side.SERVER) {
        if (ctx.getServerHandler().player.openContainer instanceof ExternalConnectionContainer) {
            final TileConduitBundle tileEntity = ((ExternalConnectionContainer) ctx.getServerHandler().player.openContainer).getTileEntity();
            if (tileEntity == null || !tileEntity.getPos().equals(getPos())) {
                Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit while having another conduit's GUI open!");
                return null;
            }
        } else {
            if (BlockCoord.get(ctx.getServerHandler().player).distanceSq(getPos()) > EnderIO.proxy.getReachDistanceForPlayer(ctx.getServerHandler().player)) {
                Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit without having its GUI open or being near it!");
                return null;
            }
        }
    }
    World world = getWorld(ctx);
    TileEntity tileEntity = getTileEntity(world);
    if (tileEntity instanceof IConduitBundle) {
        return (T) ((IConduitBundle) tileEntity).getConduit(getConType());
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileConduitBundle(crazypants.enderio.conduits.conduit.TileConduitBundle) ExternalConnectionContainer(crazypants.enderio.conduits.gui.ExternalConnectionContainer) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) World(net.minecraft.world.World) Nullable(javax.annotation.Nullable)

Example 3 with TileConduitBundle

use of crazypants.enderio.conduits.conduit.TileConduitBundle in project EnderIO by SleepyTrousers.

the class ConduitRenderMapper method mapBlockRender.

@Override
public List<IBlockState> mapBlockRender(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, BlockRenderLayer blockLayer, @Nonnull QuadCollector quadCollector) {
    TileEntity tileEntity = state.getTileEntity();
    if (tileEntity instanceof TileConduitBundle) {
        IBlockState paintSource = ((TileConduitBundle) tileEntity).getPaintSource();
        if (paintSource != null && (paintSource.isOpaqueCube() || ((TileConduitBundle) tileEntity).getFacadeType().isTransparent()) && !state.getYetaDisplayMode().isHideFacades()) {
            return null;
        }
        List<BakedQuad> quads = ConduitBundleRenderManager.instance.getConduitBundleRenderer().getGeneralQuads(state, blockLayer);
        quadCollector.addQuads(null, blockLayer, quads);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TileConduitBundle(crazypants.enderio.conduits.conduit.TileConduitBundle) IBlockState(net.minecraft.block.state.IBlockState)

Aggregations

TileConduitBundle (crazypants.enderio.conduits.conduit.TileConduitBundle)3 TileEntity (net.minecraft.tileentity.TileEntity)3 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)1 ItemConduit (crazypants.enderio.conduits.conduit.item.ItemConduit)1 ItemConduitNetwork (crazypants.enderio.conduits.conduit.item.ItemConduitNetwork)1 ExternalConnectionContainer (crazypants.enderio.conduits.gui.ExternalConnectionContainer)1 Nullable (javax.annotation.Nullable)1 IBlockState (net.minecraft.block.state.IBlockState)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1