Search in sources :

Example 6 with IConduitBundle

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

the class PowerConduit method getExternalPowerReceptor.

@Override
public IPowerInterface getExternalPowerReceptor(@Nonnull EnumFacing direction) {
    TileEntity te = bundle.getEntity();
    World world = te.getWorld();
    TileEntity test = world.getTileEntity(te.getPos().offset(direction));
    if (test == null) {
        return null;
    }
    if (test instanceof IConduitBundle) {
        return null;
    }
    return PowerHandlerUtil.getPowerInterface(test, direction.getOpposite());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) World(net.minecraft.world.World)

Example 7 with IConduitBundle

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

the class ConduitBundleRenderer method render.

// TESR rendering
@Override
public void render(@Nonnull TileConduitBundle te, double x, double y, double z, float partialTick, int b, float alpha) {
    IConduitBundle bundle = te;
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (bundle.hasFacade() && bundle.getPaintSource().isOpaqueCube() && !YetaUtil.isFacadeHidden(bundle, player)) {
        return;
    }
    float brightness = -1;
    boolean hasDynamic = false;
    for (IClientConduit c : bundle.getClientConduits()) {
        // TODO Temporary work around
        IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
        if (YetaUtil.renderConduit(player, con)) {
            IConduitRenderer renderer = getRendererForConduit(con);
            if (renderer.isDynamic()) {
                if (!hasDynamic) {
                    hasDynamic = true;
                    BlockPos loc = bundle.getLocation();
                    brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, loc);
                    RenderUtil.setupLightmapCoords(te.getPos(), te.getWorld());
                    RenderUtil.bindBlockTexture();
                    GlStateManager.enableNormalize();
                    GlStateManager.enableBlend();
                    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    GlStateManager.shadeModel(GL11.GL_SMOOTH);
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(x, y, z);
                    Tessellator tessellator = Tessellator.getInstance();
                    BufferBuilder tes = tessellator.getBuffer();
                    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
                }
                renderer.renderDynamicEntity(this, bundle, con, x, y, z, partialTick, brightness);
            }
        }
    }
    if (hasDynamic) {
        Tessellator.getInstance().draw();
        GlStateManager.disableNormalize();
        GlStateManager.disableBlend();
        GlStateManager.shadeModel(GL11.GL_FLAT);
        GlStateManager.popMatrix();
    }
}
Also used : IClientConduit(crazypants.enderio.base.conduit.IClientConduit) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) BlockPos(net.minecraft.util.math.BlockPos) IConduitRenderer(crazypants.enderio.base.conduit.IConduitRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 8 with IConduitBundle

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

the class ConduitBundleRenderer method getGeneralQuads.

// ------------ Block Model building
@Nonnull
public List<BakedQuad> getGeneralQuads(@Nonnull IBlockStateWrapper state, BlockRenderLayer layer) {
    if (layer != null && layer != BlockRenderLayer.CUTOUT) {
        return Collections.emptyList();
    }
    List<BakedQuad> result = new ArrayList<BakedQuad>();
    IConduitBundle bundle = (IConduitBundle) state.getTileEntity();
    if (bundle != null) {
        if (layer == null) {
            addBreakingQuads(bundle, result);
        } else {
            float brightness;
            if (!ConduitConfig.updateLightingWhenHidingFacades.get() && bundle.hasFacade()) {
                brightness = 15 << 20 | 15 << 4;
            } else {
                brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, bundle.getLocation());
            }
            // TODO: check if this is the client thread, if not, make a copy of the bundle and its conduits in a thread-safe way
            addConduitQuads(state, bundle, brightness, layer, result);
        }
    }
    return result;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ArrayList(java.util.ArrayList) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) Nonnull(javax.annotation.Nonnull)

Example 9 with IConduitBundle

use of crazypants.enderio.base.conduit.IConduitBundle 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 10 with IConduitBundle

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

the class ItemConduitFacade method onItemUse.

@SuppressWarnings("deprecation")
@Override
@Nonnull
public EnumActionResult onItemUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return EnumActionResult.SUCCESS;
    }
    Block conduitBlock = Registry.getConduitBlock();
    if (conduitBlock != null) {
        ItemStack stack = player.getHeldItem(hand);
        BlockPos placeAt = pos.offset(side);
        if (player.canPlayerEdit(placeAt, side, stack) && PaintUtil.getSourceBlock(stack) != null) {
            if (world.isAirBlock(placeAt)) {
                world.setBlockState(placeAt, conduitBlock.getDefaultState());
                IConduitBundle bundle = NullHelper.notnullM((IConduitBundle) world.getTileEntity(placeAt), "placing block yielded no tileentity");
                IBlockState bs = PaintUtil.getSourceBlock(stack);
                bundle.setFacadeType(EnumFacadeType.getTypeFromMeta(stack.getItemDamage()));
                bundle.setPaintSource(bs);
                ConduitUtil.playPlaceSound(bs.getBlock().getSoundType(), world, pos);
                if (!player.capabilities.isCreativeMode) {
                    stack.shrink(1);
                }
                return EnumActionResult.SUCCESS;
            } else {
                TileEntity tileEntity = world.getTileEntity(pos);
                if (tileEntity instanceof IConduitBundle) {
                    if (((IConduitBundle) tileEntity).handleFacadeClick(world, placeAt, player, side.getOpposite(), stack, hand, hitX, hitY, hitZ)) {
                        return EnumActionResult.SUCCESS;
                    }
                }
            }
        }
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)17 Nonnull (javax.annotation.Nonnull)8 TileEntity (net.minecraft.tileentity.TileEntity)7 ItemStack (net.minecraft.item.ItemStack)6 RaytraceResult (crazypants.enderio.base.conduit.RaytraceResult)4 CollidableComponent (crazypants.enderio.base.conduit.geom.CollidableComponent)4 BlockPos (net.minecraft.util.math.BlockPos)4 ArrayList (java.util.ArrayList)3 World (net.minecraft.world.World)3 NNList (com.enderio.core.common.util.NNList)2 IConduit (crazypants.enderio.base.conduit.IConduit)2 IServerConduit (crazypants.enderio.base.conduit.IServerConduit)2 BoundingBox (com.enderio.core.client.render.BoundingBox)1 ConduitDisplayMode (crazypants.enderio.base.conduit.ConduitDisplayMode)1 IClientConduit (crazypants.enderio.base.conduit.IClientConduit)1 IConduitRenderer (crazypants.enderio.base.conduit.IConduitRenderer)1 ConduitConnectorType (crazypants.enderio.base.conduit.geom.ConduitConnectorType)1 IoMode (crazypants.enderio.base.machine.modes.IoMode)1 IPowerInterface (crazypants.enderio.base.power.IPowerInterface)1 TileConduitBundle (crazypants.enderio.conduits.conduit.TileConduitBundle)1