Search in sources :

Example 1 with FluidPipeType

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

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

the class FluidPipeRenderer method registerIcons.

public void registerIcons(TextureMap map) {
    for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
        ResourceLocation inLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_in", fluidPipeType.name));
        ResourceLocation sideLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_side", fluidPipeType.name));
        TextureAtlasSprite inTexture = map.registerSprite(inLocation);
        TextureAtlasSprite sideTexture = map.registerSprite(sideLocation);
        this.pipeTextures.put(fluidPipeType, new PipeTextureInfo(inTexture, sideTexture));
    }
    for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
        float thickness = fluidPipeType.getThickness();
        double height = (1.0f - thickness) / 2.0f;
        int angles = 5 + fluidPipeType.ordinal();
        CCModel model = ShapeModelGenerator.generateModel(angles, height, thickness / 3.0f, height);
        CCModel fullBlockModel = ShapeModelGenerator.generateModel(angles, 1.0f, thickness / 3.0f, height);
        CCModel[] rotatedVariants = ShapeModelGenerator.generateRotatedVariants(model);
        CCModel[] fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
        this.pipeModels.put(fluidPipeType, new PipeModelInfo(rotatedVariants, fullBlockVariants));
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) CCModel(codechicken.lib.render.CCModel)

Example 3 with FluidPipeType

use of gregtech.common.pipelike.fluidpipe.FluidPipeType 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 4 with FluidPipeType

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

the class MetaBlocks method registerOreDict.

public static void registerOreDict() {
    OreDictUnifier.registerOre(new ItemStack(LOG, 1, GTValues.W), OrePrefix.log, Materials.Wood);
    OreDictUnifier.registerOre(new ItemStack(LEAVES, 1, GTValues.W), "treeLeaves");
    OreDictUnifier.registerOre(new ItemStack(SAPLING, 1, GTValues.W), "treeSapling");
    GameRegistry.addSmelting(LOG, new ItemStack(Items.COAL, 1, 1), 0.15F);
    for (Entry<DustMaterial, BlockCompressed> entry : COMPRESSED.entrySet()) {
        DustMaterial material = entry.getKey();
        BlockCompressed block = entry.getValue();
        ItemStack itemStack = block.getItem(material);
        OreDictUnifier.registerOre(itemStack, OrePrefix.block, material);
    }
    for (Entry<SolidMaterial, BlockFrame> entry : FRAMES.entrySet()) {
        SolidMaterial material = entry.getKey();
        BlockFrame block = entry.getValue();
        for (int i = 0; i < 16; i++) {
            ItemStack itemStack = new ItemStack(block, 1, i);
            OreDictUnifier.registerOre(itemStack, OrePrefix.frameGt, material);
        }
    }
    for (BlockOre blockOre : ORES) {
        DustMaterial material = blockOre.material;
        for (StoneType stoneType : blockOre.STONE_TYPE.getAllowedValues()) {
            if (stoneType == null)
                continue;
            ItemStack normalStack = blockOre.getItem(blockOre.getDefaultState().withProperty(blockOre.STONE_TYPE, stoneType));
            OreDictUnifier.registerOre(normalStack, stoneType.processingPrefix, material);
        }
    }
    for (Material pipeMaterial : CABLE.getEnabledMaterials()) {
        for (Insulation insulation : Insulation.values()) {
            ItemStack itemStack = CABLE.getItem(insulation, pipeMaterial);
            OreDictUnifier.registerOre(itemStack, insulation.getOrePrefix(), pipeMaterial);
        }
    }
    for (Material pipeMaterial : FLUID_PIPE.getEnabledMaterials()) {
        for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
            ItemStack itemStack = FLUID_PIPE.getItem(fluidPipeType, pipeMaterial);
            OreDictUnifier.registerOre(itemStack, fluidPipeType.getOrePrefix(), pipeMaterial);
        }
    }
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) StoneType(gregtech.api.unification.ore.StoneType) 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) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) ItemStack(net.minecraft.item.ItemStack)

Example 5 with FluidPipeType

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

FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)6 Material (gregtech.api.unification.material.type.Material)4 CCRenderState (codechicken.lib.render.CCRenderState)3 BlockFluidPipe (gregtech.common.pipelike.fluidpipe.BlockFluidPipe)3 ItemBlockFluidPipe (gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe)3 TileEntityFluidPipe (gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 ItemStack (net.minecraft.item.ItemStack)2 CCModel (codechicken.lib.render.CCModel)1 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 ICoverable (gregtech.api.cover.ICoverable)1 DustMaterial (gregtech.api.unification.material.type.DustMaterial)1 IngotMaterial (gregtech.api.unification.material.type.IngotMaterial)1 SolidMaterial (gregtech.api.unification.material.type.SolidMaterial)1 StoneType (gregtech.api.unification.ore.StoneType)1