codechicken.lib.texture.TextureUtils Java Examples

The following examples show how to use codechicken.lib.texture.TextureUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
    GlStateManager.color(1, 1, 1, 1);
    TextureUtils.changeTexture("nei:textures/gui/recipebg.png");
    int j = (width - xSize) / 2;
    int k = (height - ySize) / 2;
    drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

    GlStateManager.pushMatrix();
    GlStateManager.translate(j + 5, k + 16, 0);
    IRecipeHandler recipehandler = currenthandlers.get(recipetype);
    for (int i = page * recipehandler.recipiesPerPage(); i < recipehandler.numRecipes() && i < (page + 1) * recipehandler.recipiesPerPage(); i++) {
        recipehandler.drawBackground(i);
        GlStateManager.translate(0, 65, 0);
    }
    GlStateManager.popMatrix();
}
 
Example #2
Source File: GuiEnderItemStorage.java    From EnderStorage with MIT License 6 votes vote down vote up
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    TextureUtils.changeTexture(container.chestInv.getSize() == 0 ? "textures/gui/container/dispenser.png" : "textures/gui/container/generic_54.png");
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;

    switch (container.chestInv.getSize()) {
        case 0:
        case 2:
            blit(x, y, 0, 0, xSize, ySize);
            break;
        case 1:
            blit(x, y, 0, 0, xSize, 71);
            blit(x, y + 71, 0, 126, xSize, 96);
            break;

    }
}
 
Example #3
Source File: StoneRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    //otherwise, we are in solid rendering layer and render primary stone
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    Matrix4 translation = new Matrix4();
    translation.translate(pos.getX(), pos.getY(), pos.getZ());
    TextureAtlasSprite stoneSprite = TextureUtils.getBlockTexture("stone");
    Material material = ((BlockSurfaceRock) state.getBlock()).getStoneMaterial(world, pos, state);
    int renderingColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB);
    IVertexOperation[] operations = new IVertexOperation[] {
        new IconTransformation(stoneSprite),
        new ColourMultiplier(renderingColor),
        new TransformationList(translation)};
    if (world != null) {
        renderState.setBrightness(world, pos);
    }
    renderState.setPipeline(operations);
    CCModel actualModel = getActualModel(world, pos);
    renderState.setModel(actualModel);
    renderState.render();
    return true;
}
 
Example #4
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IBlockAccess world, BlockPos pos) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    if (metaTileEntity == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    } else {
        return metaTileEntity.getParticleTexture();
    }
}
 
Example #6
Source File: GuiNEIButton.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) {

    if (!visible) {
        return;
    }

    FontRenderer fontrenderer = minecraft.fontRenderer;
    TextureUtils.changeTexture(GUI_TEX);
    GlStateManager.color(1, 1, 1, 1);

    boolean flag = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
    int k = getHoverState(flag);

    drawTexturedModalRect(x, y, 0, 46 + k * 20, width / 2, height / 2);//top left
    drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + k * 20, width / 2, height / 2);//top right
    drawTexturedModalRect(x, y + height / 2, 0, 46 + k * 20 + 20 - height / 2, width / 2, height / 2);//bottom left
    drawTexturedModalRect(x + width / 2, y + height / 2, 200 - width / 2, 46 + k * 20 + 20 - height / 2, width / 2, height / 2);//bottom right

    mouseDragged(minecraft, mouseX, mouseY);

    if (!enabled) {
        drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0);
    } else if (flag) {
        drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xffffa0);
    } else {
        drawCenteredString(fontrenderer, displayString, x + width / 2, y + (height - 8) / 2, 0xe0e0e0);
    }
}
 
