Search in sources :

Example 71 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class PipeRenderer method getParticleTexture.

public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<?, ?> pipeTile) {
    if (pipeTile == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    IPipeType<?> pipeType = pipeTile.getPipeType();
    Material material = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
    if (pipeType == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite = getParticleTexture(pipeType, material);
    int pipeColor = getPipeColor(material, pipeTile.getPaintingColor());
    return Pair.of(atlasSprite, pipeColor);
}
Also used : TileEntityMaterialPipeBase(gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Material(gregtech.api.unification.material.Material)

Example 72 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class PipeRenderer 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);
    BlockPipe<?, ?, ?> blockPipe = (BlockPipe<?, ?, ?>) state.getBlock();
    IPipeTile<?, ?> pipeTile = blockPipe.getPipeTileEntity(world, pos);
    if (pipeTile == null) {
        return false;
    }
    IPipeType<?> pipeType = pipeTile.getPipeType();
    Material pipeMaterial = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
    int paintingColor = pipeTile.getPaintingColor();
    int connectedSidesMap = pipeTile.getVisualConnections();
    int blockedConnections = pipeTile.getBlockedConnections();
    if (pipeType != null) {
        BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
        boolean[] sideMask = new boolean[EnumFacing.VALUES.length];
        for (EnumFacing side : EnumFacing.VALUES) {
            sideMask[side.getIndex()] = state.shouldSideBeRendered(world, pos, side);
        }
        Textures.RENDER_STATE.set(new CubeRendererState(renderLayer, sideMask, world));
        if (renderLayer == BlockRenderLayer.CUTOUT) {
            renderState.lightMatrix.locate(world, pos);
            PipeRenderContext renderContext = new PipeRenderContext(pos, renderState.lightMatrix, connectedSidesMap, blockedConnections, pipeType.getThickness());
            renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(pipeMaterial, paintingColor));
            buildRenderer(renderContext, blockPipe, pipeTile, pipeType, pipeMaterial);
            renderPipeBlock(renderState, renderContext);
        }
        ICoverable coverable = pipeTile.getCoverableImplementation();
        coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
        Textures.RENDER_STATE.set(null);
    }
    return true;
}
Also used : ICoverable(gregtech.api.cover.ICoverable) EnumFacing(net.minecraft.util.EnumFacing) Material(gregtech.api.unification.material.Material) BlockPipe(gregtech.api.pipenet.block.BlockPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) Matrix4(codechicken.lib.vec.Matrix4) CubeRendererState(gregtech.client.renderer.CubeRendererState) TileEntityMaterialPipeBase(gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState)

Example 73 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class PipeRenderer method renderItem.

@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockPipe)) {
        return;
    }
    CCRenderState renderState = CCRenderState.instance();
    GlStateManager.enableBlend();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockPipe<?, ?, ?> blockFluidPipe = (BlockPipe<?, ?, ?>) ((ItemBlockPipe<?, ?>) stack.getItem()).getBlock();
    IPipeType<?> pipeType = blockFluidPipe.getItemPipeType(stack);
    Material material = blockFluidPipe instanceof BlockMaterialPipe ? ((BlockMaterialPipe<?, ?, ?>) blockFluidPipe).getItemMaterial(stack) : null;
    if (pipeType != null) {
        // 12 == 0b1100 is North and South connection (index 2 & 3)
        PipeRenderContext renderContext = new PipeRenderContext(12, 0, pipeType.getThickness());
        renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, -1));
        buildRenderer(renderContext, blockFluidPipe, null, pipeType, material);
        renderPipeBlock(renderState, renderContext);
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
Also used : BlockMaterialPipe(gregtech.api.pipenet.block.material.BlockMaterialPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) Material(gregtech.api.unification.material.Material) BlockPipe(gregtech.api.pipenet.block.BlockPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState)

Example 74 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class TurbineRotorBehavior method getRotorEfficiency.

public int getRotorEfficiency(ItemStack stack) {
    Material material = getPartMaterial(stack);
    ToolProperty property = material.getProperty(PropertyKey.TOOL);
    return property == null ? -1 : ((int) ((60 + property.getToolSpeed() * 8)) / 5 * 5);
}
Also used : Material(gregtech.api.unification.material.Material) ToolProperty(gregtech.api.unification.material.properties.ToolProperty)

Example 75 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class AbstractMaterialPartBehavior method getPartMaterial.

public Material getPartMaterial(ItemStack itemStack) {
    NBTTagCompound compound = getPartStatsTag(itemStack);
    Material defaultMaterial = Materials.Neutronium;
    if (compound == null || !compound.hasKey("Material", NBT.TAG_STRING)) {
        return defaultMaterial;
    }
    String materialName = compound.getString("Material");
    Material material = GregTechAPI.MATERIAL_REGISTRY.getObject(materialName);
    if (material == null || !material.hasProperty(PropertyKey.INGOT)) {
        return defaultMaterial;
    }
    return material;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Material(gregtech.api.unification.material.Material)

Aggregations

Material (gregtech.api.unification.material.Material)76 ItemStack (net.minecraft.item.ItemStack)31 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)19 OrePrefix (gregtech.api.unification.ore.OrePrefix)13 MaterialStack (gregtech.api.unification.stack.MaterialStack)12 Nonnull (javax.annotation.Nonnull)10 PropertyKey (gregtech.api.unification.material.properties.PropertyKey)9 Block (net.minecraft.block.Block)8 IBlockState (net.minecraft.block.state.IBlockState)8 GTValues (gregtech.api.GTValues)7 Collectors (java.util.stream.Collectors)7 Nullable (javax.annotation.Nullable)7 Materials (gregtech.api.unification.material.Materials)6 DustProperty (gregtech.api.unification.material.properties.DustProperty)6 ToolProperty (gregtech.api.unification.material.properties.ToolProperty)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 GregTechAPI (gregtech.api.GregTechAPI)5 OreDictUnifier (gregtech.api.unification.OreDictUnifier)5 MarkerMaterial (gregtech.api.unification.material.MarkerMaterial)5 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)5