Search in sources :

Example 11 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.

the class FruitProviderNone method registerSprites.

@Override
@SideOnly(Side.CLIENT)
public void registerSprites() {
    if (overlay != null) {
        TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
        map.registerSprite(overlay.sprite);
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.

the class FarmLedger method draw.

@Override
@SideOnly(Side.CLIENT)
public void draw(int x, int y) {
    // Draw background
    drawBackground(x, y);
    y += 4;
    int xIcon = x + 3;
    int xBody = x + 10;
    int xHeader = x + 22;
    // Draw icon
    Minecraft minecraft = Minecraft.getMinecraft();
    TextureMap textureMapBlocks = minecraft.getTextureMapBlocks();
    TextureAtlasSprite textureAtlasSprite = textureMapBlocks.getAtlasSprite("minecraft:items/bucket_water");
    drawSprite(TextureMap.LOCATION_BLOCKS_TEXTURE, textureAtlasSprite, xIcon, y);
    y += 4;
    if (!isFullyOpened()) {
        return;
    }
    y += drawHeader(Translator.translateToLocal("for.gui.hydration"), xHeader, y);
    y += 4;
    y += drawSubheader(Translator.translateToLocal("for.gui.hydr.heat") + ':', xBody, y);
    y += 3;
    y += drawText(StringUtil.floatAsPercent(delegate.getHydrationTempModifier()), xBody, y);
    y += 3;
    y += drawSubheader(Translator.translateToLocal("for.gui.hydr.humid") + ':', xBody, y);
    y += 3;
    y += drawText(StringUtil.floatAsPercent(delegate.getHydrationHumidModifier()), xBody, y);
    y += 3;
    y += drawSubheader(Translator.translateToLocal("for.gui.hydr.rainfall") + ':', xBody, y);
    y += 3;
    y += drawText(StringUtil.floatAsPercent(delegate.getHydrationRainfallModifier()) + " (" + delegate.getDrought() + " d)", xBody, y);
    y += 3;
    y += drawSubheader(Translator.translateToLocal("for.gui.hydr.overall") + ':', xBody, y);
    y += 3;
    drawText(StringUtil.floatAsPercent(delegate.getHydrationModifier()), xBody, y);
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 13 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project Railcraft by Railcraft.

the class JSONModelRenderer method loadModels.

@SubscribeEvent
public void loadModels(TextureStitchEvent.Pre event) {
    final TextureMap map = event.getMap();
    for (ResourceLocation modelLocation : modelLocations) {
        IModel model = ModelManager.getModel(modelLocation);
        models.put(modelLocation, model);
        model.getTextures().forEach(map::registerSprite);
    }
}
Also used : IModel(net.minecraftforge.client.model.IModel) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project pnc-repressurized by TeamPneumatic.

the class GuiUtils method drawFluid.

public static void drawFluid(final Rectangle bounds, @Nullable FluidStack fluidStack, @Nullable IFluidTank tank) {
    if (fluidStack == null || fluidStack.getFluid() == null) {
        return;
    }
    Fluid fluid = fluidStack.getFluid();
    TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks();
    ResourceLocation fluidStill = fluid.getStill();
    TextureAtlasSprite fluidStillSprite = null;
    if (fluidStill != null) {
        fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
    }
    if (fluidStillSprite == null) {
        fluidStillSprite = textureMapBlocks.getMissingSprite();
    }
    int fluidColor = fluid.getColor(fluidStack);
    int scaledAmount = tank == null ? bounds.height : fluidStack.amount * bounds.height / tank.getCapacity();
    if (fluidStack.amount > 0 && scaledAmount < 1) {
        scaledAmount = 1;
    }
    scaledAmount = Math.min(scaledAmount, bounds.height);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderUtils.glColorHex(fluidColor, 255);
    final int xTileCount = bounds.width / TEX_WIDTH;
    final int xRemainder = bounds.width - xTileCount * TEX_WIDTH;
    final int yTileCount = scaledAmount / TEX_HEIGHT;
    final int yRemainder = scaledAmount - yTileCount * TEX_HEIGHT;
    int yStart = bounds.y + bounds.height;
    if (fluid.getDensity() < 0)
        yStart -= (bounds.height - scaledAmount);
    for (int xTile = 0; xTile <= xTileCount; xTile++) {
        for (int yTile = 0; yTile <= yTileCount; yTile++) {
            int w = xTile == xTileCount ? xRemainder : TEX_WIDTH;
            int h = yTile == yTileCount ? yRemainder : TEX_HEIGHT;
            int x = bounds.x + xTile * TEX_WIDTH;
            int y = yStart - (yTile + 1) * TEX_HEIGHT;
            if (bounds.width > 0 && h > 0) {
                int maskTop = TEX_HEIGHT - h;
                int maskRight = TEX_WIDTH - w;
                drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 100);
            }
        }
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Fluid(net.minecraftforge.fluids.Fluid) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 15 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project BuildCraft by BuildCraft.

the class SpriteHolderRegistry method exportTextureMap.

public static void exportTextureMap() {
    if (!DEBUG) {
        return;
    }
    TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
    GlStateManager.bindTexture(map.getGlTextureId());
    for (int l = 0; l < 4; l++) {
        int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, l, GL11.GL_TEXTURE_WIDTH);
        int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, l, GL11.GL_TEXTURE_HEIGHT);
        GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
        GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
        int totalSize = width * height;
        IntBuffer intbuffer = BufferUtils.createIntBuffer(totalSize);
        int[] aint = new int[totalSize];
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, l, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer);
        intbuffer.get(aint);
        BufferedImage bufferedimage = new BufferedImage(width, height, 2);
        bufferedimage.setRGB(0, 0, width, height, aint, 0, width);
        try {
            ImageIO.write(bufferedimage, "png", new File("bc_spritemap_" + l + ".png"));
        } catch (IOException io) {
            BCLog.logger.warn(io);
        }
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) IntBuffer(java.nio.IntBuffer) IOException(java.io.IOException) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Aggregations

TextureMap (net.minecraft.client.renderer.texture.TextureMap)84 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)42 ResourceLocation (net.minecraft.util.ResourceLocation)40 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)21 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)19 BlockPos (net.minecraft.util.math.BlockPos)13 Fluid (net.minecraftforge.fluids.Fluid)10 FluidStack (net.minecraftforge.fluids.FluidStack)9 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)6 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)6 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)5 EnumFacing (net.minecraft.util.EnumFacing)5 World (net.minecraft.world.World)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)4 Map (java.util.Map)4 IBlockState (net.minecraft.block.state.IBlockState)4 Tessellator (net.minecraft.client.renderer.Tessellator)4 FluidTank (net.minecraftforge.fluids.FluidTank)4