Search in sources :

Example 1 with BlockFluidPipe

use of gregtech.common.pipelike.fluidpipe.BlockFluidPipe 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 BlockFluidPipe

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

the class FluidPipeRenderer method renderItem.

@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockFluidPipe)) {
        return;
    }
    CCRenderState renderState = CCRenderState.instance();
    GlStateManager.enableBlend();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockFluidPipe blockFluidPipe = (BlockFluidPipe) ((ItemBlockFluidPipe) stack.getItem()).getBlock();
    FluidPipeType pipeType = blockFluidPipe.getItemPipeType(stack);
    Material material = blockFluidPipe.getItemMaterial(stack);
    if (pipeType != null && material != null) {
        renderPipeBlock(material, pipeType, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 0);
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
Also used : ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) 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) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState)

Example 3 with BlockFluidPipe

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

the class MetaBlocks method init.

public static void init() {
    GregTechAPI.MACHINE = MACHINE = new BlockMachine();
    MACHINE.setRegistryName("machine");
    CABLE = new BlockCable();
    CABLE.setRegistryName("cable");
    FLUID_PIPE = new BlockFluidPipe();
    FLUID_PIPE.setRegistryName("fluid_pipe");
    BOILER_CASING = new BlockBoilerCasing();
    BOILER_CASING.setRegistryName("boiler_casing");
    BOILER_FIREBOX_CASING = new BlockFireboxCasing();
    BOILER_FIREBOX_CASING.setRegistryName("boiler_firebox_casing");
    METAL_CASING = new BlockMetalCasing();
    METAL_CASING.setRegistryName("metal_casing");
    TURBINE_CASING = new BlockTurbineCasing();
    TURBINE_CASING.setRegistryName("turbine_casing");
    MACHINE_CASING = new BlockMachineCasing();
    MACHINE_CASING.setRegistryName("machine_casing");
    MUTLIBLOCK_CASING = new BlockMultiblockCasing();
    MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
    WIRE_COIL = new BlockWireCoil();
    WIRE_COIL.setRegistryName("wire_coil");
    WARNING_SIGN = new BlockWarningSign();
    WARNING_SIGN.setRegistryName("warning_sign");
    GRANITE = new BlockGranite();
    GRANITE.setRegistryName("granite");
    MINERAL = new BlockMineral();
    MINERAL.setRegistryName("mineral");
    CONCRETE = new BlockConcrete();
    CONCRETE.setRegistryName("concrete");
    FOAM = new BlockFoam(false);
    FOAM.setRegistryName("foam");
    REINFORCED_FOAM = new BlockFoam(true);
    REINFORCED_FOAM.setRegistryName("reinforced_foam");
    PETRIFIED_FOAM = new BlockPetrifiedFoam(false);
    PETRIFIED_FOAM.setRegistryName("petrified_foam");
    REINFORCED_PETRIFIED_FOAM = new BlockPetrifiedFoam(true);
    REINFORCED_PETRIFIED_FOAM.setRegistryName("reinforced_petrified_foam");
    LOG = new BlockGregLog();
    LOG.setRegistryName("log");
    LEAVES = new BlockGregLeaves();
    LEAVES.setRegistryName("leaves");
    SAPLING = new BlockGregSapling();
    SAPLING.setRegistryName("sapling");
    CRUSHER_BLADE = new BlockCrusherBlade();
    CRUSHER_BLADE.setRegistryName("crusher_blade");
    SURFACE_ROCK_NEW = new BlockSurfaceRockNew();
    SURFACE_ROCK_NEW.setRegistryName("surface_rock_new");
    StoneType.init();
    createGeneratedBlock(material -> material instanceof DustMaterial && !OrePrefix.block.isIgnored(material), MetaBlocks::createCompressedBlock);
    createGeneratedBlock(material -> material instanceof IngotMaterial && material.hasFlag(MatFlags.GENERATE_ORE), MetaBlocks::createSurfaceRockBlock);
    for (Material material : Material.MATERIAL_REGISTRY) {
        if (material instanceof DustMaterial && material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
            createOreBlock((DustMaterial) material);
        }
        if (material instanceof SolidMaterial && material.hasFlag(GENERATE_FRAME)) {
            BlockFrame blockFrame = new BlockFrame((SolidMaterial) material);
            blockFrame.setRegistryName("frame_" + material.toString());
            FRAMES.put((SolidMaterial) material, blockFrame);
        }
        if (material instanceof IngotMaterial) {
            IngotMaterial metalMaterial = (IngotMaterial) material;
            if (metalMaterial.cableProperties != null) {
                CABLE.addCableMaterial(metalMaterial, metalMaterial.cableProperties);
            }
            if (metalMaterial.fluidPipeProperties != null) {
                FLUID_PIPE.addPipeMaterial(metalMaterial, metalMaterial.fluidPipeProperties);
            }
        }
    }
    FLUID_PIPE.addPipeMaterial(Materials.Wood, new FluidPipeProperties(310, 20, false));
    CABLE.addCableMaterial(MarkerMaterials.Tier.Superconductor, new WireProperties(Integer.MAX_VALUE, 4, 0));
    registerTileEntity();
    // not sure if that's a good place for that, but i don't want to make a dedicated method for that
    // could possibly override block methods, but since these props don't depend on state why not just use nice and simple vanilla method
    Blocks.FIRE.setFireInfo(LOG, 5, 5);
    Blocks.FIRE.setFireInfo(LEAVES, 30, 60);
}
Also used : BlockMachine(gregtech.api.block.machines.BlockMachine) BlockPetrifiedFoam(gregtech.common.blocks.foam.BlockPetrifiedFoam) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) BlockGregSapling(gregtech.common.blocks.wood.BlockGregSapling) BlockGregLog(gregtech.common.blocks.wood.BlockGregLog) FluidPipeProperties(gregtech.common.pipelike.fluidpipe.FluidPipeProperties) BlockSurfaceRockNew(gregtech.common.blocks.surfacerock.BlockSurfaceRockNew) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) Material(gregtech.api.unification.material.type.Material) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) WireProperties(gregtech.common.pipelike.cable.WireProperties) BlockFoam(gregtech.common.blocks.foam.BlockFoam) BlockGregLeaves(gregtech.common.blocks.wood.BlockGregLeaves) DustMaterial(gregtech.api.unification.material.type.DustMaterial) BlockCable(gregtech.common.pipelike.cable.BlockCable)