Example #7
Source File: GuiEnchantmentModifier.java    From NotEnoughItems with MIT License 5 votes vote down vote up
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GlStateManager.color(1, 1, 1, 1);
    TextureUtils.changeTexture("textures/gui/container/enchanting_table.png");
    GlStateManager.translate(guiLeft, guiTop, 0);
    drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);

    container.onUpdate(i, j);
    container.drawSlots(this);
    container.drawScrollBar(this);

    String levelstring = "" + container.level;
    fontRenderer.drawString(levelstring, 33 - fontRenderer.getStringWidth(levelstring) / 2, 34, 0xFF606060);

    GlStateManager.translate(-guiLeft, -guiTop, 0);
}
 
Example #8
Source File: GuiExtendedCreativeInv.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {

    GlStateManager.color(1, 1, 1, 1);
    TextureUtils.changeTexture(INV_TEX);

    int x = guiLeft;
    int y = guiTop - 4;

    drawTexturedModalRect(x - 23, y, 0, 0, 199, 204);
}
 
Example #9
Source File: GuiPotionCreator.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawBackground() {
    TextureUtils.changeTexture("nei:textures/gui/potion.png");
    drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);

    FontUtils.drawCenteredString("Favourite Potions", xSize / 2, 4, 0x404040);
    fontRenderer.drawString("Duration", 12, 40, 0x404040);
    fontRenderer.drawString("Level", 19, 73, 0x404040);
    FontUtils.drawCenteredString(translateAmplifier(amplifier), 33, 86, 0xFF606060);
}
 
Example #10
Source File: ContainerEnchantmentModifier.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void drawSlots(GuiEnchantmentModifier gui) {
    for (int slot = 0; slot < 3; slot++) {
        int shade = 0;
        String text = "";

        int containerslot = slot + getScrolledSlots();
        if (containerslot + 1 > slotEnchantment.size()) {
            shade = 1;
        } else {
            EnchantmentHash e = slotEnchantment.get(containerslot);
            shade = e.state;
            text = e.enchantment.getTranslatedName(e.level == -1 ? level : e.level);
            if (gui.mc.fontRenderer.getStringWidth(text) > 95 && text.contains("Projectile")) {
                text = text.replace("Projectile", "Proj");
            }
            if (gui.mc.fontRenderer.getStringWidth(text) > 95 && text.contains("Protection")) {
                text = text.replace("Protection", "Protect");
            }
            if (gui.mc.fontRenderer.getStringWidth(text) > 95 && text.contains("Bane of")) {
                text = text.replace("Bane of ", "");
            }
        }

        TextureUtils.changeTexture("textures/gui/container/enchanting_table.png");
        GlStateManager.color(1, 1, 1);
        if (hasScrollBar()) {
            gui.drawTexturedModalRect(relx, rely + slot * slotheight, 0, gui.getYSize() + slotheight * shade, cwidth - 30, slotheight);
            gui.drawTexturedModalRect(relx + cwidth - 30, rely + slot * slotheight, cwidth - 23, gui.getYSize() + slotheight * shade, 30, slotheight);
        } else {
            gui.drawTexturedModalRect(relx, rely + slot * slotheight, 0, gui.getYSize() + slotheight * shade, cwidth + 7, slotheight);
        }

        gui.getFontRenderer().drawString(text, relx + 4, rely + slot * slotheight + 5, textColourFromState(shade));
    }
}
 
Example #11
Source File: PatreonButton.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawButtonTex(int mousex, int mousey) {
    super.drawButtonTex(mousex, mousey);

    GlStateManager.color(1, 1, 1, 1);
    TextureUtils.changeTexture("nei:textures/patreon_neon.png");
    int texh = height - 4;
    int texw = texh * 4;
    drawModalRectWithCustomSizedTexture(x + width / 2 - texw / 2, y + height / 2 - texh / 2, 0, 0, texw, texh, texw, texh);
}
 
Example #12
Source File: ModelProperties.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TextureAtlasSprite getParticleTexture() {
    //TODO, 1.13, Force ModelProperties to be constructed after texture stitching.
    if (particle == null) {
        particle = TextureUtils.getMissingSprite();
    }
    return particle;
}
 
