Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Problem with IVertexBuilder color


Recommended Posts

I have create a quad with TER, it has the texture of water_still from vanilla Minecraft. The problem is that the texture is grey and I want to add it some color. 

I know how to do it, but when I add some color (red for example, whis is rgb(255, 0, 0)) it looks really strange. I think the problem is with the alpha.

This is the quad code:

private void addVertex(Matrix4f matrix, Matrix3f matrixNormal, IVertexBuilder vertexBuilder, float red, float green, float blue, float alpha, int combinedOverlay, int combinedLight) {
		vertexBuilder.vertex(matrix, 0.8125F, 0.9375F, 0.1875F).color(red, green, blue, alpha).uv(0.1875F, 0.005859375F).overlayCoords(combinedOverlay).uv2(combinedLight).normal(matrixNormal, 0.0F, 1.0F, 0.0F).endVertex();
		vertexBuilder.vertex(matrix, 0.1875F, 0.9375F, 0.1875F).color(red, green, blue, alpha).uv(0.8125F, 0.005859375F).overlayCoords(combinedOverlay).uv2(combinedLight).normal(matrixNormal, 0.0F, 1.0F, 0.0F).endVertex();
		vertexBuilder.vertex(matrix, 0.1875F, 0.9375F, 0.8125F).color(red, green, blue, alpha).uv(0.8125F, 0.025390625F).overlayCoords(combinedOverlay).uv2(combinedLight).normal(matrixNormal, 0.0F, 1.0F, 0.0F).endVertex();
		vertexBuilder.vertex(matrix, 0.8125F, 0.9375F, 0.8125F).color(red, green, blue, alpha).uv(0.1875F, 0.025390625F).overlayCoords(combinedOverlay).uv2(combinedLight).normal(matrixNormal, 0.0F, 1.0F, 0.0F).endVertex();
	}

and with this line I call it in the render function:

this.addVertex(matrix4f, matrixNormal, vertexBuilder, 255, 0, 0, 1, combinedOverlay, combinedLight);

 

With this code, I think, the quad must be red, but with an alpha, but as yo can see isn´t red, it is back

001.png.f1078fa97b9d4299f5c8eb24a4727291.png

If I change the alpha to 255, the error still:

001.png.c95501f609b2e6d19ff028cc856cf7bf.png

also is I change the alpha to 0 it looks like if it is 255.

 

Thank you in advance

Link to post
Share on other sites

When colors are using float type then you use values from 0 to 1. When colors are using int then you use values from 0 to 255. So, you can change to

this.addVertex(matrix4f, matrixNormal, vertexBuilder, 1, 0, 0, 1, combinedOverlay, combinedLight);

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I think I've found the cause of the problem.  A recently updated Java installation installed just the JRE instead of the JDK, and was causing gradle to be unable to find tools.jar.  Installing the updated version of the JDK seems to have fixed the problem.  Thank you, and I apologize for wasting your time.
    • Send me examples with entities if u have ^^
    • Minecraft 1.16.5 Forge latest  This is my /data/forge/loot_modifiers/global_loot_modifiers.json  { "replace": false, "entries": [ "multimod:blaze_loot" ] }   This my /data/multimod/loot_modifiers/blaze_loot.json (serialized json) { "conditions": [ { "condition": "minecraft:killed_by_player" }, { "condition": "minecraft:entity_properties", "predicate": { "type": "minecraft:blaze" }, "entity": "this" } ] }   and now I want that the Entity Blaze can drop my custom item (custom_item) in this GlobalLotModifiers.java package com.squidxtv.multimod.core.init; import com.google.gson.JsonObject; import net.minecraft.item.ItemStack; import net.minecraft.loot.LootContext; import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.LootModifier; import javax.annotation.Nonnull; import java.util.List; public class GlobalLootModifiers extends LootModifier { /** * Constructs a LootModifier. * * @param conditionsIn the ILootConditions that need to be matched before the loot is modified. */ protected GlobalLootModifiers(ILootCondition[] conditionsIn) { super(conditionsIn); } @Nonnull @Override public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { return null; } private static class Serializer extends GlobalLootModifierSerializer<GlobalLootModifiers> { @Override public GlobalLootModifiers read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) { return null; } @Override public JsonObject write(GlobalLootModifiers instance) { return null; } } } but how can I do this?
    • I tried to found debug.log, but I can't found that, would you tell me about the location of the debug.log?
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.