net.minecraft.client.renderer.texture.TextureUtil Java Examples

The following examples show how to use net.minecraft.client.renderer.texture.TextureUtil. 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: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static List<CCQuad> applyItemTint(List<CCQuad> quads, ItemStack stack) {
    List<CCQuad> retQuads = new LinkedList<>();
    for (CCQuad quad : quads) {
        int colour = -1;

        if (quad.hasTint()) {
            colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.tintIndex);

            if (EntityRenderer.anaglyphEnable) {
                colour = TextureUtil.anaglyphColor(colour);
            }
            colour = colour | 0xFF000000;
        }
        CCQuad copyQuad = quad.copy();

        Colour c = new ColourARGB(colour);
        for (Colour qC : copyQuad.colours) {
            qC.multiply(c);
        }
        retQuads.add(copyQuad);
    }

    return retQuads;
}
 
Example #2
Source File: TextureURL.java    From Custom-Main-Menu with MIT License 6 votes vote down vote up
@Override
public void bind()
{
	if (this.textureID != -1)
	{
		GlStateManager.bindTexture(this.textureID);
	}
	else
	{
		if (bi != null)
		{
			setTextureID(TextureUtil.uploadTextureImageAllocate(GL11.glGenTextures(), bi, false, false));
			bind();
			return;
		}
		CustomMainMenu.bindTransparent();
	}
}
 
Example #3
Source File: RenderUtils.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Reimplement vanilla item so we can draw pearl stacks with opacity support.
 * + FIX THE OPACITY RENDERING.
 */
private static void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack) {
	color &= 0xFF000000;
	boolean flag = !stack.isEmpty();
	int i = 0;

	for (int j = quads.size(); i < j; ++i) {
		BakedQuad bakedquad = quads.get(i);
		int k = color | 0xFFFFFF;

		if (flag && bakedquad.hasTintIndex()) {
			k = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, bakedquad.getTintIndex());

			if (EntityRenderer.anaglyphEnable) {
				k = TextureUtil.anaglyphColor(k);
			}

			k &= 0xFFFFFF;
			k |= color;
		}

		LightUtil.renderQuadColor(renderer, bakedquad, k);
	}
}
 
Example #4
Source File: NewThreadDownloadImageData.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void checkTextureUploaded() {
	if (!textureUploaded)
		if (bufferedImage != null) {
			if (textureLocation != null)
				deleteGlTexture();

			TextureUtil.uploadTextureImage(super.getGlTextureId(), bufferedImage);
			if (imgDownload != null) {
				BufferedImage oldStyleImg = imgDownload.getOldSyleImage();
				Minecraft.getMinecraft().getTextureManager().loadTexture(resLocationOld, new DynamicTexture(oldStyleImg));
			}
			textureUploaded = true;
		}
}
 
Example #5
Source File: TextureCalendar.java    From Artifacts with MIT License 5 votes vote down vote up
public void updateAnimation()
{
    if (!this.framesTextureData.isEmpty())
    {
        Minecraft minecraft = Minecraft.getMinecraft();
        
        int i = frameCounter;
        if (minecraft.theWorld != null && minecraft.thePlayer != null)
        {
        	if (!minecraft.theWorld.provider.isSurfaceWorld())
            {
        		netherAnim++;
        		if(netherAnim > 8) {
        			netherAnim = 0;
                 i += (Math.random()*3)-1;
                 if(i < 0)
                 	i += 8;
                 if(i > 7)
                 	i -= 8;
        		}
            }
        	else {
        		i = minecraft.theWorld.getMoonPhase();
        	}
         //System.out.println("Moon: " + minecraft.theWorld.getMoonPhase());
        }
        if (i != this.frameCounter)
        {
         //System.out.println("Moon: " + i + "," + minecraft.theWorld.getCurrentMoonPhaseFactor());
            this.frameCounter = i;
            TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
            //TextureUtil.uploadTextureSub((int[])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
        }
    }
}
 
Example #6
Source File: DisposableDynamicTexture.java    From OpenModsLib with MIT License 5 votes vote down vote up
public void resize(int width, int height) {
	if (width != this.width || height != this.height) {
		this.width = width;
		this.height = height;
		TextureUtil.allocateTexture(getGlTextureId(), width, height);
	}
}
 
Example #7
Source File: TextureSpecial.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void updateAnimation() {
    if (textureFX != null) {
        textureFX.update();
        if (textureFX.changed()) {
            int[][] mipmaps = new int[mipmapLevels + 1][];
            mipmaps[0] = textureFX.imageData;
            //TODO mipmaps = prepareAnisotropicFiltering(mipmaps);
            mipmaps = TextureUtil.generateMipmapData(mipmapLevels, width, mipmaps);
            TextureUtil.uploadTextureMipmap(mipmaps, width, height, originX, originY, false, false);
        }
    }
}
 