Example 4 with BlockFluidPipe

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

the class DebugPipeNetInfoProvider method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    if (mode == ProbeMode.DEBUG && ConfigHolder.debug) {
        TileEntity tileEntity = world.getTileEntity(data.getPos());
        if (tileEntity instanceof MetaTileEntityHolder) {
            MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
            if (metaTileEntity != null) {
                ArrayList<String> arrayList = new ArrayList<>();
                arrayList.add("MetaTileEntity Id: " + metaTileEntity.metaTileEntityId);
                metaTileEntity.addDebugInfo(arrayList);
                arrayList.forEach(probeInfo::text);
            }
        }
        if (tileEntity instanceof TileEntityPipeBase) {
            IPipeTile<?, ?> pipeTile = (IPipeTile<?, ?>) tileEntity;
            BlockPipe<?, ?, ?> blockPipe = pipeTile.getPipeBlock();
            PipeNet<?> pipeNet = blockPipe.getWorldPipeNet(world).getNetFromPos(data.getPos());
            if (pipeNet != null) {
                probeInfo.text("Net: " + pipeNet.hashCode());
                probeInfo.text("Node Info: ");
                StringBuilder builder = new StringBuilder();
                Map<BlockPos, ? extends Node<?>> nodeMap = pipeNet.getAllNodes();
                Node<?> node = nodeMap.get(data.getPos());
                builder.append("{").append("active: ").append(node.isActive).append(", mark: ").append(node.mark).append(", blocked: ").append(node.blockedConnections).append("}");
                probeInfo.text(builder.toString());
            }
            probeInfo.text("tile blocked: " + pipeTile.getBlockedConnections());
            if (blockPipe instanceof BlockFluidPipe) {
                if (pipeTile instanceof TileEntityFluidPipeTickable) {
                    probeInfo.text("tile active: " + ((TileEntityFluidPipeTickable) pipeTile).isActive());
                }
            }
        }
    }
}
Also used : IPipeTile(gregtech.api.pipenet.tile.IPipeTile) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) ArrayList(java.util.ArrayList) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) TileEntityFluidPipeTickable(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable) TileEntityPipeBase(gregtech.api.pipenet.tile.TileEntityPipeBase) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with BlockFluidPipe

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

the class FluidPipeRenderer method handleRenderBlockDamage.

@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
    BlockFluidPipe blockFluidPipe = (BlockFluidPipe) state.getBlock();
    IPipeTile<FluidPipeType, FluidPipeProperties> tileEntityPipe = blockFluidPipe.getPipeTileEntity(world, pos);
    if (tileEntityPipe == null) {
        return;
    }
    FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
    if (fluidPipeType == null) {
        return;
    }
    float thickness = fluidPipeType.getThickness();
    int connectedSidesMask = blockFluidPipe.getActualConnections(tileEntityPipe, world);
    Cuboid6 baseBox = BlockFluidPipe.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockFluidPipe.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
Also used : FluidPipeProperties(gregtech.common.pipelike.fluidpipe.FluidPipeProperties) EnumFacing(net.minecraft.util.EnumFacing) Vector3(codechicken.lib.vec.Vector3) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) CCRenderState(codechicken.lib.render.CCRenderState) Cuboid6(codechicken.lib.vec.Cuboid6) Vec3d(net.minecraft.util.math.Vec3d) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Aggregations

BlockFluidPipe (gregtech.common.pipelike.fluidpipe.BlockFluidPipe)6 CCRenderState (codechicken.lib.render.CCRenderState)3 Material (gregtech.api.unification.material.type.Material)3 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)3 ItemBlockFluidPipe (gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe)3 FluidPipeProperties (gregtech.common.pipelike.fluidpipe.FluidPipeProperties)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Matrix4 (codechicken.lib.vec.Matrix4)1 Translation (codechicken.lib.vec.Translation)1 Vector3 (codechicken.lib.vec.Vector3)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 BlockMachine (gregtech.api.block.machines.BlockMachine)1 ICoverable (gregtech.api.cover.ICoverable)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)1 IPipeTile (gregtech.api.pipenet.tile.IPipeTile)1 TileEntityPipeBase (gregtech.api.pipenet.tile.TileEntityPipeBase)1