Skip to content

Commit

Permalink
Add Color#lerp and mark old config options as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Apr 30, 2024
1 parent af65d85 commit 8a2d26b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/minelittlepony/common/util/Color.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.minelittlepony.common.util;

import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;

/**
* Colouration Utilities
Expand Down Expand Up @@ -59,4 +60,16 @@ static int abgrToArgb(int color) {
ColorHelper.Argb.getRed(color)
);
}

/**
* Interpolates between two colours
*/
static int lerp(float delta, int from, int to) {
return argbToHex(
MathHelper.lerp(delta, a(from), a(to)),
MathHelper.lerp(delta, r(from), r(to)),
MathHelper.lerp(delta, g(from), g(to)),
MathHelper.lerp(delta, b(from), b(to))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* A configuration container that lets you programmatically index values by a key.
*/
public abstract class Config implements Iterable<Grouping> {
@SuppressWarnings("deprecation")
@Deprecated
public static final Adapter FLATTENED_JSON_ADAPTER = LegacyJsonConfigAdapter.DEFAULT;
public static final Adapter HEIRARCHICAL_JSON_ADAPTER = HeirarchicalJsonConfigAdapter.DEFAULT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.apache.logging.log4j.Logger;

public class HeirarchicalJsonConfigAdapter implements Config.Adapter {
private static final Logger logger = LogManager.getLogger();
private static final Logger LOGGER = LogManager.getLogger();

private final Gson gson;

Expand Down Expand Up @@ -58,7 +58,7 @@ public void save(Config config, Path file) {
}
writer.endObject();
} catch (IOException e) {
logger.warn("Error whilst saving Json config", e);
LOGGER.warn("Error whilst saving Json config", e);
}
}

Expand All @@ -79,7 +79,7 @@ public void load(Config config, Path file) {
});
});
} catch (IOException | JsonParseException e) {
logger.warn("Erorr whilst loading json config", e);
LOGGER.warn("Erorr whilst loading json config", e);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @deprecated Use Config with {@code Config#FLATTENED_JSON_ADAPTER}
*/
@Deprecated
@Deprecated(forRemoval = true)
public class JsonConfig extends Config {
public JsonConfig(Path path) {
super(LegacyJsonConfigAdapter.DEFAULT, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Deprecated
@Deprecated(forRemoval = true)
public class LegacyJsonConfigAdapter implements Config.Adapter {
private static final Logger logger = LogManager.getLogger();

Expand Down

0 comments on commit 8a2d26b

Please sign in to comment.