Example #8
Source File: IconHelper.java    From AgriCraft with MIT License 5 votes vote down vote up
private DefaultIcon(String location) {
    super(location);
    this.width = 16;
    this.height = 16;
    this.framesTextureData = new ArrayList<>(1);
    this.framesTextureData.add(new int[][]{TextureUtil.MISSING_TEXTURE_DATA});
}
 
Example #9
Source File: TextureApng.java    From Custom-Main-Menu with MIT License 5 votes vote down vote up
@Override
public void bind()
{
	if (!loaded)
	{
		load();
		loaded = true;
	}

	if (errored)
	{
		GlStateManager.bindTexture(TextureUtil.MISSING_TEXTURE.getGlTextureId());
		return;
	}
	
	while (System.currentTimeMillis() - lastTimeStamp >= currentFrameDelay)
	{
		currentFrame++;
		if (currentFrame > animationControl.numFrames - 1)
		{
			currentFrame = 0;
		}

		Frame f = frames.get(currentFrame);

		float numerator = f.control.delayNumerator;
		float denominator = f.control.delayDenominator > 0 ? f.control.delayDenominator : 100;

		this.lastTimeStamp += currentFrameDelay;
		this.currentFrameDelay = (int) ((numerator / denominator) * 1000);
	}

	GlStateManager.bindTexture(frameTextureID.get(frames.get(currentFrame)));
}
 
Example #10
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private BufferedImage screenshot() {
    Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
    Dimension mcSize = GuiDraw.displayRes();
    Dimension texSize = mcSize;

    if (OpenGlHelper.isFramebufferEnabled())
        texSize = new Dimension(fb.framebufferTextureWidth, fb.framebufferTextureHeight);

    int k = texSize.width * texSize.height;
    if (pixelBuffer == null || pixelBuffer.capacity() < k) {
        pixelBuffer = BufferUtils.createIntBuffer(k);
        pixelValues = new int[k];
    }

    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();

    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(fb.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, texSize.width, texSize.height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }

    pixelBuffer.get(pixelValues);
    TextureUtil.processPixelValues(pixelValues, texSize.width, texSize.height);

    BufferedImage img = new BufferedImage(mcSize.width, mcSize.height, BufferedImage.TYPE_INT_ARGB);
    if (OpenGlHelper.isFramebufferEnabled()) {
        int yOff = texSize.height - mcSize.height;
        for (int y = 0; y < mcSize.height; ++y)
            for (int x = 0; x < mcSize.width; ++x)
                img.setRGB(x, y, pixelValues[(y + yOff) * texSize.width + x]);
    } else {
        img.setRGB(0, 0, texSize.width, height, pixelValues, 0, texSize.width);
    }

    return img;
}
 
Example #11
Source File: PrismarineIcon.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void updateAnimationInterpolated() throws IllegalArgumentException, IllegalAccessException {
	AnimationMetadataSection animationMetadata = (AnimationMetadataSection) fanimationMetadata.get(this);

	double d0 = 1.0D - tickCounter / (double) animationMetadata.getFrameTimeSingle(frameCounter);
	int i = animationMetadata.getFrameIndex(frameCounter);
	int j = animationMetadata.getFrameCount() == 0 ? framesTextureData.size() : animationMetadata.getFrameCount();
	int k = animationMetadata.getFrameIndex((frameCounter + 1) % j);

	if (i != k && k >= 0 && k < framesTextureData.size()) {
		int[][] aint = (int[][]) framesTextureData.get(i);
		int[][] aint1 = (int[][]) framesTextureData.get(k);

		if (interpolatedFrameData == null || interpolatedFrameData.length != aint.length)
			interpolatedFrameData = new int[aint.length][];

		for (int l = 0; l < aint.length; l++) {
			if (interpolatedFrameData[l] == null)
				interpolatedFrameData[l] = new int[aint[l].length];

			if (l < aint1.length && aint1[l].length == aint[l].length)
				for (int i1 = 0; i1 < aint[l].length; ++i1) {
					int j1 = aint[l][i1];
					int k1 = aint1[l][i1];
					int l1 = (int) (((j1 & 16711680) >> 16) * d0 + ((k1 & 16711680) >> 16) * (1.0D - d0));
					int i2 = (int) (((j1 & 65280) >> 8) * d0 + ((k1 & 65280) >> 8) * (1.0D - d0));
					int j2 = (int) ((j1 & 255) * d0 + (k1 & 255) * (1.0D - d0));
					interpolatedFrameData[l][i1] = j1 & -16777216 | l1 << 16 | i2 << 8 | j2;
				}
		}

		TextureUtil.uploadTextureMipmap(interpolatedFrameData, width, height, originX, originY, false, false);
	}
}
 
