Skip to content

Instantly share code, notes, and snippets.

@gigaherz
Created July 24, 2020 17:53
Show Gist options
  • Save gigaherz/79ff72a560d6066a83ac6721759e0d1c to your computer and use it in GitHub Desktop.
Save gigaherz/79ff72a560d6066a83ac6721759e0d1c to your computer and use it in GitHub Desktop.
package gigaherz.signbutton;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
public class MultiplyAlphaRenderTypeBuffer implements IRenderTypeBuffer
{
private final IRenderTypeBuffer inner;
private final float constantAlpha;
public MultiplyAlphaRenderTypeBuffer(IRenderTypeBuffer inner, float constantAlpha)
{
this.inner = inner;
this.constantAlpha = constantAlpha;
}
@Override
public IVertexBuilder getBuffer(RenderType type)
{
return new MultiplyAlphaVertexBuilder(inner.getBuffer(type), constantAlpha);
}
}
package gigaherz.signbutton;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.Matrix3f;
import net.minecraft.client.renderer.Matrix4f;
public class MultiplyAlphaVertexBuilder implements IVertexBuilder
{
private final IVertexBuilder inner;
private final float constantAlpha;
public MultiplyAlphaVertexBuilder(IVertexBuilder inner, float constantAlpha)
{
this.inner = inner;
this.constantAlpha = constantAlpha;
}
@Override
public IVertexBuilder pos(double x, double y, double z)
{
return inner.pos(x,y,z);
}
@Override
public IVertexBuilder pos(Matrix4f matrixIn, float x, float y, float z)
{
return inner.pos(matrixIn, x, y, z);
}
@Override
public IVertexBuilder color(int red, int green, int blue, int alpha)
{
return inner.color(red,green,blue,(int)(alpha*constantAlpha));
}
@Override
public IVertexBuilder tex(float u, float v)
{
return inner.tex(u, v);
}
@Override
public IVertexBuilder overlay(int u, int v)
{
return inner.overlay(u, v);
}
@Override
public IVertexBuilder lightmap(int u, int v)
{
return inner.lightmap(u, v);
}
@Override
public IVertexBuilder normal(float x, float y, float z)
{
return inner.normal(x,y,z);
}
@Override
public IVertexBuilder normal(Matrix3f matrixIn, float x, float y, float z)
{
return inner.normal(matrixIn, x, y, z);
}
@Override
public void endVertex()
{
inner.endVertex();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment