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);
}
}
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);
}
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);
}
}
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);
}
}
}
}
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);
}
}
}
Aggregations