Search in sources :

Example 1 with TileEntityFluidPipe

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.

the class FluidPipeRenderer 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);
    BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock());
    TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos);
    if (tileEntityPipe == null) {
        return false;
    }
    FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
    Material pipeMaterial = tileEntityPipe.getPipeMaterial();
    int paintingColor = tileEntityPipe.getInsulationColor();
    if (fluidPipeType != null && pipeMaterial != null) {
        BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
        if (renderLayer == BlockRenderLayer.CUTOUT) {
            int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world);
            IVertexOperation[] pipeline = new IVertexOperation[] { new Translation(pos) };
            renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask);
        }
        ICoverable coverable = tileEntityPipe.getCoverableImplementation();
        coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ICoverable(gregtech.api.cover.ICoverable) Translation(codechicken.lib.vec.Translation) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) Material(gregtech.api.unification.material.type.Material) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe) Matrix4(codechicken.lib.vec.Matrix4)

Example 2 with TileEntityFluidPipe

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.

the class FluidPipeRenderer method getParticleTexture.

public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<FluidPipeType, FluidPipeProperties> tileEntity) {
    if (tileEntity == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    FluidPipeType fluidPipeType = tileEntity.getPipeType();
    Material material = ((TileEntityFluidPipe) tileEntity).getPipeMaterial();
    if (fluidPipeType == null || material == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite = pipeTextures.get(fluidPipeType).sideTexture;
    int pipeColor = getPipeColor(material, tileEntity.getInsulationColor());
    return Pair.of(atlasSprite, pipeColor);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) Material(gregtech.api.unification.material.type.Material) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)

Example 3 with TileEntityFluidPipe

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.

the class BlockFluidPipe method onActiveModeChange.

@Override
protected void onActiveModeChange(World world, BlockPos pos, boolean isActiveNow, boolean isInitialChange) {
    TileEntityFluidPipe oldTileEntity = (TileEntityFluidPipe) world.getTileEntity(pos);
    if (!(oldTileEntity instanceof TileEntityFluidPipeTickable) && isActiveNow) {
        TileEntityFluidPipeTickable newTileEntity = new TileEntityFluidPipeTickable();
        newTileEntity.transferDataFrom(oldTileEntity);
        newTileEntity.setActive(true);
        world.setTileEntity(pos, newTileEntity);
    } else if (oldTileEntity instanceof TileEntityFluidPipeTickable) {
        ((TileEntityFluidPipeTickable) oldTileEntity).setActive(isActiveNow);
    }
}
Also used : TileEntityFluidPipeTickable(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)

Example 4 with TileEntityFluidPipe

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.

the class FluidPipeNet method destroyNetwork.

public void destroyNetwork(boolean isLeaking, boolean isBurning) {
    World world = worldData.getWorld();
    ((WorldFluidPipeNet) (Object) worldData).removePipeNet(this);
    for (BlockPos nodePos : getAllNodes().keySet()) {
        TileEntity tileEntity = world.getTileEntity(nodePos);
        if (tileEntity instanceof TileEntityFluidPipe) {
            if (isBurning) {
                world.setBlockState(nodePos, Blocks.FIRE.getDefaultState());
            } else {
                world.setBlockToAir(nodePos);
            }
        }
        Random random = world.rand;
        if (isBurning) {
            TileEntityFluidPipe.spawnParticles(world, nodePos, EnumFacing.UP, EnumParticleTypes.FLAME, 3 + random.nextInt(2), random);
            if (random.nextInt(4) == 0) {
                TileEntityFluidPipe.setNeighboursToFire(world, nodePos);
            }
        }
        if (isLeaking && world.rand.nextInt(isBurning ? 3 : 7) == 0) {
            world.createExplosion(null, nodePos.getX() + 0.5, nodePos.getY() + 0.5, nodePos.getZ() + 0.5, 1.0f + world.rand.nextFloat(), false);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)

Aggregations

TileEntityFluidPipe (gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)4 Material (gregtech.api.unification.material.type.Material)2 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)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 BlockFluidPipe (gregtech.common.pipelike.fluidpipe.BlockFluidPipe)1 ItemBlockFluidPipe (gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe)1 TileEntityFluidPipeTickable (gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable)1 Random (java.util.Random)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 World (net.minecraft.world.World)1