Extracted full texture icon

This commit is contained in:
Ven committed 2023-06-30 11:13:28 +01:00
1 parent d3b1461664
commit 49ec327c97
2 files changed
+46 -46

No files matched your search

@@ -0,0 +1,44 @@
package com.falsepattern.lib.internal.render;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minecraft.util.IIcon;
@Getter
@AllArgsConstructor
public final class FullTextureIcon implements IIcon {
private final String iconName;
private final int iconWidth;
private final int iconHeight;
@Override
public float getMinU() {
return 0F;
}
@Override
public float getMinV() {
return 0F;
}
@Override
public float getMaxU() {
return 1F;
}
@Override
public float getMaxV() {
return 1F;
}
@Override
public float getInterpolatedU(double textureU) {
return (float) textureU / 16F;
}
@Override
public float getInterpolatedV(double textureV) {
return (float) textureV / 16F;
}
}
@@ -21,6 +21,7 @@
package com.falsepattern.lib.util;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.internal.render.FullTextureIcon;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import lombok.val;
@@ -72,52 +73,7 @@ public final class RenderUtil {
*/
@StableAPI.Expose(since = "0.10.0")
public static IIcon getFullTextureIcon(String iconName, int width, int height) {
return new IIcon() {
@Override
public int getIconWidth() {
return width;
}
@Override
public int getIconHeight() {
return height;
}
@Override
public float getMinU() {
return 0;
}
@Override
public float getMaxU() {
return 1;
}
@Override
public float getInterpolatedU(double u) {
return (float) (u / 16D);
}
@Override
public float getMinV() {
return 0;
}
@Override
public float getMaxV() {
return 1;
}
@Override
public float getInterpolatedV(double v) {
return (float) (v / 16D);
}
@Override
public String getIconName() {
return iconName;
}
};
return new FullTextureIcon(iconName, width, height);
}
/**