color me surprised

- move functionality of ColorHelper into a new Color class
- replace usage of java.awt.Color with our own color in most cases
This commit is contained in:
zelophed 2021-07-31 14:21:19 +02:00
parent 05d581c779
commit 0fe3230640
53 changed files with 582 additions and 411 deletions

View file

@ -5,7 +5,7 @@ import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
@ -47,7 +47,7 @@ public class KineticDebugger {
CreateClient.OUTLINER.chaseAABB("kineticSource", shape.bounds()
.move(toOutline))
.lineWidth(1 / 16f)
.colored(te.hasSource() ? ColorHelper.colorFromLong(te.network) : 0xffcc00);
.colored(te.hasSource() ? Color.generateFromLong(te.network).getRGB() : 0xffcc00);
if (state.getBlock() instanceof IRotate) {
Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.core.materials.BasicData;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3f;
@ -44,31 +44,17 @@ public class KineticData extends BasicData {
}
public KineticData setColor(KineticTileEntity te) {
if (te.hasSource()) {
setColor(te.network);
if (te.hasNetwork()) {
setColor(Color.generateFromLong(te.network));
}else {
setColor(0xFF, 0xFF, 0x00);
}
return this;
}
public KineticData setColor(Long l) {
if (l != null)
return setColor(l.longValue());
else {
setColor(0xFF, 0xFF, 0xFF);
return this;
}
return this;
}
private KineticData setColor(long l) {
int color = ColorHelper.colorFromLong(l);
byte r = (byte) ((color >> 16) & 0xFF);
byte g = (byte) ((color >> 8) & 0xFF);
byte b = (byte) (color & 0xFF);
setColor(r, g, b);
return this;
public KineticData setColor(Color c) {
setColor(c.getRed(), c.getGreen(), c.getBlue());
return this;
}
public KineticData setRotationalSpeed(float rotationalSpeed) {

View file

@ -11,7 +11,7 @@ import com.simibubi.create.foundation.render.Compartment;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -77,19 +77,18 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
buffer.light(light);
buffer.rotateCentered(Direction.get(AxisDirection.POSITIVE, axis), angle);
int white = 0xFFFFFF;
if (KineticDebugger.isActive()) {
rainbowMode = true;
buffer.color(te.hasNetwork() ? ColorHelper.colorFromLong(te.network) : white);
buffer.color(te.hasNetwork() ? Color.generateFromLong(te.network) : Color.WHITE);
} else {
float overStressedEffect = te.effects.overStressedEffect;
if (overStressedEffect != 0)
if (overStressedEffect > 0)
buffer.color(ColorHelper.mixColors(white, 0xFF0000, overStressedEffect));
buffer.color(Color.WHITE.mixWith(Color.RED, overStressedEffect));
else
buffer.color(ColorHelper.mixColors(white, 0x00FFBB, -overStressedEffect));
buffer.color(Color.WHITE.mixWith(Color.SPRING_GREEN, -overStressedEffect));
else
buffer.color(white);
buffer.color(Color.WHITE);
}
return buffer;

View file

@ -12,7 +12,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.VecHelper;
@ -225,7 +225,7 @@ public class CouplingRenderer {
.position()
.add(0, yOffset, 0);
int color = ColorHelper.mixColors(0xabf0e9, 0xee8572, (float) MathHelper
int color = Color.mixColors(0xabf0e9, 0xee8572, (float) MathHelper
.clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1));
CreateClient.OUTLINER.showLine(mainCart.getId() + "", mainCenter, connectedCenter)

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.fluids.particle;
import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.IParticleRenderType;
@ -43,7 +43,7 @@ public class FluidStackParticle extends SpriteTexturedParticle {
this.multiplyColor(fluid.getFluid()
.getAttributes()
.getColor(fluid));
this.xd = vx;
this.yd = vy;
this.zd = vz;
@ -98,12 +98,12 @@ public class FluidStackParticle extends SpriteTexturedParticle {
if (!onGround && level.random.nextFloat() < 1 / 8f)
return;
Vector3d rgb = ColorHelper.getRGB(fluid.getFluid()
Vector3d rgb = Color.vectorFromRGB(fluid.getFluid()
.getAttributes()
.getColor(fluid));
level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, rgb.x, rgb.y, rgb.z);
}
protected boolean canEvaporate() {
return fluid.getFluid() instanceof PotionFluid;
}

View file

@ -18,7 +18,7 @@ import com.simibubi.create.foundation.config.CClient;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.outliner.Outline;
@ -46,7 +46,7 @@ public class GoggleOverlayRenderer {
private static final List<Supplier<Boolean>> customGogglePredicates = new LinkedList<>();
private static final Map<Object, OutlineEntry> outlines = CreateClient.OUTLINER.getOutlines();
public static int hoverTicks = 0;
public static BlockPos lastHovered = null;
@ -74,15 +74,15 @@ public class GoggleOverlayRenderer {
BlockPos pos = result.getBlockPos();
ItemStack headSlot = mc.player.getItemBySlot(EquipmentSlotType.HEAD);
TileEntity te = world.getBlockEntity(pos);
if (lastHovered == null || lastHovered.equals(pos))
if (lastHovered == null || lastHovered.equals(pos))
hoverTicks++;
else
else
hoverTicks = 0;
lastHovered = pos;
boolean wearingGoggles = AllItems.GOGGLES.isIn(headSlot);
for (Supplier<Boolean> supplier : customGogglePredicates)
for (Supplier<Boolean> supplier : customGogglePredicates)
wearingGoggles |= supplier.get();
boolean hasGoggleInformation = te instanceof IHaveGoggleInformation;
@ -179,26 +179,25 @@ public class GoggleOverlayRenderer {
float fade = MathHelper.clamp((hoverTicks + partialTicks) / 12f, 0, 1);
Boolean useCustom = cfg.overlayCustomColor.get();
int colorBackground = useCustom ? cfg.overlayBackgroundColor.get()
: ColorHelper.applyAlpha(Theme.i(Theme.Key.VANILLA_TOOLTIP_BACKGROUND), .75f);
int colorBorderTop =
useCustom ? cfg.overlayBorderColorTop.get() : Theme.i(Theme.Key.VANILLA_TOOLTIP_BORDER, true);
int colorBorderBot =
useCustom ? cfg.overlayBorderColorBot.get() : Theme.i(Theme.Key.VANILLA_TOOLTIP_BORDER, false);
Color colorBackground = useCustom ?
new Color(cfg.overlayBackgroundColor.get()) :
Theme.c(Theme.Key.VANILLA_TOOLTIP_BACKGROUND).scaleAlpha(.75f);
Color colorBorderTop = useCustom ?
new Color(cfg.overlayBorderColorTop.get()) :
Theme.c(Theme.Key.VANILLA_TOOLTIP_BORDER, true).copy();
Color colorBorderBot = useCustom ?
new Color(cfg.overlayBorderColorBot.get()) :
Theme.c(Theme.Key.VANILLA_TOOLTIP_BORDER, false).copy();
if (fade < 1) {
ms.translate((1 - fade) * Math.signum(cfg.overlayOffsetX.get() + .5f) * 4, 0, 0);
int alphaMask = 0xFF000000;
if ((alphaMask & colorBackground) != 0)
colorBackground = ColorHelper.applyAlpha(colorBackground, fade);
if ((alphaMask & colorBorderTop) != 0)
colorBorderTop = ColorHelper.applyAlpha(colorBorderTop, fade);
if ((alphaMask & colorBorderBot) != 0)
colorBorderBot = ColorHelper.applyAlpha(colorBorderBot, fade);
colorBackground.scaleAlpha(fade);
colorBorderTop.scaleAlpha(fade);
colorBorderBot.scaleAlpha(fade);
}
GuiUtils.drawHoveringText(ms, tooltip, posX, posY, tooltipScreen.width, tooltipScreen.height, -1,
colorBackground, colorBorderTop, colorBorderBot, mc.font);
colorBackground.getRGB(), colorBorderTop.getRGB(), colorBorderBot.getRGB(), mc.font);
ItemStack item = AllItems.GOGGLES.asStack();
GuiGameElement.of(item)

View file

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.itemAssembly;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@ -36,7 +36,7 @@ public class SequencedAssemblyItem extends Item {
@Override
public int getRGBDurabilityForDisplay(ItemStack stack) {
return ColorHelper.mixColors(0xFF_46FFE0, 0xFF_FFC074, (float) getDurabilityForDisplay(stack));
return Color.mixColors(0xFF_46FFE0, 0xFF_FFC074, (float) getDurabilityForDisplay(stack));
}
}

View file

@ -5,7 +5,7 @@ import javax.annotation.Nonnull;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.fan.IAirCurrentSource;
import com.simibubi.create.content.contraptions.processing.InWorldProcessing;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.Blocks;
@ -102,7 +102,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
InWorldProcessing.Type type = source.getAirCurrent().getSegmentAt((float) distance);
if (type == InWorldProcessing.Type.SPLASHING) {
setColor(ColorHelper.mixColors(0x4499FF, 0x2277FF, level.random.nextFloat()));
setColor(Color.mixColors(0x4499FF, 0x2277FF, level.random.nextFloat()));
setAlpha(1f);
selectSprite(level.random.nextInt(3));
if (level.random.nextFloat() < 1 / 32f)
@ -114,7 +114,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
}
if (type == InWorldProcessing.Type.SMOKING) {
setColor(ColorHelper.mixColors(0x0, 0x555555, level.random.nextFloat()));
setColor(Color.mixColors(0x0, 0x555555, level.random.nextFloat()));
setAlpha(1f);
selectSprite(level.random.nextInt(3));
if (level.random.nextFloat() < 1 / 32f)
@ -126,7 +126,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
}
if (type == InWorldProcessing.Type.BLASTING) {
setColor(ColorHelper.mixColors(0xFF4400, 0xFF8855, level.random.nextFloat()));
setColor(Color.mixColors(0xFF4400, 0xFF8855, level.random.nextFloat()));
setAlpha(.5f);
selectSprite(level.random.nextInt(3));
if (level.random.nextFloat() < 1 / 32f)

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.particle;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft;
@ -38,7 +38,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle {
this.quadSize *= 0.75F;
this.lifetime = lifeSpan + this.random.nextInt(32);
this.setFadeColor(color);
this.setColor(ColorHelper.mixColors(color, 0xFFFFFF, .5f));
this.setColor(Color.mixColors(color, 0xFFFFFF, .5f));
this.setSpriteFromAge(sprite);
this.radius1 = radius1;
this.radius = radius1;

View file

@ -17,7 +17,7 @@ import com.simibubi.create.content.contraptions.relays.belt.transport.Transporte
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -307,7 +307,7 @@ public class InWorldProcessing {
world.addParticle(ParticleTypes.POOF, vec.x, vec.y + .25f, vec.z, 0, 1 / 16f, 0);
break;
case SPLASHING:
Vector3d color = ColorHelper.getRGB(0x0055FF);
Vector3d color = Color.vectorFromRGB(0x0055FF);
world.addParticle(new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1),
vec.x + (world.random.nextFloat() - .5f) * .5f, vec.y + .5f, vec.z + (world.random.nextFloat() - .5f) * .5f,
0, 1 / 8f, 0);

View file

@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlo
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
@ -22,34 +22,25 @@ import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.ForgeHooks;
public class BlazeBurnerTileEntity extends SmartTileEntity {
public static final int MAX_HEAT_CAPACITY = 10000;
private static final Vector3d EMPTY_COLOR = new Vector3d(0, 0, 0);
private final static Vector3d[][] PARTICLE_COLORS;
private final static Vector3d[] CREATIVE_PARTICLE_COLORS;
static {
int[][] colors = {
private final static Color[][] PARTICLE_COLORS = {
{ },
{ 0x3B141A, 0x47141A, 0x7A3B24, 0x854D26 },
{ 0x2A0103, 0x741B0A, 0xC38246, 0xCCBD78 },
{ 0x630B03, 0x8B3503, 0xBC8200, 0xCCC849 },
{ 0x1C6378, 0x4798B5, 0x4DA6C0, 0xBAC8CE }
};
int[] creativeColors = { 0x54295D, 0x6E3C76, 0xA5479F, 0x85157C };
PARTICLE_COLORS = new Vector3d[colors.length][];
for (int i = 0; i < colors.length; i++) {
PARTICLE_COLORS[i] = ColorHelper.toVectors(colors[i]);
}
CREATIVE_PARTICLE_COLORS = ColorHelper.toVectors(creativeColors);
}
{ new Color(0x3B141A), new Color(0x47141A), new Color(0x7A3B24), new Color(0x854D26) },
{ new Color(0x2A0103), new Color(0x741B0A), new Color(0xC38246), new Color(0xCCBD78) },
{ new Color(0x630B03), new Color(0x8B3503), new Color(0xBC8200), new Color(0xCCC849) },
{ new Color(0x1C6378), new Color(0x4798B5), new Color(0x4DA6C0), new Color(0xBAC8CE) }
};
private final static Color[] CREATIVE_PARTICLE_COLORS = {
new Color(0x54295D),
new Color(0x6E3C76),
new Color(0xA5479F),
new Color(0x85157C)
};
protected FuelType activeFuel;
protected int remainingBurnTime;
@ -296,23 +287,20 @@ public class BlazeBurnerTileEntity extends SmartTileEntity {
}
}
protected void spawnParticle(Vector3d color, float scale, int avgAge, boolean hot, double speed, double spread) {
protected void spawnParticle(Color color, float scale, int avgAge, boolean hot, double speed, double spread) {
Random random = level.getRandom();
level.addAlwaysVisibleParticle(
new CubeParticleData((float) color.x, (float) color.y, (float) color.z, scale, avgAge, hot),
new CubeParticleData(color.getRedAsFloat(), color.getGreenAsFloat(), color.getBlueAsFloat(), scale, avgAge, hot),
(double) worldPosition.getX() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread,
(double) worldPosition.getY() + 0.6D + (random.nextDouble() / 4.0),
(double) worldPosition.getZ() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, 0.0D, speed, 0.0D);
}
protected void spawnParticle(Vector3d[] colors, float scale, int avgAge, boolean hot, double speed, double spread) {
Vector3d color;
if (colors.length == 0) {
color = EMPTY_COLOR;
} else {
color = colors[(int) (Math.random() * colors.length)];
}
spawnParticle(color, scale, avgAge, hot, speed, spread);
protected void spawnParticle(Color[] colors, float scale, int avgAge, boolean hot, double speed, double spread) {
if (colors.length == 0)
return;
spawnParticle(colors[(int) (Math.random() * colors.length)], scale, avgAge, hot, speed, spread);
}
protected void spawnParticle(HeatLevel heatLevel, float scale, int avgAge, boolean hot, double speed, double spread) {

View file

@ -5,7 +5,7 @@ import java.util.Random;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper;
@ -70,9 +70,9 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
/*
* FIXME: Is there a new way of doing this in 1.16? Or cn we just delete it?
*
*
* @SuppressWarnings("deprecation")
*
*
* @Override
* public MaterialColor getMaterialColor(BlockState state, IBlockReader worldIn, BlockPos pos) {
* return Blocks.SPRUCE_PLANKS.getMaterialColor(state, worldIn, pos);
@ -152,7 +152,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
if (!shouldRenderHeadOnFace(worldIn, pos, stateIn, face))
continue;
Vector3d rgb = ColorHelper.getRGB(color);
Vector3d rgb = Color.vectorFromRGB(color);
Vector3d faceVec = Vector3d.atLowerCornerOf(face.getNormal());
Direction positiveFacing = Direction.get(AxisDirection.POSITIVE, face.getAxis());
Vector3d positiveFaceVec = Vector3d.atLowerCornerOf(positiveFacing.getNormal());

View file

@ -6,7 +6,7 @@ import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel;
import com.simibubi.create.content.contraptions.goggles.GogglesItem;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.tileentity.TileEntityType;
@ -26,7 +26,7 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
float speed = Math.abs(getSpeed());
color = speed == 0 ? 0x333333
: ColorHelper.mixColors(SpeedLevel.of(speed)
: Color.mixColors(SpeedLevel.of(speed)
.getColor(), 0xffffff, .25f);
if (speed == 69)
AllTriggers.triggerForNearbyPlayers(AllTriggers.SPEED_READ, level, worldPosition, 6, GogglesItem::canSeeParticles);

View file

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.tileentity.TileEntityType;
@ -35,9 +35,9 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
if (dialTarget > 0) {
if (dialTarget < .5f)
color = ColorHelper.mixColors(0x00FF00, 0xFFFF00, dialTarget * 2);
color = Color.mixColors(0x00FF00, 0xFFFF00, dialTarget * 2);
else if (dialTarget < 1)
color = ColorHelper.mixColors(0xFFFF00, 0xFF0000, (dialTarget) * 2 - 1);
color = Color.mixColors(0xFFFF00, 0xFF0000, (dialTarget) * 2 - 1);
else
color = 0xFF0000;
}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.curiosities;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.IItemColor;
@ -9,20 +9,20 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
public class ChromaticCompoundColor implements IItemColor {
@Override
public int getColor(ItemStack stack, int layer) {
Minecraft mc = Minecraft.getInstance();
float pt = AnimationTickHolder.getPartialTicks();
float progress = (float) ((mc.player.getViewYRot(pt)) / 180 * Math.PI) + (AnimationTickHolder.getRenderTime() / 10f);
if (layer == 0)
return ColorHelper.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2);
return Color.mixColors(0x6e5773, 0x6B3074, ((float) MathHelper.sin(progress) + 1) / 2);
if (layer == 1)
return ColorHelper.mixColors(0xd45d79, 0x6e5773,
return Color.mixColors(0xd45d79, 0x6e5773,
((float) MathHelper.sin((float) (progress + Math.PI)) + 1) / 2);
if (layer == 2)
return ColorHelper.mixColors(0xea9085, 0xd45d79,
return Color.mixColors(0xea9085, 0xd45d79,
((float) MathHelper.sin((float) (progress * 1.5f + Math.PI)) + 1) / 2);
return 0;
}
}
}

View file

@ -5,7 +5,7 @@ import java.util.Random;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CRecipes;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
@ -54,7 +54,7 @@ public class ChromaticCompoundItem extends Item {
@Override
public int getRGBDurabilityForDisplay(ItemStack stack) {
return ColorHelper.mixColors(0x413c69, 0xFFFFFF, (float) (1 - getDurabilityForDisplay(stack)));
return Color.mixColors(0x413c69, 0xFFFFFF, (float) (1 - getDurabilityForDisplay(stack)));
}
@Override

View file

@ -9,7 +9,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.block.BlockState;
import net.minecraft.client.MainWindow;
@ -132,7 +132,7 @@ public class CopperBacktankArmorLayer<T extends LivingEntity, M extends EntityMo
.render(ms);
int color = 0xFF_FFFFFF;
if (timeLeft < 60 && timeLeft % 2 == 0) {
color = ColorHelper.mixColors(0xFF_FF0000, color, Math.max(timeLeft / 60f, .25f));
color = Color.mixColors(0xFF_FF0000, color, Math.max(timeLeft / 60f, .25f));
}
Minecraft.getInstance().font.drawShadow(ms, text, 16, 5, color);
buffers.endBatch();

View file

@ -6,7 +6,7 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper;
@ -205,7 +205,7 @@ public class EjectorTargetHandler {
double tickOffset = totalFlyingTicks / segments;
boolean valid = xDiff == validX && zDiff == validZ;
int intColor = valid ? 0x9ede73 : 0xff7171;
Vector3d color = ColorHelper.getRGB(intColor);
Vector3d color = Color.vectorFromRGB(intColor);
RedstoneParticleData data = new RedstoneParticleData((float) color.x, (float) color.y, (float) color.z, 1);
ClientWorld world = mc.level;

View file

@ -1,14 +1,14 @@
package com.simibubi.create.content.logistics.block.diodes;
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
public class AdjustableRepeaterInstance extends TileEntityInstance<AdjustableRepeaterTileEntity> implements ITickableInstance {
@ -53,6 +53,6 @@ public class AdjustableRepeaterInstance extends TileEntityInstance<AdjustableRep
}
protected int getColor() {
return ColorHelper.mixColors(0x2C0300, 0xCD0000, tile.state / (float) tile.maxState.getValue());
return Color.mixColors(0x2c0300, 0xcd0000, tile.state / (float) tile.maxState.getValue());
}
}

View file

@ -4,7 +4,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -16,7 +16,7 @@ public class AdjustableRepeaterRenderer extends ColoredOverlayTileEntityRenderer
@Override
protected int getColor(AdjustableRepeaterTileEntity te, float partialTicks) {
return ColorHelper.mixColors(0x2C0300, 0xCD0000, te.state / (float) te.maxState.getValue());
return Color.mixColors(0x2C0300, 0xCD0000, te.state / (float) te.maxState.getValue());
}
@Override

View file

@ -5,8 +5,8 @@ import java.util.ArrayList;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
@ -15,7 +15,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.client.Minecraft;
@ -112,7 +112,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95);
headAngle = -lowerArmAngle;
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB();
} else {
baseAngle = this.baseAngle;
lowerArmAngle = this.lowerArmAngle - 135;

View file

@ -11,7 +11,7 @@ import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.P
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState;
@ -74,7 +74,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95);
headAngle = -lowerArmAngle;
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100).getRGB();
} else {
baseAngle = arm.baseAngle.get(pt);
lowerArmAngle = arm.lowerArmAngle.get(pt) - 135;

View file

@ -1,16 +1,16 @@
package com.simibubi.create.content.logistics.block.redstone;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.util.Direction;
@ -53,7 +53,7 @@ public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntit
float state = tile.clientState.get(AnimationTickHolder.getPartialTicks());
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f);
indicator.setTransform(ms)
.setColor(color);

View file

@ -8,7 +8,7 @@ import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -46,7 +46,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
.renderInto(ms, vb);
// Indicator
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
indicator.light(lightCoords)
.color(color)

View file

@ -8,7 +8,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.block.BlockState;
@ -92,7 +92,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
Couple<Integer> couple = DYE_TABLE.get(color);
int brightColor = couple.getFirst();
int darkColor = couple.getSecond();
int flickeringBrightColor = ColorHelper.mixColors(brightColor, darkColor, flicker / 4);
int flickeringBrightColor = Color.mixColors(brightColor, darkColor, flicker / 4);
ms.pushPose();
ms.translate((charWidth - shadowOffset) / -2f, -height, 0);
@ -109,7 +109,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
drawChar(ms, buffer, c, darkColor);
ms.pushPose();
ms.translate(-shadowOffset, shadowOffset, -1 / 16f);
drawChar(ms, buffer, c, ColorHelper.mixColors(darkColor, 0, .35f));
drawChar(ms, buffer, c, Color.mixColors(darkColor, 0, .35f));
ms.popPose();
ms.popPose();
}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.palettes;
import com.simibubi.create.foundation.block.render.IBlockVertexColor;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
public class ScoriaVertexColor implements IBlockVertexColor {
@ -11,15 +11,18 @@ public class ScoriaVertexColor implements IBlockVertexColor {
float y2 = (float) Math.floor(y * 1.5 + x * .5 - z);
float z2 = (float) Math.floor(y - z * .5 - x);
int color = 0x448888;
Color color = new Color(0x448888);
if (x2 % 2 == 0)
color |= 0x0011ff;
color.modifyValue(v -> v | 0x0011ff);
if (z2 % 2 == 0)
color |= 0x888888;
color = ColorHelper.mixColors(ColorHelper.rainbowColor((int) (x + y + z) * 170), color, .6f);
color.modifyValue(v -> v | 0x888888);
color.mixWith(Color.rainbowColor((int) (x + y + z) * 170), .4f);
if ((x2 % 4 == 0) || (y2 % 4 == 0))
color = ColorHelper.mixColors(0xffffff, color, .2f);
return color;
color.mixWith(Color.WHITE, .8f);
return color.getRGB() & 0x00_ffffff;
}
}

View file

@ -26,7 +26,7 @@ import net.minecraftforge.fml.config.ModConfig;
public class BaseConfigScreen extends ConfigScreen {
private static final DelegatedStencilElement.ElementRenderer DISABLED_RENDERER = (ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.i(Theme.Key.BUTTON_DISABLE, true), Theme.i(Theme.Key.BUTTON_DISABLE, false) | 0x40_000000);
private static final DelegatedStencilElement.ElementRenderer DISABLED_RENDERER = (ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.p(Theme.Key.BUTTON_DISABLE));
public static BaseConfigScreen forCreate(Screen parent) {
return new BaseConfigScreen(parent)

View file

@ -23,7 +23,7 @@ import net.minecraftforge.fml.config.ModConfig;
public class ConfigHelper {
private static final LoadingCache<String, EnumMap<ModConfig.Type, ModConfig>> configCache = CacheBuilder.newBuilder().expireAfterAccess(15, TimeUnit.SECONDS).build(
private static final LoadingCache<String, EnumMap<ModConfig.Type, ModConfig>> configCache = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build(
new CacheLoader<String, EnumMap<ModConfig.Type, ModConfig>>() {
@Override
public EnumMap<ModConfig.Type, ModConfig> load(@Nonnull String key) {

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.config.ui.entries.NumberEntry;
import com.simibubi.create.foundation.gui.TextStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
@ -40,10 +41,11 @@ public class ConfigScreenList extends ExtendedList<ConfigScreenList.Entry> {
@Override
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, 0x60_000000, 0x0);
UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, 0x60_000000, 0x0);
UIRenderHelper.angledGradient(ms, 0, x0, y0 + height / 2, height, 5, 0x60_000000, 0x0);
UIRenderHelper.angledGradient(ms, 180, x1, y0 + height / 2, height, 5, 0x60_000000, 0x0);
Color c = new Color(0x60_000000);
UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, c, Color.TRANSPARENT_BLACK);
UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, c, Color.TRANSPARENT_BLACK);
UIRenderHelper.angledGradient(ms, 0, x0, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
UIRenderHelper.angledGradient(ms, 180, x1, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
super.render(ms, mouseX, mouseY, partialTicks);
}

View file

@ -1,6 +1,5 @@
package com.simibubi.create.foundation.config.ui;
import java.awt.Color;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@ -32,6 +31,7 @@ import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.client.Minecraft;

View file

@ -8,7 +8,7 @@ import com.mojang.blaze3d.matrix.MatrixStack.Entry;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.renderState.RenderTypes;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.client.Minecraft;
@ -131,7 +131,7 @@ public class FluidRenderer {
.translateBack(center);
boolean X = side.getAxis() == Axis.X;
int darkColor = ColorHelper.mixColors(color, 0xff000011, 1 / 4f);
int darkColor = Color.mixColors(color, 0xff000011, 1 / 4f);
renderTiledHorizontalFace(X ? xMax : zMax, side, X ? zMin : xMin, yMin, X ? zMax : xMax, yMax, builder,
ms, light, darkColor, fluidTexture);

View file

@ -1,9 +1,8 @@
package com.simibubi.create.foundation.gui;
import java.awt.Color;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;

View file

@ -4,7 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.matrix.MatrixStack.Entry;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
@ -181,7 +181,7 @@ public class AllIcons implements IScreenRenderable {
int j = i >> 16 & '\uffff';
int k = i & '\uffff';
Entry peek = ms.last();
Vector3d rgb = ColorHelper.getRGB(color);
Vector3d rgb = Color.vectorFromRGB(color);
Vector3d vec4 = new Vector3d(1, 1, 0);
Vector3d vec3 = new Vector3d(0, 1, 0);

View file

@ -1,12 +1,10 @@
package com.simibubi.create.foundation.gui;
import java.awt.Color;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.client.renderer.BufferBuilder;
@ -96,9 +94,9 @@ public class BoxElement extends RenderElement {
RenderSystem.shadeModel(GL11.GL_SMOOTH);
int f = borderOffset;
Color c1 = ColorHelper.applyAlpha(background, alpha);
Color c2 = ColorHelper.applyAlpha(borderTop, alpha);
Color c3 = ColorHelper.applyAlpha(borderBot, alpha);
Color c1 = background.copy().scaleAlpha(alpha);
Color c2 = borderTop.copy().scaleAlpha(alpha);
Color c3 = borderBot.copy().scaleAlpha(alpha);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder b = tessellator.getBuilder();
Matrix4f model = ms.last().pose();

View file

@ -1,12 +1,12 @@
package com.simibubi.create.foundation.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
public class DelegatedStencilElement extends StencilElement {
protected static final ElementRenderer EMPTY_RENDERER = (ms, width, height, alpha) -> {};
protected static final ElementRenderer DEFAULT_ELEMENT = (ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, -3, 5, height+4, width+6, ColorHelper.applyAlpha(0xff_10dd10, alpha), ColorHelper.applyAlpha(0xff_1010dd, alpha));
protected static final ElementRenderer DEFAULT_ELEMENT = (ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, -3, 5, height+4, width+6, new Color(0xff_10dd10).scaleAlpha(alpha), new Color(0xff_1010dd).scaleAlpha(alpha));
protected ElementRenderer stencil;
protected ElementRenderer element;

View file

@ -11,7 +11,7 @@ import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
@ -192,7 +192,7 @@ public class GuiGameElement {
int color = Minecraft.getInstance()
.getBlockColors()
.getColor(blockState, null, null, 0);
Vector3d rgb = ColorHelper.getRGB(color == -1 ? this.color : color);
Vector3d rgb = Color.vectorFromRGB(color == -1 ? this.color : color);
blockRenderer.getModelRenderer()
.renderModel(ms.last(), vb, blockState, blockModel, (float) rgb.x, (float) rgb.y, (float) rgb.z,
0xF000F0, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE);

View file

@ -1,6 +1,5 @@
package com.simibubi.create.foundation.gui;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@ -11,6 +10,7 @@ import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
public class Theme {
@ -205,13 +205,13 @@ public class Theme {
private static ColorHolder single(Color c) {
ColorHolder h = new ColorHolder();
h.colors = Couple.create(c, c);
h.colors = Couple.create(c.setImmutable(), c.setImmutable());
return h;
}
private static ColorHolder pair(Color first, Color second) {
ColorHolder h = new ColorHolder();
h.colors = Couple.create(first, second);
h.colors = Couple.create(first.setImmutable(), second.setImmutable());
return h;
}

View file

@ -1,14 +1,12 @@
package com.simibubi.create.foundation.gui;
import java.awt.Color;
import javax.annotation.Nonnull;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import net.minecraft.client.MainWindow;
@ -116,23 +114,23 @@ public class UIRenderHelper {
}
/**
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, int, int)
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
*/
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, Couple<Color> c) {
angledGradient(ms, angle, x, y, 0, breadth, length, c);
}
/**
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, int, int)
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
*/
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, Couple<Color> c) {
angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst().getRGB(), c.getSecond().getRGB());
angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond());
}
/**
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, int, int)
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
*/
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, int color1, int color2) {
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int breadth, int length, Color color1, Color color2) {
angledGradient(ms, angle, x, y, 0, breadth, length, color1, color2);
}
@ -144,22 +142,22 @@ public class UIRenderHelper {
* @param color2 the color at the ending edge
* @param breadth the total width of the gradient
*/
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, int color1, int color2) {
public static void angledGradient(@Nonnull MatrixStack ms, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) {
ms.pushPose();
ms.translate(x, y, z);
ms.mulPose(Vector3f.ZP.rotationDegrees(angle - 90));
Matrix4f model = ms.last().pose();
int w = breadth / 2;
GuiUtils.drawGradientRect(model, 0, -w, 0, w, length, color1, color2);
GuiUtils.drawGradientRect(model, 0, -w, 0, w, length, color1.getRGB(), color2.getRGB());
ms.popPose();
}
public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(matrixStack, x, y, z, width, height, indent, colors.getFirst().getRGB(), colors.getSecond().getRGB());}
public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(matrixStack, x, y, z, width, height, indent, colors.getFirst(), colors.getSecond());}
// draws a wide chevron-style breadcrumb arrow pointing left
public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, int startColor, int endColor) {
public static void breadcrumbArrow(MatrixStack matrixStack, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) {
matrixStack.pushPose();
matrixStack.translate(x - indent, y, z);
@ -168,7 +166,7 @@ public class UIRenderHelper {
matrixStack.popPose();
}
private static void breadcrumbArrow(MatrixStack ms, int width, int height, int indent, int c1, int c2) {
private static void breadcrumbArrow(MatrixStack ms, int width, int height, int indent, Color c1, Color c2) {
/*
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
@ -193,10 +191,10 @@ public class UIRenderHelper {
indent = Math.abs(indent);
width = Math.abs(width);
int fc1 = ColorHelper.mixAlphaColors(c1, c2, 0);
int fc2 = ColorHelper.mixAlphaColors(c1, c2, (indent) / (width + 2f * indent));
int fc3 = ColorHelper.mixAlphaColors(c1, c2, (indent + width) / (width + 2f * indent));
int fc4 = ColorHelper.mixAlphaColors(c1, c2, 1);
Color fc1 = Color.mixColors(c1, c2, 0);
Color fc2 = Color.mixColors(c1, c2, (indent) / (width + 2f * indent));
Color fc3 = Color.mixColors(c1, c2, (indent + width) / (width + 2f * indent));
Color fc4 = Color.mixColors(c1, c2, 1);
RenderSystem.disableTexture();
RenderSystem.enableBlend();
@ -210,29 +208,29 @@ public class UIRenderHelper {
Matrix4f model = ms.last().pose();
bufferbuilder.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
bufferbuilder.vertex(model, x0, y0, 0).color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x1, y1, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x2, y2, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x0, y0, 0).color(fc1 >> 16 & 0xFF, fc1 >> 8 & 0xFF, fc1 & 0xFF, fc1 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x2, y2, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x1, y1, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2 >> 16 & 0xFF, fc2 >> 8 & 0xFF, fc2 & 0xFF, fc2 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x6, y6, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x5, y5, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x7, y7, 0).color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x7, y7, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
bufferbuilder.vertex(model, x6, y6, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x5, y5, 0).color(fc3 >> 16 & 0xFF, fc3 >> 8 & 0xFF, fc3 & 0xFF, fc3 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x8, y8, 0).color(fc4 >> 16 & 0xFF, fc4 >> 8 & 0xFF, fc4 & 0xFF, fc4 >> 24 & 0xFF).endVertex();
bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
bufferbuilder.vertex(model, x8, y8, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
tessellator.end();
RenderSystem.shadeModel(GL11.GL_FLAT);

View file

@ -1,7 +1,5 @@
package com.simibubi.create.foundation.gui.mainMenu;
import java.awt.Color;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
@ -16,6 +14,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.ponder.content.PonderTagIndexScreen;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
@ -106,7 +105,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen {
AllGuiTextures.LOGO.draw(ms, 0, 0);
ms.popPose();
new BoxElement().withBackground(0x88_000000)
.flatBorder(new Color(0x01_000000, true))
.flatBorder(new Color(0x01_000000))
.at(-32, 56, 100)
.withBounds(128, 11)
.render(ms);

View file

@ -1,6 +1,5 @@
package com.simibubi.create.foundation.gui.widgets;
import java.awt.Color;
import java.util.function.Function;
import javax.annotation.Nonnull;
@ -11,13 +10,13 @@ import com.simibubi.create.foundation.gui.DelegatedStencilElement;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.Theme.Key;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
public class BoxWidget extends ElementWidget {
public static final Function<BoxWidget, DelegatedStencilElement.ElementRenderer> gradientFactory = (box) -> (ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, w/2, -2, w + 4, h + 4, box.gradientColor1.getRGB(), box.gradientColor2.getRGB());
public static final Function<BoxWidget, DelegatedStencilElement.ElementRenderer> gradientFactory = (box) -> (ms, w, h, alpha) -> UIRenderHelper.angledGradient(ms, 90, w/2, -2, w + 4, h + 4, box.gradientColor1, box.gradientColor2);
protected BoxElement box;
@ -29,8 +28,8 @@ public class BoxWidget extends ElementWidget {
protected Color gradientColor1, gradientColor2;
private Color previousColor1, previousColor2;
private Color colorTarget1 = Theme.c(getIdleTheme(), true);
private Color colorTarget2 = Theme.c(getIdleTheme(), false);
private Color colorTarget1 = Theme.c(getIdleTheme(), true).copy();
private Color colorTarget2 = Theme.c(getIdleTheme(), false).copy();
public BoxWidget() {
this(0, 0);
@ -116,8 +115,8 @@ public class BoxWidget extends ElementWidget {
gradientColor2 = colorTarget2;
} else {
float animationValue = 1 - Math.abs(colorAnimation.getValue(partialTicks));
gradientColor1 = ColorHelper.mixColors(previousColor1, colorTarget1, animationValue);
gradientColor2 = ColorHelper.mixColors(previousColor2, colorTarget2, animationValue);
gradientColor1 = Color.mixColors(previousColor1, colorTarget1, animationValue);
gradientColor2 = Color.mixColors(previousColor2, colorTarget2, animationValue);
}
}

View file

@ -19,6 +19,7 @@ import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.ponder.content.PonderTagIndexScreen;
import com.simibubi.create.foundation.ponder.content.PonderTagScreen;
import com.simibubi.create.foundation.ponder.ui.PonderButton;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -242,7 +243,7 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen {
names.forEach(s -> {
int sWidth = font.width(s);
UIRenderHelper.breadcrumbArrow(ms, x.getValue(), y.getValue(), 0, sWidth + spacing, 14, spacing / 2,
0xdd101010, 0x44101010);
new Color(0xdd101010), new Color(0x44101010));
font.draw(ms, s, x.getValue() + 5, y.getValue() + 3, first.getValue() ? 0xffeeffee : 0xffddeeff);
first.setFalse();

View file

@ -4,7 +4,7 @@ import java.util.List;
import com.google.common.base.Strings;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
@ -133,8 +133,8 @@ public class PonderTooltipHandler {
private static int getSmoothColorForProgress(float progress) {
if (progress < .5f)
return ColorHelper.mixColors(0x5000FF, 5592575, progress * 2);
return ColorHelper.mixColors(5592575, 0xffffff, (progress - .5f) * 2);
return Color.mixColors(0x5000FF, 5592575, progress * 2);
return Color.mixColors(5592575, 0xffffff, (progress - .5f) * 2);
}
private static ITextComponent makeProgressBar(float progress) {

View file

@ -2,7 +2,6 @@ package com.simibubi.create.foundation.ponder;
import static com.simibubi.create.foundation.ponder.PonderLocalization.LANG_PREFIX;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -31,7 +30,7 @@ import com.simibubi.create.foundation.ponder.content.PonderTagScreen;
import com.simibubi.create.foundation.ponder.elements.TextWindowElement;
import com.simibubi.create.foundation.ponder.ui.PonderButton;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.FontHelper;
import com.simibubi.create.foundation.utility.Iterate;
@ -469,7 +468,7 @@ public class PonderUI extends NavigatableSimiScreen {
ms.scale(1, .5f + flash * .75f, 1);
GuiUtils.drawGradientRect(ms.last()
.pose(), 0, 0, -1, -story.basePlateSize, 0, 0x00_c6ffc9,
ColorHelper.applyAlpha(0xaa_c6ffc9, alpha));
new Color(0xaa_c6ffc9).scaleAlpha(alpha).getRGB());
ms.popPose();
}
ms.translate(0, 0, 2 / 1024f);
@ -538,7 +537,7 @@ public class PonderUI extends NavigatableSimiScreen {
protected void renderWidgets(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
RenderSystem.disableDepthTest();
float fade = fadeIn.getValue(partialTicks);
float lazyIndexValue = lazyIndex.getValue(partialTicks);
float indexDiff = Math.abs(lazyIndexValue - index);
@ -582,7 +581,7 @@ public class PonderUI extends NavigatableSimiScreen {
ms.mulPose(Vector3f.XN.rotationDegrees(indexDiff * -75));
ms.translate(0, 0, 5);
FontHelper.drawSplitString(ms, font, title, 0, 0, left.x - 51,
ColorHelper.applyAlpha(Theme.i(Theme.Key.TEXT), 1 - indexDiff));
Theme.c(Theme.Key.TEXT).scaleAlpha(1 - indexDiff).getRGB());
ms.popPose();
if (chapter != null) {
@ -598,10 +597,13 @@ public class PonderUI extends NavigatableSimiScreen {
ms.popPose();
}
UIRenderHelper.breadcrumbArrow(ms, width / 2 - 20, height - 51, 0, 20, 20, 5, 0x40aa9999, 0x20aa9999);
UIRenderHelper.breadcrumbArrow(ms, width / 2 + 20, height - 51, 0, -20, 20, -5, 0x40aa9999, 0x20aa9999);
UIRenderHelper.breadcrumbArrow(ms, width / 2 - 90, height - 51, 0, 70, 20, 5, 0x40aa9999, 0x10aa9999);
UIRenderHelper.breadcrumbArrow(ms, width / 2 + 90, height - 51, 0, -70, 20, -5, 0x40aa9999, 0x10aa9999);
Color c1 = Theme.c(Theme.Key.PONDER_BACK_ARROW).setAlpha(0x40);
Color c2 = Theme.c(Theme.Key.PONDER_BACK_ARROW).setAlpha(0x20);
Color c3 = Theme.c(Theme.Key.PONDER_BACK_ARROW).setAlpha(0x10);
UIRenderHelper.breadcrumbArrow(ms, width / 2 - 20, height - 51, 0, 20, 20, 5, c1, c2);
UIRenderHelper.breadcrumbArrow(ms, width / 2 + 20, height - 51, 0, -20, 20, -5, c1, c2);
UIRenderHelper.breadcrumbArrow(ms, width / 2 - 90, height - 51, 0, 70, 20, 5, c1, c3);
UIRenderHelper.breadcrumbArrow(ms, width / 2 + 90, height - 51, 0, -70, 20, -5, c1, c3);
}
if (identifyMode) {
@ -738,7 +740,7 @@ public class PonderUI extends NavigatableSimiScreen {
if (PonderIndex.EDITOR_MODE && userMode.isHovered())
drawCenteredString(ms, font, "Editor View", userMode.x + 10, tooltipY, tooltipColor);
ms.popPose();
RenderSystem.enableDepthTest();
}
@ -869,7 +871,7 @@ public class PonderUI extends NavigatableSimiScreen {
boxY -= h / 2;
divotX += distance;
divotY -= divotRadius;
c = ColorHelper.mixColors(borderColors, 0.5f);
c = Color.mixColors(borderColors, 0.5f);
break;
case RIGHT:
divotRotation = 270;
@ -877,7 +879,7 @@ public class PonderUI extends NavigatableSimiScreen {
boxY -= h / 2;
divotX -= divotSize + distance;
divotY -= divotRadius;
c = ColorHelper.mixColors(borderColors, 0.5f);
c = Color.mixColors(borderColors, 0.5f);
break;
case UP:
divotRotation = 180;

View file

@ -59,7 +59,7 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
@ -132,7 +132,7 @@ public class SceneBuilder {
* Assign a unique translation key, as well as the standard english translation
* for this scene's title using this method, anywhere inside the program
* function.
*
*
* @param sceneId
* @param title
*/
@ -147,7 +147,7 @@ public class SceneBuilder {
* the the base plate. <br>
* As a result, showBasePlate() will only show the configured size, and the
* scene's scaling inside the UI will be consistent with its base size.
*
*
* @param xOffset Block spaces between the base plate and the schematic
* boundary on the Western side.
* @param zOffset Block spaces between the base plate and the schematic
@ -164,7 +164,7 @@ public class SceneBuilder {
/**
* Use this in case you are not happy with the scale of the scene relative to
* the overlay
*
*
* @param factor >1 will make the scene appear larger, smaller otherwise
*/
public void scaleSceneView(float factor) {
@ -174,7 +174,7 @@ public class SceneBuilder {
/**
* Use this in case you are not happy with the vertical alignment of the scene
* relative to the overlay
*
*
* @param yOffset >0 moves the scene up, down otherwise
*/
public void setSceneOffsetY(float yOffset) {
@ -197,7 +197,7 @@ public class SceneBuilder {
* actions play out. <br>
* Idle does not stall any animations, only schedules a time gap between
* instructions.
*
*
* @param ticks Duration to wait for
*/
public void idle(int ticks) {
@ -209,7 +209,7 @@ public class SceneBuilder {
* actions play out. <br>
* Idle does not stall any animations, only schedules a time gap between
* instructions.
*
*
* @param seconds Duration to wait for
*/
public void idleSeconds(int seconds) {
@ -229,7 +229,7 @@ public class SceneBuilder {
/**
* Pans the scene's camera view around the vertical axis by the given amount
*
*
* @param degrees
*/
public void rotateCameraY(float degrees) {
@ -309,7 +309,7 @@ public class SceneBuilder {
}
public void createRedstoneParticles(BlockPos pos, int color, int amount) {
Vector3d rgb = ColorHelper.getRGB(color);
Vector3d rgb = Color.vectorFromRGB(color);
addInstruction(new EmitParticlesInstruction(VecHelper.getCenterOf(pos), Emitter.withinBlockSpace(
new RedstoneParticleData((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), Vector3d.ZERO), amount, 2));
}
@ -824,4 +824,4 @@ public class SceneBuilder {
scene.schedule.add(PonderInstruction.simple(callback));
}
}
}

View file

@ -1,30 +1,36 @@
package com.simibubi.create.foundation.ponder.content;
import com.simibubi.create.foundation.utility.Color;
public enum PonderPalette {
WHITE(0xFF_eeeeee),
BLACK(0xFF_221111),
RED(0xFF_ff5d6c),
GREEN(0xFF_8cba51),
BLUE(0xFF_5f6caf),
SLOW(0xFF_22ff22),
MEDIUM(0xFF_0084ff),
FAST(0xFF_ff55ff),
INPUT(0xFF_4f8a8b),
OUTPUT(0xFF_ffcb74),
;
private int color;
private final Color color;
private PonderPalette(int color) {
this.color = color;
PonderPalette(int color) {
this.color = new Color(color);
}
public int getColor() {
return color.getRGB();
}
public Color getColorObject() {
return color;
}
}

View file

@ -10,7 +10,6 @@ import com.simibubi.create.foundation.ponder.PonderLocalization;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderUI;
import com.simibubi.create.foundation.ponder.content.PonderPalette;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Pointing;
import net.minecraft.client.gui.FontRenderer;
@ -59,7 +58,7 @@ public class InputWindowElement extends AnimatedOverlayElement {
icon = AllIcons.I_RMB;
return this;
}
public InputWindowElement showing(AllIcons icon) {
this.icon = icon;
return this;
@ -126,7 +125,7 @@ public class InputWindowElement extends AnimatedOverlayElement {
if (hasText)
font.draw(ms, text, 2, (height - font.lineHeight) / 2f + 2,
ColorHelper.applyAlpha(PonderPalette.WHITE.getColor(), fade));
PonderPalette.WHITE.getColorObject().scaleAlpha(fade).getRGB());
if (hasIcon) {
ms.pushPose();

View file

@ -10,7 +10,7 @@ import com.simibubi.create.foundation.ponder.PonderLocalization;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderUI;
import com.simibubi.create.foundation.ponder.content.PonderPalette;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
@ -126,7 +126,7 @@ public class TextWindowElement extends AnimatedOverlayElement {
//PonderUI.renderBox(ms, targetX - 10, 3, boxWidth, boxHeight - 1, 0xaa000000, 0x30eebb00, 0x10eebb00);
int brighterColor = ColorHelper.mixAlphaColors(color, 0xFFffffdd, 1 / 2f);
int brighterColor = Color.mixColors(color, 0xFFffffdd, 1 / 2f);
if (vec != null) {
ms.pushPose();
ms.translate(sceneToScreen.x, 0, 0);
@ -142,7 +142,7 @@ public class TextWindowElement extends AnimatedOverlayElement {
for (int i = 0; i < lines.size(); i++) {
screen.getFontRenderer()
.draw(ms, lines.get(i)
.getString(), targetX - 10, 3 + 9 * i, ColorHelper.applyAlpha(brighterColor, fade));
.getString(), targetX - 10, 3 + 9 * i, new Color(brighterColor).scaleAlpha(fade).getRGB());
}
ms.popPose();
}

View file

@ -1,7 +1,5 @@
package com.simibubi.create.foundation.ponder.ui;
import java.awt.Color;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.matrix.MatrixStack;
@ -13,7 +11,7 @@ import com.simibubi.create.foundation.gui.widgets.BoxWidget;
import com.simibubi.create.foundation.gui.widgets.ElementWidget;
import com.simibubi.create.foundation.ponder.content.PonderTag;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.Minecraft;
@ -48,7 +46,7 @@ public class PonderButton extends BoxWidget {
public <T extends PonderButton> T showingTag(PonderTag tag) {
return showing(this.tag = tag);
}
public <T extends PonderButton> T showing(ItemStack item) {
this.item = item;
return super.showingElement(GuiGameElement.of(item)
@ -83,12 +81,10 @@ public class PonderButton extends BoxWidget {
if (flashValue > .1f) {
float sin = 0.5f + 0.5f * MathHelper.sin((AnimationTickHolder.getTicks(true) + partialTicks) / 5f);
sin *= flashValue;
Color c1 = gradientColor1;
Color c2 = gradientColor2;
Color nc1 = new Color(255, 255, 255, MathHelper.clamp(c1.getAlpha() + 150, 0, 255));
Color nc2 = new Color(155, 155, 155, MathHelper.clamp(c2.getAlpha() + 150, 0, 255));
gradientColor1 = ColorHelper.mixColors(c1, nc1, sin);
gradientColor2 = ColorHelper.mixColors(c2, nc2, sin);
Color nc1 = new Color(255, 255, 255, MathHelper.clamp(gradientColor1.getAlpha() + 150, 0, 255));
Color nc2 = new Color(155, 155, 155, MathHelper.clamp(gradientColor2.getAlpha() + 150, 0, 255));
gradientColor1.mixWith(nc1, sin);
gradientColor2.mixWith(nc2, sin);
}
}
@ -102,14 +98,14 @@ public class PonderButton extends BoxWidget {
if (shortcut != null) {
ms.translate(0, 0, z + 50);
drawCenteredString(ms, Minecraft.getInstance().font, shortcut.getTranslatedKeyMessage(), x + width / 2 + 8, y + height - 6, ColorHelper.applyAlpha(Theme.i(Theme.Key.TEXT_DARKER), fadeValue));
drawCenteredString(ms, Minecraft.getInstance().font, shortcut.getTranslatedKeyMessage(), x + width / 2 + 8, y + height - 6, Theme.c(Theme.Key.TEXT_DARKER).scaleAlpha(fadeValue).getRGB());
}
}
public ItemStack getItem() {
return item;
}
public PonderTag getTag() {
return tag;
}

View file

@ -5,6 +5,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import com.simibubi.create.foundation.utility.Color;
import it.unimi.dsi.fastutil.longs.Long2IntMap;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
@ -207,7 +208,7 @@ public class SuperByteBuffer {
while (!transforms.clear())
transforms.popPose();
transforms.pushPose();
shouldColor = false;
r = 0;
g = 0;
@ -297,6 +298,10 @@ public class SuperByteBuffer {
return this;
}
public SuperByteBuffer color(Color c) {
return color(c.getRGB());
}
/**
* Prevents vertex colors from being divided by the diffuse value calculated from the raw untransformed normal vector.
* Useful when passed vertex colors do not have diffuse baked in.

View file

@ -6,7 +6,7 @@ import com.simibubi.create.foundation.gui.AllIcons;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.outliner.ChasingAABBOutline;
@ -143,7 +143,7 @@ public class ValueBox extends ChasingAABBOutline {
boolean isEmpty = stack.isEmpty();
float scale = 1.5f;
ms.translate(-font.width(countString), 0, 0);
if (isFilter)
ms.translate(3, 8, 7.25f);
else if (isEmpty) {
@ -215,7 +215,7 @@ public class ValueBox extends ChasingAABBOutline {
// util
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text) {
renderHoveringText(ms, buffer, text, highlightColor, ColorHelper.mixColors(passiveColor, 0, 0.75f));
renderHoveringText(ms, buffer, text, highlightColor, Color.mixColors(passiveColor, 0, 0.75f));
}
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, int color,

View file

@ -0,0 +1,322 @@
package com.simibubi.create.foundation.utility;
import java.util.function.UnaryOperator;
import javax.annotation.Nonnull;
import com.google.common.hash.Hashing;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
@SuppressWarnings("PointlessBitwiseExpression")
public class Color {
public final static Color TRANSPARENT_BLACK = new Color(0, 0, 0, 0).setImmutable();
public final static Color BLACK = new Color(0, 0, 0).setImmutable();
public final static Color WHITE = new Color(255, 255, 255).setImmutable();
public final static Color RED = new Color(255, 0, 0).setImmutable();
public final static Color GREEN = new Color(0, 255, 0).setImmutable();
public final static Color SPRING_GREEN = new Color(0, 255, 187).setImmutable();
protected boolean mutable = true;
protected int value;
public Color(int r, int g, int b) {
this(r, g, b, 0xff);
}
public Color(int r, int g, int b, int a) {
value = ((a & 0xff) << 24) |
((r & 0xff) << 16) |
((g & 0xff) << 8) |
((b & 0xff) << 0);
}
public Color(float r, float g, float b, float a) {
this(
(int) (0.5 + 0xff * MathHelper.clamp(r, 0, 1)),
(int) (0.5 + 0xff * MathHelper.clamp(g, 0, 1)),
(int) (0.5 + 0xff * MathHelper.clamp(b, 0, 1)),
(int) (0.5 + 0xff * MathHelper.clamp(a, 0, 1))
);
}
public Color(int rgba) {
value = rgba;
}
public Color(int rgb, boolean hasAlpha) {
if (hasAlpha) {
value = rgb;
} else {
value = rgb | 0xff_000000;
}
}
public Color copy() {
return copy(true);
}
public Color copy(boolean mutable) {
if (mutable)
return new Color(value);
else
return new Color(value).setImmutable();
}
/**
* Mark this color as immutable. Attempting to mutate this color in the future
* will instead cause a copy to be created that can me modified.
*/
public Color setImmutable() {
this.mutable = false;
return this;
}
/**
* @return the red component in the range 0-255.
* @see #getRGB
*/
public int getRed() {
return (getRGB() >> 16) & 0xff;
}
/**
* @return the green component in the range 0-255.
* @see #getRGB
*/
public int getGreen() {
return (getRGB() >> 8) & 0xff;
}
/**
* @return the blue component in the range 0-255.
* @see #getRGB
*/
public int getBlue() {
return (getRGB() >> 0) & 0xff;
}
/**
* @return the alpha component in the range 0-255.
* @see #getRGB
*/
public int getAlpha() {
return (getRGB() >> 24) & 0xff;
}
/**
* @return the red component in the range 0-1f.
*/
public float getRedAsFloat() {
return getRed() / 255f;
}
/**
* @return the green component in the range 0-1f.
*/
public float getGreenAsFloat() {
return getGreen() / 255f;
}
/**
* @return the blue component in the range 0-1f.
*/
public float getBlueAsFloat() {
return getBlue() / 255f;
}
/**
* @return the alpha component in the range 0-1f.
*/
public float getAlphaAsFloat() {
return getAlpha() / 255f;
}
/**
* Returns the RGB value representing this color
* (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue).
* @return the RGB value of the color
*/
public int getRGB() {
return value;
}
public Vector3d asVector() {
return new Vector3d(getRedAsFloat(), getGreenAsFloat(), getBlueAsFloat());
}
public Color setRed(int r) {
return ensureMutable().setRedUnchecked(r);
}
public Color setGreen(int g) {
return ensureMutable().setGreenUnchecked(g);
}
public Color setBlue(int b) {
return ensureMutable().setBlueUnchecked(b);
}
public Color setAlpha(int a) {
return ensureMutable().setAlphaUnchecked(a);
}
public Color setRed(float r) {
return ensureMutable().setRedUnchecked((int) (0xff * MathHelper.clamp(r, 0, 1)));
}
public Color setGreen(float g) {
return ensureMutable().setGreenUnchecked((int) (0xff * MathHelper.clamp(g, 0, 1)));
}
public Color setBlue(float b) {
return ensureMutable().setBlueUnchecked((int) (0xff * MathHelper.clamp(b, 0, 1)));
}
public Color setAlpha(float a) {
return ensureMutable().setAlphaUnchecked((int) (0xff * MathHelper.clamp(a, 0, 1)));
}
public Color scaleAlpha(float factor) {
return ensureMutable().setAlphaUnchecked((int) (getAlpha() * MathHelper.clamp(factor, 0, 1)));
}
@Deprecated
public Color applyAlpha(float alpha) {
if (getAlpha() == 0)
return setAlpha(alpha);
else
return scaleAlpha(alpha);
}
public Color mixWith(Color other, float weight) {
return ensureMutable()
.setRedUnchecked((int) (getRed() + (other.getRed() - getRed()) * weight))
.setGreenUnchecked((int) (getGreen() + (other.getGreen() - getGreen()) * weight))
.setBlueUnchecked((int) (getBlue() + (other.getBlue() - getBlue()) * weight))
.setAlphaUnchecked((int) (getAlpha() + (other.getAlpha() - getAlpha()) * weight));
}
public Color darker() {
//todo
return ensureMutable();
}
public Color setValue(int value) {
return ensureMutable().setValueUnchecked(value);
}
public Color modifyValue(UnaryOperator<Integer> function) {
int newValue = function.apply(value);
if (newValue == value)
return this;
return ensureMutable().setValueUnchecked(newValue);
}
// ********* //
protected Color ensureMutable() {
if (this.mutable)
return this;
return new Color(this.value);
}
protected Color setRedUnchecked(int r) {
this.value = (this.value & 0xff_00ffff) | ((r & 0xff) << 16);
return this;
}
protected Color setGreenUnchecked(int g) {
this.value = (this.value & 0xff_ff00ff) | ((g & 0xff) << 8);
return this;
}
protected Color setBlueUnchecked(int b) {
this.value = (this.value & 0xff_ffff00) | ((b & 0xff) << 0);
return this;
}
protected Color setAlphaUnchecked(int a) {
this.value = (this.value & 0x00_ffffff) | ((a & 0xff) << 24);
return this;
}
protected Color setValueUnchecked(int value) {
this.value = value;
return this;
}
// ********* //
public static Color mixColors(@Nonnull Color c1, @Nonnull Color c2, float w) {
return new Color(
(int) (c1.getRed() + (c2.getRed() - c1.getRed()) * w),
(int) (c1.getGreen() + (c2.getGreen() - c1.getGreen()) * w),
(int) (c1.getBlue() + (c2.getBlue() - c1.getBlue()) * w),
(int) (c1.getAlpha() + (c2.getAlpha() - c1.getAlpha()) * w)
);
}
public static Color mixColors(@Nonnull Couple<Color> colors, float w) {
return mixColors(colors.getFirst(), colors.getSecond(), w);
}
public static int mixColors(int color1, int color2, float w) {
int a1 = (color1 >> 24);
int r1 = (color1 >> 16) & 0xFF;
int g1 = (color1 >> 8) & 0xFF;
int b1 = color1 & 0xFF;
int a2 = (color2 >> 24);
int r2 = (color2 >> 16) & 0xFF;
int g2 = (color2 >> 8) & 0xFF;
int b2 = color2 & 0xFF;
return
((int) (a1 + (a2 - a1) * w) << 24) +
((int) (r1 + (r2 - r1) * w) << 16) +
((int) (g1 + (g2 - g1) * w) << 8) +
((int) (b1 + (b2 - b1) * w) << 0);
}
public static Color rainbowColor(int timeStep) {
int localTimeStep = Math.abs(timeStep) % 1536;
int timeStepInPhase = localTimeStep % 256;
int phaseBlue = localTimeStep / 256;
int red = colorInPhase(phaseBlue + 4, timeStepInPhase);
int green = colorInPhase(phaseBlue + 2, timeStepInPhase);
int blue = colorInPhase(phaseBlue, timeStepInPhase);
return new Color(red, green, blue);
}
private static int colorInPhase(int phase, int progress) {
phase = phase % 6;
if (phase <= 1)
return 0;
if (phase == 2)
return progress;
if (phase <= 4)
return 255;
else
return 255 - progress;
}
public static Color generateFromLong(long l) {
return rainbowColor(Hashing.crc32().hashLong(l).asInt())
.mixWith(WHITE, 0.5f);
}
/**
* Try not to introduce new usages of this method and instead use Color instances directly
*/
@Deprecated
public static Vector3d vectorFromRGB(int color) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
return new Vector3d(r, g, b).scale(1 / 255d);
}
}

View file

@ -1,135 +0,0 @@
package com.simibubi.create.foundation.utility;
import java.awt.Color;
import java.util.UUID;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
public class ColorHelper {
public static int rainbowColor(int timeStep) {
int localTimeStep = timeStep % 1536;
int timeStepInPhase = localTimeStep % 256;
int phaseBlue = localTimeStep / 256;
int red = colorInPhase(phaseBlue + 4, timeStepInPhase);
int green = colorInPhase(phaseBlue + 2, timeStepInPhase);
int blue = colorInPhase(phaseBlue, timeStepInPhase);
return (red << 16) + (green << 8) + (blue);
}
private static int colorInPhase(int phase, int progress) {
phase = phase % 6;
if (phase <= 1)
return 0;
if (phase == 2)
return progress;
if (phase <= 4)
return 255;
else
return 255 - progress;
}
public static int applyAlpha(int color, float alpha) {
int prevAlphaChannel = (color >> 24) & 0xFF;
if (prevAlphaChannel > 0)
alpha *= prevAlphaChannel / 255f;
int alphaChannel = (int) (0xFF * MathHelper.clamp(alpha, 0, 1));
return (color & 0xFFFFFF) | alphaChannel << 24;
}
public static Color applyAlpha(Color c, float alpha) {
return new Color(applyAlpha(c.getRGB(), alpha), true);
}
public static int mixColors(int color1, int color2, float w) {
int r1 = (color1 >> 16);
int g1 = (color1 >> 8) & 0xFF;
int b1 = color1 & 0xFF;
int r2 = (color2 >> 16);
int g2 = (color2 >> 8) & 0xFF;
int b2 = color2 & 0xFF;
int color = ((int) (r1 + (r2 - r1) * w) << 16) + ((int) (g1 + (g2 - g1) * w) << 8) + (int) (b1 + (b2 - b1) * w);
return color;
}
@Nonnull
public static Color mixColors(@Nonnull Color c1, @Nonnull Color c2, float w) {
float[] cmp1 = c1.getRGBComponents(null);
float[] cmp2 = c2.getRGBComponents(null);
return new Color(
cmp1[0] + (cmp2[0] - cmp1[0]) * w,
cmp1[1] + (cmp2[1] - cmp1[1]) * w,
cmp1[2] + (cmp2[2] - cmp1[2]) * w,
cmp1[3] + (cmp2[3] - cmp1[3]) * w
);
}
@Nonnull
public static Color mixColors(@Nonnull Couple<Color> colors, float w) {
return mixColors(colors.getFirst(), colors.getSecond(), w);
}
public static int mixAlphaColors(int color1, int color2, float w) {
int a1 = (color1 >> 24);
int r1 = (color1 >> 16) & 0xFF;
int g1 = (color1 >> 8) & 0xFF;
int b1 = color1 & 0xFF;
int a2 = (color2 >> 24);
int r2 = (color2 >> 16) & 0xFF;
int g2 = (color2 >> 8) & 0xFF;
int b2 = color2 & 0xFF;
int color = ((int) (a1 + (a2 - a1) * w) << 24) + ((int) (r1 + (r2 - r1) * w) << 16)
+ ((int) (g1 + (g2 - g1) * w) << 8) + (int) (b1 + (b2 - b1) * w);
return color;
}
public static void glColor(int color) {
color = mixColors(color, 0xFFFFFF, .5f);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
RenderSystem.color4f(r / 255f, g / 255f, b / 255f, 1);
}
public static void glResetColor() {
RenderSystem.color4f(1, 1, 1, 1);
}
public static Vector3d getRGB(int color) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
return new Vector3d(r, g, b).scale(1 / 255d);
}
public static Vector3d[] toVectors(int[] colors) {
Vector3d[] vectors = new Vector3d[colors.length];
for (int i = 0; i < colors.length; i++) {
vectors[i] = ColorHelper.getRGB(colors[i]);
}
return vectors;
}
public static int colorFromUUID(UUID uuid) {
if (uuid == null)
return 0x333333;
return colorFromLong(uuid.getLeastSignificantBits());
}
public static int colorFromLong(long l) {
int rainbowColor = ColorHelper.rainbowColor(String.valueOf(l)
.hashCode());
return ColorHelper.mixColors(rainbowColor, 0xFFFFFF, .5f);
}
}

View file

@ -12,7 +12,7 @@ import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.foundation.renderState.RenderTypes;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.renderer.texture.OverlayTexture;
@ -129,7 +129,7 @@ public abstract class Outline {
int j = i >> 16 & '\uffff';
int k = i & '\uffff';
Entry peek = ms.last();
Vector3d rgb = params.rgb;
Color rgb = params.rgb;
if (transformNormals == null)
transformNormals = peek.normal();
@ -144,7 +144,7 @@ public abstract class Outline {
}
builder.vertex(peek.pose(), (float) pos.x, (float) pos.y, (float) pos.z)
.color((float) rgb.x, (float) rgb.y, (float) rgb.z, params.alpha)
.color(rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), rgb.getAlphaAsFloat() * params.alpha)
.uv(u, v)
.overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(j, k)
@ -169,7 +169,7 @@ public abstract class Outline {
protected boolean disableNormals;
protected float alpha;
protected int lightMapU, lightMapV;
protected Vector3d rgb;
protected Color rgb;
private float lineWidth;
public OutlineParams() {
@ -177,7 +177,7 @@ public abstract class Outline {
alpha = 1;
lineWidth = 1 / 32f;
fadeLineWidth = true;
rgb = ColorHelper.getRGB(0xFFFFFF);
rgb = Color.WHITE;
int i = 15 << 20 | 15 << 4;
lightMapU = i >> 16 & '\uffff';
@ -187,7 +187,12 @@ public abstract class Outline {
// builder
public OutlineParams colored(int color) {
rgb = ColorHelper.getRGB(color);
rgb = new Color(color, false);
return this;
}
public OutlineParams colored(Color c) {
rgb = c.copy();
return this;
}