Some color fixes

This commit is contained in:
Vincent Lee committed 2020-02-20 21:00:12 -06:00
1 parent c19c4ecbb3
commit 1e280976c4
3 files changed
+20 -22

No files matched your search

@@ -301,10 +301,12 @@ public final class RenderHelper {
/**
* @param color Must include alpha
*/
// [VanillaCopy] ItemRenderer.renderItem with simplifications + color support
public static void renderItemCustomColor(LivingEntity entity, ItemStack stack, int color, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
// [VanillaCopy] ItemRenderer.renderItem with simplifications + color support + custom model
public static void renderItemCustomColor(LivingEntity entity, ItemStack stack, int color, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay, @Nullable IBakedModel model) {
ms.push();
IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(stack, entity.world, entity);
if (model == null) {
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(stack, entity.world, entity);
}
model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ms, model, ItemCameraTransforms.TransformType.NONE, false);
ms.translate(-0.5D, -0.5D, -0.5D);
if (!model.isBuiltInRenderer()) {
@@ -319,6 +321,10 @@ public final class RenderHelper {
ms.pop();
}
public static void renderItemCustomColor(LivingEntity entity, ItemStack stack, int color, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
renderItemCustomColor(entity, stack, color, ms, buffers, light, overlay, null);
}
// [VanillaCopy] ItemRenderer with custom color
private static void renderBakedItemModel(IBakedModel model, ItemStack stack, int color, int light, int overlay, MatrixStack ms, IVertexBuilder buffer) {
Random random = new Random();
@@ -333,7 +339,7 @@ public final class RenderHelper {
renderBakedItemQuads(ms, buffer, color, model.getQuads((BlockState)null, (Direction)null, random), stack, light, overlay);
}
// [VanillaCopy] ItemRenderer, with custom color
// [VanillaCopy] ItemRenderer, with custom color + alpha support
private static void renderBakedItemQuads(MatrixStack ms, IVertexBuilder buffer, int color, List<BakedQuad> quads, ItemStack stack, int light, int overlay) {
MatrixStack.Entry matrixstack$entry = ms.peek();
@@ -343,7 +349,6 @@ public final class RenderHelper {
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
// Botania: support alpha
float alpha = ((color >> 24) & 0xFF) / 255.0F;
buffer.addVertexData(matrixstack$entry, bakedquad, f, f1, f2, alpha, light, overlay, true);
}
@@ -202,12 +202,8 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
case ORANGE_SHADES:
ms.scale(1.25f, 1.25f, 1.25f);
ms.translate(0F, 0.04F, 0F);
/* todo 1.15
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 0.7F);
*/
renderItem(stack, ms, buffers, light);
int color = 0xFFFFFF | (178 << 24);
RenderHelper.renderItemCustomColor(player, stack, color, ms, buffers, light, OverlayTexture.DEFAULT_UV);
break;
case GROUCHO_GLASSES:
ms.scale(1.5F, 1.5F, 1.5F);
@@ -324,9 +324,10 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
float h = 0.2F;
float i = 0.15F;
float s = 1F;
int color = -1;
boolean fullbright = false;
ms.push();
boolean fullbright = false;
switch (meta) {
case 1: { // Jibril
@@ -370,8 +371,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
rz = 0F;
ry = -rx;
rx = 0F;
// todo 1.15
RenderSystem.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F);
float alpha = 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F;
color = 0xFFFFFF | ((int) (alpha * 255F)) << 24;
break;
}
case 8: { // Mega Ultra Chicken
@@ -384,8 +385,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
rx = 0F;
h = 1.1F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F));
// todo 1.15
RenderSystem.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F));
float alpha = 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F);
color = 0xFFFFFF | ((int) (alpha * 255F)) << 24;
}
}
@@ -403,10 +404,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(ry));
ms.scale(s, s, s);
IVertexBuilder buffer = buffers.getBuffer(Atlases.getEntityTranslucent());
Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer()
.render(ms.peek(), buffer, null, model, 1, 1, 1, fullbright ? 0xF000F0 : light, OverlayTexture.DEFAULT_UV);
RenderHelper.renderItemCustomColor(player, stack, color, ms, buffers, light, OverlayTexture.DEFAULT_UV, model);
ms.pop();
if(meta != 2) { // Sephiroth
@@ -416,8 +414,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(rx));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(ry));
ms.scale(s, s, s);
Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer()
.render(ms.peek(), buffer, null, model, 1, 1, 1, fullbright ? 0xF000F0 : light, OverlayTexture.DEFAULT_UV);
RenderHelper.renderItemCustomColor(player, stack, color, ms, buffers, light, OverlayTexture.DEFAULT_UV, model);
ms.pop();
}