Search in sources :

Example 1 with TileEntityCable

use of gregtech.common.pipelike.cable.tile.TileEntityCable in project GregTech by GregTechCE.

the class CableRenderer method renderBlock.

@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setBrightness(world, pos);
    IVertexOperation[] pipeline = { new Translation(pos) };
    BlockCable blockCable = (BlockCable) state.getBlock();
    TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos);
    if (tileEntityCable == null)
        return false;
    int paintingColor = tileEntityCable.getInsulationColor();
    int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
    Insulation insulation = tileEntityCable.getPipeType();
    Material material = tileEntityCable.getPipeMaterial();
    if (insulation != null && material != null) {
        BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
        if (renderLayer == BlockRenderLayer.CUTOUT) {
            renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask);
        }
        ICoverable coverable = tileEntityCable.getCoverableImplementation();
        coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) Insulation(gregtech.common.pipelike.cable.Insulation) ICoverable(gregtech.api.cover.ICoverable) Translation(codechicken.lib.vec.Translation) TileEntityCable(gregtech.common.pipelike.cable.tile.TileEntityCable) Material(gregtech.api.unification.material.type.Material) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable) Matrix4(codechicken.lib.vec.Matrix4)

Example 2 with TileEntityCable

use of gregtech.common.pipelike.cable.tile.TileEntityCable in project GregTech by GregTechCE.

the class CableRenderer method getParticleTexture.

public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<Insulation, WireProperties> tileEntity) {
    if (tileEntity == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    Material material = ((TileEntityCable) tileEntity).getPipeMaterial();
    Insulation insulation = tileEntity.getPipeType();
    if (material == null || insulation == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite;
    int particleColor;
    if (insulation.insulationLevel == -1) {
        atlasSprite = wireTexture;
        particleColor = material.materialRGB;
    } else {
        atlasSprite = insulationTextures[5];
        particleColor = tileEntity.getInsulationColor();
    }
    return Pair.of(atlasSprite, particleColor);
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) TileEntityCable(gregtech.common.pipelike.cable.tile.TileEntityCable) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Material(gregtech.api.unification.material.type.Material)

Example 3 with TileEntityCable

use of gregtech.common.pipelike.cable.tile.TileEntityCable in project GregTech by GregTechCE.

the class RoutePath method burnCablesInPath.

public boolean burnCablesInPath(World world, long voltage, long amperage) {
    for (BlockPos blockPos : path.keySet()) {
        WireProperties wireProperties = path.get(blockPos);
        if (voltage > wireProperties.voltage || amperage > wireProperties.amperage) {
            TileEntity tileEntity = world.getTileEntity(blockPos);
            if (tileEntity instanceof TileEntityCable) {
                world.setBlockToAir(blockPos);
                world.setBlockState(blockPos, Blocks.FIRE.getDefaultState());
                if (!world.isRemote) {
                    ((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5, 5 + world.rand.nextInt(3), 0.0, 0.0, 0.0, 0.1);
                }
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCable(gregtech.common.pipelike.cable.tile.TileEntityCable) BlockPos(net.minecraft.util.math.BlockPos) WireProperties(gregtech.common.pipelike.cable.WireProperties) WorldServer(net.minecraft.world.WorldServer)

Aggregations

TileEntityCable (gregtech.common.pipelike.cable.tile.TileEntityCable)3 Material (gregtech.api.unification.material.type.Material)2 Insulation (gregtech.common.pipelike.cable.Insulation)2 CCRenderState (codechicken.lib.render.CCRenderState)1 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 Matrix4 (codechicken.lib.vec.Matrix4)1 Translation (codechicken.lib.vec.Translation)1 ICoverable (gregtech.api.cover.ICoverable)1 BlockCable (gregtech.common.pipelike.cable.BlockCable)1 ItemBlockCable (gregtech.common.pipelike.cable.ItemBlockCable)1 WireProperties (gregtech.common.pipelike.cable.WireProperties)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 WorldServer (net.minecraft.world.WorldServer)1