Example #12
Source File: IslandWarpGui.java    From SkyblockAddons with MIT License 5 votes vote down vote up
Island(String label, int x, int y) {
    this.label = label;
    this.x = x;
    this.y = y;

    this.resourceLocation = new ResourceLocation("skyblockaddons", "islands/"+this.name().toLowerCase(Locale.US).replace("_", "")+".png");
    try {
        bufferedImage = TextureUtil.readBufferedImage(Minecraft.getMinecraft().getResourceManager().getResource(this.resourceLocation).getInputStream());
        this.w = bufferedImage.getWidth();
        this.h = bufferedImage.getHeight();

        if (label.equals("The End")) {
            IslandWarpGui.IMAGE_SCALED_DOWN_FACTOR = this.w/573F; // The original end HD texture is 573 pixels wide.

        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    this.w /= IMAGE_SCALED_DOWN_FACTOR;
    this.h /= IMAGE_SCALED_DOWN_FACTOR;

    if (this.y + this.h > TOTAL_HEIGHT) {
        TOTAL_HEIGHT = this.y + this.h;
    }
    if (this.x + this.w > TOTAL_WIDTH) {
        TOTAL_WIDTH = this. x+ this.w;
    }
}
 
Example #13
Source File: HyperiumAbstractResourcePack.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BufferedImage getPackImage(int iconSize) throws IOException {
    BufferedImage originalIcon = TextureUtil.readBufferedImage(((IMixinAbstractResourcePack) parent).callGetInputStreamByName("pack.png"));
    if (originalIcon == null) return null;
    BufferedImage resizedIcon = new BufferedImage(iconSize, iconSize, BufferedImage.TYPE_INT_ARGB);
    Graphics graphics = resizedIcon.getGraphics();
    graphics.drawImage(originalIcon, 0, 0, iconSize, iconSize, null);
    graphics.dispose();
    return resizedIcon;
}
 
Example #14
Source File: CustomTexture.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return ID of this texture loaded into memory
 * @throws IllegalStateException If the texture was unloaded via {@link #unload()}
 */
public int getTextureId() {
    if (unloaded)
        throw new IllegalStateException("Texture unloaded");

    if (textureId == -1)
        textureId = TextureUtil.uploadTextureImageAllocate(TextureUtil.glGenTextures(), image, true, true);

    return textureId;
}
 
Example #15
Source File: ButtonBanner.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Create a button for toggling a feature on or off. This includes all the {@link Feature}s that have a proper ID.
 */
public ButtonBanner(double x, double y) {
    super(0, (int)x, (int)y, "");
    this.main = SkyblockAddons.getInstance();
    logger = main.getLogger();

    if (!grabbedBanner) {
        grabbedBanner = true;
        bannerImage = null;
        banner = null;

        new Thread(() -> {
            try {
                URL url = new URL(this.main.getOnlineData().getBannerImageURL());
                HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                connection.setReadTimeout(5000);
                connection.addRequestProperty("User-Agent", Utils.USER_AGENT);

                bannerImage = TextureUtil.readBufferedImage(connection.getInputStream());

                connection.disconnect();

                this.width = bannerImage.getWidth();
                this.height = bannerImage.getHeight();
            } catch (IOException ex) {
                logger.info("Couldn't grab main menu banner image from URL, falling back to local banner.");
            }
        }).start();
    }

    xPosition -= WIDTH/2;

    if (bannerImage != null) {
        this.width = bannerImage.getWidth();
        this.height = bannerImage.getHeight();
    }
}
 
Example #16
Source File: ColorSelectionGui.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Creates a gui to allow you to select a color for a specific feature.
 *
 * @param feature The feature that this color is for.
 * @param lastTab The previous tab that you came from.
 * @param lastPage The previous page.
 */
ColorSelectionGui(Feature feature, EnumUtils.GUIType lastGUI, EnumUtils.GuiTab lastTab, int lastPage) {
    this.feature = feature;
    this.lastTab = lastTab;
    this.lastGUI = lastGUI;
    this.lastPage = lastPage;

    try {
        COLOR_PICKER_IMAGE = TextureUtil.readBufferedImage(Minecraft.getMinecraft().getResourceManager().getResource(COLOR_PICKER).getInputStream());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #17
Source File: GolemGuiTexture.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void loadTexture(IResourceManager resourceManager) throws IOException {
    this.deleteGlTexture();
    InputStream inputstream = null;

    try
    {
        IResource iresource = resourceManager.getResource(this.textureLocation);
        inputstream = iresource.getInputStream();
        BufferedImage bufferedimage = manipulateImage(resourceManager, ImageIO.read(inputstream));

        boolean flag = false;
        boolean flag1 = false;

        if (iresource.hasMetadata())
        {
            try
            {
                TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");

                if (texturemetadatasection != null)
                {
                    flag = texturemetadatasection.getTextureBlur();
                    flag1 = texturemetadatasection.getTextureClamp();
                }
            }
            catch (RuntimeException runtimeexception)
            {
                LOGGER.warn("Failed reading metadata of: " + this.textureLocation, runtimeexception);
            }
        }

        TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
    }
    finally
    {
        if (inputstream != null)
        {
            inputstream.close();
        }
    }
}
 
Example #18
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private BufferedImage screenshot() {
    Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
    Dimension mcSize = GuiDraw.getDisplayRes();
    Dimension texSize = mcSize;

    if (OpenGlHelper.isFramebufferEnabled()) {
        texSize = new Dimension(fb.framebufferTextureWidth, fb.framebufferTextureHeight);
    }

    int k = texSize.width * texSize.height;
    if (pixelBuffer == null || pixelBuffer.capacity() < k) {
        pixelBuffer = BufferUtils.createIntBuffer(k);
        pixelValues = new int[k];
    }

    GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    pixelBuffer.clear();

    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.bindTexture(fb.framebufferTexture);
        GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    } else {
        GL11.glReadPixels(0, 0, texSize.width, texSize.height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
    }

    pixelBuffer.get(pixelValues);
    TextureUtil.processPixelValues(pixelValues, texSize.width, texSize.height);

    BufferedImage img = new BufferedImage(mcSize.width, mcSize.height, BufferedImage.TYPE_INT_ARGB);
    if (OpenGlHelper.isFramebufferEnabled()) {
        int yOff = texSize.height - mcSize.height;
        for (int y = 0; y < mcSize.height; ++y) {
            for (int x = 0; x < mcSize.width; ++x) {
                img.setRGB(x, y, pixelValues[(y + yOff) * texSize.width + x]);
            }
        }
    } else {
        img.setRGB(0, 0, texSize.width, height, pixelValues, 0, texSize.width);
    }

    return img;
}
 
Example #19
Source File: BlockModelRendererSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderQuadsFlat(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, int brightnessIn, boolean ownBrightness, BufferBuilder buffer, List<BakedQuad> list, BitSet bitSet)
{
    Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn);
    double d0 = (double)posIn.getX() + vec3d.x;
    double d1 = (double)posIn.getY() + vec3d.y;
    double d2 = (double)posIn.getZ() + vec3d.z;
    int i = 0;

    for (int j = list.size(); i < j; ++i)
    {
        BakedQuad bakedquad = list.get(i);

        if (ownBrightness)
        {
            this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, bitSet);
            BlockPos blockpos = bitSet.get(0) ? posIn.offset(bakedquad.getFace()) : posIn;
            brightnessIn = stateIn.getPackedLightmapCoords(blockAccessIn, blockpos);
        }

        buffer.addVertexData(bakedquad.getVertexData());
        buffer.putBrightness4(brightnessIn, brightnessIn, brightnessIn, brightnessIn);

        if (bakedquad.hasTintIndex())
        {
            int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            float f = (float)(k >> 16 & 255) / 255.0F;
            float f1 = (float)(k >> 8 & 255) / 255.0F;
            float f2 = (float)(k & 255) / 255.0F;
            buffer.putColorMultiplier(f, f1, f2, 4);
            buffer.putColorMultiplier(f, f1, f2, 3);
            buffer.putColorMultiplier(f, f1, f2, 2);
            buffer.putColorMultiplier(f, f1, f2, 1);
        }

        buffer.putPosition(d0, d1, d2);
    }
}
 
Example #20
Source File: TextureApng.java    From Custom-Main-Menu with MIT License 4 votes vote down vote up
private void load()
{
	frameTextureID = new HashMap<Frame, Integer>();
	try
	{
		InputStream inputStream = Minecraft.getMinecraft().getResourceManager().getResource(rl).getInputStream();

		Argb8888BitmapSequence pngContainer = Png.readArgb8888BitmapSequence(inputStream);
		animationControl = pngContainer.getAnimationControl();

		frames = Collections.synchronizedList(pngContainer.getAnimationFrames());

		BufferedImage canvas = new BufferedImage(pngContainer.defaultImage.width, pngContainer.defaultImage.height, BufferedImage.TYPE_INT_ARGB);
		Graphics2D graphics = canvas.createGraphics();
		graphics.setBackground(new Color(0, 0, 0, 0));

		BufferedImage frameBackup = new BufferedImage(pngContainer.defaultImage.width, pngContainer.defaultImage.height, BufferedImage.TYPE_INT_ARGB);
		Graphics2D graphicsBackup = frameBackup.createGraphics();
		graphicsBackup.setBackground(new Color(0, 0, 0, 0));

		for (int i = 0; i < frames.size(); i++)
		{
			Frame f = frames.get(i);

			switch (f.control.blendOp)
			{
				case 0:
					graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
					break;
				case 1:
					graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
					break;
			}

			Argb8888Bitmap bitmap = f.bitmap;

			BufferedImage buffered = new BufferedImage(bitmap.width, bitmap.height, BufferedImage.TYPE_INT_ARGB);
			buffered.setRGB(0, 0, bitmap.width, bitmap.height, bitmap.getPixelArray(), 0, bitmap.width);

			graphicsBackup.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
			graphicsBackup.drawImage(canvas, 0, 0, canvas.getWidth(), canvas.getHeight(), null);

			graphics.drawImage(buffered, f.control.xOffset, f.control.yOffset, f.control.xOffset + f.control.width, f.control.yOffset + f.control.height, 0, 0, buffered.getWidth(), buffered.getHeight(), null);

			frameTextureID.put(f, TextureUtil.uploadTextureImageAllocate(GL11.glGenTextures(), canvas, false, false));

			switch (f.control.disposeOp)
			{
				case 0:
					break;
				case 1:
					graphics.clearRect(f.control.xOffset, f.control.yOffset, f.control.width, f.control.height);
					break;
				case 2:
					graphics.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
					graphics.drawImage(frameBackup, 0, 0, canvas.getWidth(), canvas.getHeight(), null);
					break;
			}
		}
		
		graphics.dispose();
		graphicsBackup.dispose();
	}
	catch (Exception e)
	{
		e.printStackTrace();
		errored = true;
		return;
	}
	
	Frame frame = frames.get(0);

	float numerator = frame.control.delayNumerator;
	float denominator = frame.control.delayDenominator > 0 ? frame.control.delayDenominator : 100;

	this.currentFrameDelay = (int) (numerator / denominator * 1000);
	this.lastTimeStamp = System.currentTimeMillis();
}
 
Example #21
Source File: BlockModelRendererSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderQuadsSmooth(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, BufferBuilder buffer, List<BakedQuad> list, float[] quadBounds, BitSet bitSet, AmbientOcclusionFace aoFace)
{
    Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn);
    double x = (double)posIn.getX() + vec3d.x;
    double y = (double)posIn.getY() + vec3d.y;
    double z = (double)posIn.getZ() + vec3d.z;
    int i = 0;

    for (int j = list.size(); i < j; ++i)
    {
        BakedQuad bakedquad = list.get(i);
        this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), quadBounds, bitSet);
        aoFace.updateVertexBrightness(blockAccessIn, stateIn, posIn, bakedquad.getFace(), quadBounds, bitSet);
        buffer.addVertexData(bakedquad.getVertexData());
        buffer.putBrightness4(aoFace.vertexBrightness[0], aoFace.vertexBrightness[1], aoFace.vertexBrightness[2], aoFace.vertexBrightness[3]);

        if (bakedquad.hasTintIndex())
        {
            int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            float f = (float)(k >> 16 & 255) / 255.0F;
            float f1 = (float)(k >> 8 & 255) / 255.0F;
            float f2 = (float)(k & 255) / 255.0F;
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0] * f, aoFace.vertexColorMultiplier[0] * f1, aoFace.vertexColorMultiplier[0] * f2, 4);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1] * f, aoFace.vertexColorMultiplier[1] * f1, aoFace.vertexColorMultiplier[1] * f2, 3);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2] * f, aoFace.vertexColorMultiplier[2] * f1, aoFace.vertexColorMultiplier[2] * f2, 2);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3] * f, aoFace.vertexColorMultiplier[3] * f1, aoFace.vertexColorMultiplier[3] * f2, 1);
        }
        else
        {
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], 4);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], 3);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], 2);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], 1);
        }

        buffer.putPosition(x, y, z);
    }
}
 
Example #22
Source File: DisposableDynamicTexture.java    From OpenModsLib with MIT License 4 votes vote down vote up
public void update() {
	Preconditions.checkNotNull(dynamicTextureData, "Texture not allocated");
	TextureUtil.uploadTexture(getGlTextureId(), dynamicTextureData, width, height);
}