Fixing svgTexture
This commit is contained in:
@@ -2,6 +2,9 @@ package org.saturnclient.common.minecraft;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public abstract class MinecraftProvider {
|
||||
public static MinecraftProvider PROVIDER;
|
||||
|
||||
@@ -12,4 +15,6 @@ public abstract class MinecraftProvider {
|
||||
public abstract File getRunDirectory();
|
||||
|
||||
public abstract int getWidth(String text, int font);
|
||||
|
||||
public abstract void registerBufferedImageTexture(SaturnIdentifier i, BufferedImage bi);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@ public class SaturnIdentifier extends MinecraftBinding {
|
||||
return new SaturnIdentifier(namespace, path);
|
||||
}
|
||||
|
||||
public static SaturnIdentifier of(String fullPath) {
|
||||
String[] p = fullPath.split(":", 2);
|
||||
|
||||
return new SaturnIdentifier(p[0], p[1]);
|
||||
}
|
||||
|
||||
public static SaturnIdentifier ofVanilla(String path) {
|
||||
return new SaturnIdentifier("minecraft", path);
|
||||
}
|
||||
|
||||
@@ -5,18 +5,11 @@ import org.saturnclient.ui.Element;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
import org.saturnclient.ui.RenderScope;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ImageTexture extends Element {
|
||||
Identifier sprite;
|
||||
|
||||
public ImageTexture(Identifier sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
SaturnIdentifier sprite;
|
||||
|
||||
public ImageTexture(SaturnIdentifier sprite) {
|
||||
this.sprite = (Identifier) sprite.inner;
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,16 +9,11 @@ import java.util.List;
|
||||
|
||||
import com.kitfox.svg.SVGDiagram;
|
||||
import com.kitfox.svg.SVGUniverse;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.saturnclient.cosmetics.cloak.utils.IdentifierUtils;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
||||
|
||||
public class SvgTexture {
|
||||
|
||||
private static List<Identifier> svgCache = new ArrayList<>();
|
||||
private static List<SaturnIdentifier> svgCache = new ArrayList<>();
|
||||
|
||||
private static BufferedImage renderSvg(InputStream svgStream, int width, int height) throws Exception {
|
||||
// Load SVG
|
||||
@@ -52,9 +47,8 @@ public class SvgTexture {
|
||||
return image;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Identifier getSvg(MinecraftClient client, Identifier svgImage, int width, int height) {
|
||||
Identifier id = Identifier
|
||||
public static SaturnIdentifier getSvg(MinecraftClient client, SaturnIdentifier svgImage, int width, int height) {
|
||||
SaturnIdentifier id = SaturnIdentifier
|
||||
.of(svgImage.toString().replaceAll("\\.svg$", (width + "_" + height).toString() + ".png"));
|
||||
|
||||
if (svgCache.contains(id)) {
|
||||
|
||||
Reference in New Issue
Block a user