Example #13
Source File: CustomGradient.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CustomGradient(ResourceLocation textureFile) {
    BufferedImage img = TextureUtils.loadBufferedImage(textureFile);
    if (img == null) {
        throw new RuntimeException("File not found: " + textureFile.toString());
    }

    int[] data = new int[img.getWidth()];
    img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth());
    gradient = new int[img.getWidth()];
    for (int i = 0; i < data.length; i++) {
        gradient[i] = (data[i] << 8) | (((data[i]) >> 24) & 0xFF);
    }
}
 
Example #14
Source File: QBImporter.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TextureAtlasSprite getIcon(String key, TextureMap textureMap) {
    int img = map.get(key).img;
    String iconName = "QBModel" + hashCode() + "_img";
    TextureAtlasSprite icon = textureMap.getTextureExtry(iconName);
    if (icon != null) {
        return icon;
    }

    return TextureUtils.getTextureSpecial(textureMap, iconName).addTexture(new TextureDataHolder(images.get(img)));
}
 
Example #15
Source File: TileEntityCrusherBladeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void draw(TileEntityCrusherBlade tileEntity, CCRenderState renderState, Matrix4 translation, float partialTicks) {
    translation.translate(0.5, 0.5, 0.5);

    IBlockState blockState = tileEntity.getBlockState();
    switch (blockState.getValue(BlockCrusherBlade.AXIS)) {
        case Y:
            break;
        case X:
            translation.rotate(Math.toRadians(90.0), Rotation.axes[3]);
            break;
        case Z:
            translation.rotate(Math.toRadians(90.0), Rotation.axes[5]);
            break;
    }

    if (blockState.getValue(BlockCrusherBlade.ACTIVE)) {
        long currentWorldTime = tileEntity.hasWorld() ? tileEntity.getWorld().getTotalWorldTime() : 0;
        translation.rotate(Math.toRadians(currentWorldTime * 12.0 % 180), Rotation.axes[1]);
    }

    translation.translate(-0.5, -0.5, -0.5);

    TextureAtlasSprite ironBlockTexture = TextureUtils.getBlockTexture("iron_block");
    IVertexOperation[] operations = {};

    for (Cuboid6 cuboid6 : BlockCrusherBlade.basicModel) {
        for (EnumFacing renderSide : EnumFacing.VALUES) {
            Textures.renderFace(renderState, translation, operations, renderSide, cuboid6, ironBlockTexture);
        }
    }
}
 
Example #16
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<InventoryPipeType, EmptyNodeData> tileEntity) {
    if (tileEntity == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite = TextureUtils.getBlockTexture("stone");
    int particleColor = tileEntity.getInsulationColor();
    return Pair.of(atlasSprite, particleColor);
}
 
Example #17
Source File: TankRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderFluid(CCRenderState renderState, Matrix4 translation, int connectionMask, double fillPercent, FluidStack fluidStack) {
    if (fluidStack != null) {
        int fluidStackColor = fluidStack.getFluid().getColor(fluidStack);
        double fluidLevelOffset = (offset(EnumFacing.UP, connectionMask) + offset(EnumFacing.DOWN, connectionMask));
        double fluidLevel = fillPercent * (1.0 - fluidLevelOffset);

        Cuboid6 resultFluidCuboid = createFullOffsetCuboid(connectionMask);
        int resultFluidColor;
        if (fluidStack.getFluid().isGaseous(fluidStack)) {
            int opacity = (int) (fillPercent * 255);
            resultFluidColor = GTUtility.convertRGBtoRGBA_CL(fluidStackColor, opacity);
        } else {
            resultFluidCuboid.max.y = resultFluidCuboid.min.y + fluidLevel;
            resultFluidColor = GTUtility.convertRGBtoOpaqueRGBA_CL(fluidStackColor);
        }

        ColourMultiplier multiplier = new ColourMultiplier(resultFluidColor);
        IVertexOperation[] fluidPipeline = new IVertexOperation[]{multiplier};
        TextureAtlasSprite fluidSprite = TextureUtils.getTexture(fluidStack.getFluid().getStill(fluidStack));

        for (EnumFacing renderSide : EnumFacing.VALUES) {
            if (hasFaceBit(connectionMask, renderSide)) continue;
            Textures.renderFace(renderState, translation, fluidPipeline, renderSide, resultFluidCuboid, fluidSprite);
        }
    }
}
 
Example #18
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #19
Source File: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Renders this meta tile entity
 * Note that you shouldn't refer to world-related information in this method, because it
 * will be called on ItemStacks too
 *
 * @param renderState render state (either chunk batched or item)
 * @param pipeline    default set of pipeline transformations
 */
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    TextureAtlasSprite atlasSprite = TextureUtils.getMissingSprite();
    IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    for (EnumFacing face : EnumFacing.VALUES) {
        Textures.renderFace(renderState, translation, renderPipeline, face, Cuboid6.full, atlasSprite);
    }
}
 
