Search in sources :

Example 1 with Insulation

use of gregtech.common.pipelike.cable.Insulation 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 2 with Insulation

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

the class CableRenderer method renderItem.

@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockCable)) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockCable blockCable = (BlockCable) ((ItemBlockCable) stack.getItem()).getBlock();
    Insulation insulation = blockCable.getItemPipeType(stack);
    Material material = blockCable.getItemMaterial(stack);
    if (insulation != null && material != null) {
        renderCableBlock(material, insulation, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 1 << EnumFacing.SOUTH.getIndex() | 1 << EnumFacing.NORTH.getIndex() | 1 << (6 + EnumFacing.SOUTH.getIndex()) | 1 << (6 + EnumFacing.NORTH.getIndex()));
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) Material(gregtech.api.unification.material.type.Material) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable)

Example 3 with Insulation

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

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

the class CableRenderer 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));
    BlockCable blockCable = (BlockCable) state.getBlock();
    IPipeTile<Insulation, WireProperties> tileEntityCable = blockCable.getPipeTileEntity(world, pos);
    if (tileEntityCable == null) {
        return;
    }
    Insulation insulation = tileEntityCable.getPipeType();
    if (insulation == null) {
        return;
    }
    float thickness = insulation.getThickness();
    int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
    Cuboid6 baseBox = BlockCable.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockCable.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) EnumFacing(net.minecraft.util.EnumFacing) Vector3(codechicken.lib.vec.Vector3) WireProperties(gregtech.common.pipelike.cable.WireProperties) CCRenderState(codechicken.lib.render.CCRenderState) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable) Cuboid6(codechicken.lib.vec.Cuboid6) Vec3d(net.minecraft.util.math.Vec3d) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Example 5 with Insulation

use of gregtech.common.pipelike.cable.Insulation 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)

Aggregations

Insulation (gregtech.common.pipelike.cable.Insulation)5 Material (gregtech.api.unification.material.type.Material)4 CCRenderState (codechicken.lib.render.CCRenderState)3 BlockCable (gregtech.common.pipelike.cable.BlockCable)3 ItemBlockCable (gregtech.common.pipelike.cable.ItemBlockCable)3 TileEntityCable (gregtech.common.pipelike.cable.tile.TileEntityCable)2 ItemStack (net.minecraft.item.ItemStack)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 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 WireProperties (gregtech.common.pipelike.cable.WireProperties)1 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)1