Example #20
Source File: MetaTileEntityPrimitiveBlastFurnace.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    Textures.PRIMITIVE_BLAST_FURNACE_OVERLAY.render(renderState, translation, pipeline, getFrontFacing(), isActive());
    if (isActive() && isStructureFormed()) {
        EnumFacing back = getFrontFacing().getOpposite();
        Matrix4 offset = translation.copy().translate(back.getFrontOffsetX(), -0.3, back.getFrontOffsetZ());
        TextureAtlasSprite sprite = TextureUtils.getBlockTexture("lava_still");
        renderState.brightness = 0xF000F0;
        renderState.colour = 0xFFFFFFFF;
        Textures.renderFace(renderState, offset, new IVertexOperation[0], EnumFacing.UP, Cuboid6.full, sprite);
    }
}
 
Example #21
Source File: ClientProxy.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onPreLoad() {
    super.onPreLoad();
    MetaTileEntityRenderer.preInit();
    CableRenderer.preInit();
    FluidPipeRenderer.preInit();
    StoneRenderer.preInit();
    MetaEntities.initRenderers();
    TextureUtils.addIconRegister(MetaFluids::registerSprites);
    MinecraftForge.EVENT_BUS.register(ToolRenderHandler.INSTANCE);
}
 
Example #22
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void preInit() {
    BLOCK_RENDER_TYPE = BlockRenderingRegistry.createRenderType("gt_cable");
    BlockRenderingRegistry.registerRenderer(BLOCK_RENDER_TYPE, INSTANCE);
    MinecraftForge.EVENT_BUS.register(INSTANCE);
    TextureUtils.addIconRegister(INSTANCE::registerIcons);
}
 
Example #23
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void preInit() {
    BLOCK_RENDER_TYPE = BlockRenderingRegistry.createRenderType("meta_tile_entity");
    BlockRenderingRegistry.registerRenderer(BLOCK_RENDER_TYPE, INSTANCE);
    MinecraftForge.EVENT_BUS.register(INSTANCE);
    TextureUtils.addIconRegister(Textures::register);
}
 
Example #24
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}
 
Example #25
Source File: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public Pair<TextureAtlasSprite, Integer> getParticleTexture() {
    return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
}
 
Example #26
Source File: BakedModelHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getBlockTexture(particleTexture);
}
 
Example #27
Source File: CCBakeryModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}
 
Example #28
Source File: IModelParticleProvider.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
default TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}
 
Example #29
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void preInit() {
    BLOCK_RENDER_TYPE = BlockRenderingRegistry.createRenderType("gt_fluid_pipe");
    BlockRenderingRegistry.registerRenderer(BLOCK_RENDER_TYPE, INSTANCE);
    MinecraftForge.EVENT_BUS.register(INSTANCE);
    TextureUtils.addIconRegister(INSTANCE::registerIcons);
}
 
Example #30
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TextureAtlasSprite getParticleTexture() {
    return TextureUtils.getMissingSprite();
}