diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-28 17:29:26 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-28 17:29:26 +0700 |
commit | e85b11665a92e8a6bffb11b76b45ee3c97138bd2 (patch) | |
tree | 1e85d3673d6511df53b96deb8fc23989cd304722 /src/main/java/cc | |
parent | 61861be3663dc05883c387070c81eae9154444ef (diff) | |
download | OneConfig-e85b11665a92e8a6bffb11b76b45ee3c97138bd2.tar.gz OneConfig-e85b11665a92e8a6bffb11b76b45ee3c97138bd2.tar.bz2 OneConfig-e85b11665a92e8a6bffb11b76b45ee3c97138bd2.zip |
revert funny diamond hud stuff
add ExcludeType again
fix INSTANCE field stuff
Diffstat (limited to 'src/main/java/cc')
14 files changed, 303 insertions, 162 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Exclude.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Exclude.java index 8736e56..eddb490 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Exclude.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Exclude.java @@ -14,4 +14,11 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) public @interface Exclude { + ExcludeType type() default ExcludeType.ALL; + + enum ExcludeType { + ALL, + CONFIG, + HUD + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java index ee3b97f..bfad00c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java @@ -114,8 +114,8 @@ public class VigilanceConfig extends Config { try { Field field = valueBackedPropertyValue.getClass().getDeclaredField("obj"); field.setAccessible(true); - return (Field) field.get(valueBackedPropertyValue); - } catch (IllegalAccessException | NoSuchFieldException e) { + return field; + } catch (NoSuchFieldException e) { throw new RuntimeException(e); } } else if (data.getValue() instanceof KPropertyBackedPropertyValue) { diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java index 75bd98d..14e8d01 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java @@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.config.elements.OptionSubcategory; import cc.polyfrost.oneconfig.config.migration.Migrator; import cc.polyfrost.oneconfig.gui.elements.config.*; import cc.polyfrost.oneconfig.internal.config.annotations.Option; +import com.google.gson.FieldAttributes; import org.jetbrains.annotations.Nullable; import java.lang.annotation.Annotation; @@ -56,6 +57,8 @@ public class ConfigUtils { parentClass = clazz; } for (Field field : fields) { + Exclude exclude = findAnnotation(field, Exclude.class); + if (exclude != null && exclude.type() != Exclude.ExcludeType.CONFIG) continue; Option option = findAnnotation(field, Option.class); if (option == null) continue; options.add(getOption(option, field, object)); @@ -91,6 +94,25 @@ public class ConfigUtils { return null; } + public static <T extends Annotation> T findAnnotation(FieldAttributes field, Class<T> annotationType) { + T annotation = field.getAnnotation(annotationType); + if (annotation != null) return annotation; + for (Annotation ann : field.getAnnotations()) { + if (ann.annotationType().isAnnotationPresent(annotationType)) + return ann.annotationType().getAnnotation(annotationType); + } + return null; + } + + public static <T extends Annotation> T findAnnotation(Class<?> clazz, Class<T> annotationType) { + if (clazz.isAnnotationPresent(annotationType)) return clazz.getAnnotation(annotationType); + for (Annotation ann : clazz.getDeclaredAnnotations()) { + if (ann.annotationType().isAnnotationPresent(annotationType)) + return ann.annotationType().getAnnotation(annotationType); + } + return null; + } + public static Object getField(Field field, Object parent) { try { field.setAccessible(true); diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/ExclusionUtils.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/ExclusionUtils.java new file mode 100644 index 0000000..3981134 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/ExclusionUtils.java @@ -0,0 +1,15 @@ +package cc.polyfrost.oneconfig.config.gson; + +public class ExclusionUtils { + protected static boolean isSuperClassOf(Class<?> clazz, Class<?> parentClass) { + Class<?> tempClass = clazz; + Class<?> lastClass; + if (tempClass == parentClass) return true; + while (true) { + lastClass = tempClass; + tempClass = tempClass.getSuperclass(); + if (tempClass == lastClass) return false; + if (tempClass == parentClass) return true; + } + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java index 8efa0b7..7679b9c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java @@ -1,18 +1,22 @@ package cc.polyfrost.oneconfig.config.gson; +import cc.polyfrost.oneconfig.config.Config; import cc.polyfrost.oneconfig.config.annotations.Exclude; import cc.polyfrost.oneconfig.config.annotations.NonProfileSpecific; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; -public class NonProfileSpecificExclusionStrategy implements ExclusionStrategy { +public class NonProfileSpecificExclusionStrategy extends ExclusionUtils implements ExclusionStrategy { /** * @param f the field object that is under test * @return true if the field should be ignored; otherwise false */ @Override public boolean shouldSkipField(FieldAttributes f) { - return f.getAnnotation(NonProfileSpecific.class) == null || f.getAnnotation(Exclude.class) != null; + if (isSuperClassOf(f.getDeclaredClass(), Config.class)) return true; + if (f.getAnnotation(NonProfileSpecific.class) == null) return true; + Exclude exclude = f.getAnnotation(Exclude.class); + return exclude != null && exclude.type() != Exclude.ExcludeType.HUD; } /** @@ -21,6 +25,7 @@ public class NonProfileSpecificExclusionStrategy implements ExclusionStrategy { */ @Override public boolean shouldSkipClass(Class<?> clazz) { - return clazz.getAnnotation(Exclude.class) != null; + Exclude exclude = clazz.getAnnotation(Exclude.class); + return exclude != null && exclude.type() != Exclude.ExcludeType.HUD; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java index c94e8bd..45f3a04 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java @@ -1,18 +1,22 @@ package cc.polyfrost.oneconfig.config.gson; +import cc.polyfrost.oneconfig.config.Config; import cc.polyfrost.oneconfig.config.annotations.Exclude; import cc.polyfrost.oneconfig.config.annotations.NonProfileSpecific; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; -public class ProfileExclusionStrategy implements ExclusionStrategy { +public class ProfileExclusionStrategy extends ExclusionUtils implements ExclusionStrategy { /** * @param f the field object that is under test * @return true if the field should be ignored; otherwise false */ @Override public boolean shouldSkipField(FieldAttributes f) { - return f.getAnnotation(NonProfileSpecific.class) != null || f.getAnnotation(Exclude.class) != null; + if (isSuperClassOf(f.getDeclaredClass(), Config.class)) return true; + if (f.getAnnotation(NonProfileSpecific.class) != null) return true; + Exclude exclude = f.getAnnotation(Exclude.class); + return exclude != null && exclude.type() != Exclude.ExcludeType.HUD; } /** @@ -21,6 +25,7 @@ public class ProfileExclusionStrategy implements ExclusionStrategy { */ @Override public boolean shouldSkipClass(Class<?> clazz) { - return clazz.getAnnotation(NonProfileSpecific.class) != null || clazz.getAnnotation(Exclude.class) != null; + Exclude exclude = clazz.getAnnotation(Exclude.class); + return exclude != null && exclude.type() != Exclude.ExcludeType.HUD; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/Conditional.java b/src/main/java/cc/polyfrost/oneconfig/hud/Conditional.java new file mode 100644 index 0000000..d9f9ca9 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/hud/Conditional.java @@ -0,0 +1,12 @@ +package cc.polyfrost.oneconfig.hud; + +import cc.polyfrost.oneconfig.config.elements.BasicOption; + +import java.util.ArrayList; + +/** + * Marks that the HUD element has options to add programmatically. + */ +public interface Conditional { + void addNewOptions(String category, String subcategory, ArrayList<BasicOption> options); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java index e91a7ce..fb6f755 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java @@ -23,6 +23,9 @@ public class HUDUtils { options.add(new ConfigHeader(field, hud, hudAnnotation.name(), category, subcategory, 2)); options.add(new ConfigSwitch(hud.getClass().getField("enabled"), hud, "Enabled", category, subcategory, 2)); options.addAll(ConfigUtils.getClassOptions(hud)); + if (hud instanceof Conditional) { + ((Conditional) hud).addNewOptions(category, subcategory, options); + } options.add(new ConfigCheckbox(hud.getClass().getField("rounded"), hud, "Rounded corners", category, subcategory, 1)); options.get(options.size() - 1).addDependency(() -> hud.enabled); options.add(new ConfigCheckbox(hud.getClass().getField("border"), hud, "Outline/border", category, subcategory, 1)); diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/MultiTextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/MultiTextHud.java new file mode 100644 index 0000000..17e27ec --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/hud/MultiTextHud.java @@ -0,0 +1,120 @@ +package cc.polyfrost.oneconfig.hud; + +import cc.polyfrost.oneconfig.config.annotations.Exclude; +import cc.polyfrost.oneconfig.config.elements.BasicOption; +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.Stage; +import cc.polyfrost.oneconfig.events.event.TickEvent; +import cc.polyfrost.oneconfig.gui.elements.config.ConfigSwitch; +import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.renderer.RenderManager; + +import java.util.ArrayList; +import java.util.List; + +public abstract class MultiTextHud extends TextHud implements Conditional { + private transient int width = 100; + private transient int height; + private transient List<String> cachedStrings = null; + private transient final boolean caching; + + public MultiTextHud(boolean enabled) { + this(enabled, 0, 0); + } + + public MultiTextHud(boolean enabled, boolean caching) { + this(enabled, 0, 0, caching); + } + + public MultiTextHud(boolean enabled, int x, int y) { + this(enabled, x, y, true); + } + + public MultiTextHud(boolean enabled, int x, int y, boolean caching) { + super(enabled, x, y); + this.caching = caching; + if (caching) { + EventManager.INSTANCE.register(new TextCacher()); + } + } + + @Override + public final void addNewOptions(String category, String subcategory, ArrayList<BasicOption> options) { + if (caching) { + try { + options.add(new ConfigSwitch(getClass().getField("cacheText"), this, "Cache Text", category, subcategory, 1)); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } + } + + @Exclude(type = Exclude.ExcludeType.HUD) + public boolean cacheText = true; + + @Override + public final int getWidth(float scale) { + return (int) (width * scale); + } + + @Override + public final int getHeight(float scale) { + return (int) (height * scale); + } + + @Override + public final void draw(int x, int y, float scale) { + update(x, y, scale); + int textY = y; + width = 0; + for (String line : cachedStrings == null ? getLines() : cachedStrings) { + RenderManager.drawScaledString(line, x, textY, color.getRGB(), RenderManager.TextType.toType(textType), scale); + width = Math.max(width, UMinecraft.getFontRenderer().getStringWidth(line)); + textY += 12 * scale; + } + height = (int) ((textY - y) / scale - 3); + } + + @Override + public final void drawExample(int x, int y, float scale) { + update(x, y, scale); + int textY = y; + width = 0; + for (String line : getExampleLines()) { + RenderManager.drawScaledString(line, x, textY, color.getRGB(), RenderManager.TextType.toType(textType), scale); + width = Math.max(width, UMinecraft.getFontRenderer().getStringWidth(line)); + textY += 12 * scale; + } + height = (int) ((textY - y) / scale - 3); + } + + protected abstract List<String> getLines(); + + protected List<String> getExampleLines() { + return getLines(); + } + + /** + * Ran before the HUD is drawn. + * + * Can be used to update values but not necessarily process / render them. + * This should only be used if absolutely necessary. + */ + protected void update(int x, int y, float scale) { + + } + + private class TextCacher { + @Subscribe + private void onTick(TickEvent event) { + if (event.stage == Stage.START) { + if (cacheText) { + cachedStrings = getLines(); + } else { + cachedStrings = null; + } + } + } + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java index 2e32d8a..3c357e0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java @@ -1,81 +1,108 @@ package cc.polyfrost.oneconfig.hud; import cc.polyfrost.oneconfig.config.annotations.Dropdown; +import cc.polyfrost.oneconfig.config.annotations.Exclude; import cc.polyfrost.oneconfig.config.annotations.Switch; import cc.polyfrost.oneconfig.config.annotations.Text; +import cc.polyfrost.oneconfig.config.elements.BasicOption; +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.Stage; +import cc.polyfrost.oneconfig.events.event.TickEvent; +import cc.polyfrost.oneconfig.gui.elements.config.ConfigSwitch; +import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.renderer.RenderManager; -import java.util.Collections; -import java.util.List; +import java.util.ArrayList; + +public abstract class SingleTextHud extends TextHud implements Conditional { + + private transient String cachedString = null; + private transient final boolean caching; + + public SingleTextHud(String title) { + this(title, true); + } -public abstract class SingleTextHud extends TextHud { public SingleTextHud(String title, boolean enabled) { this(title, enabled, 0, 0); } + public SingleTextHud(String title, boolean enabled, boolean caching) { + this(title, enabled, 0, 0, caching); + } + public SingleTextHud(String title, boolean enabled, int x, int y) { + this(title, enabled, x, y, true); + } + + public SingleTextHud(String title, boolean enabled, int x, int y, boolean caching) { super(enabled, x, y); this.title = title; + this.caching = caching; + if (caching) { + EventManager.INSTANCE.register(new TextCacher()); + } } - /** - * This function is called every tick - * - * @return The new text - */ - protected abstract String getText(); - - /** - * This function is called every frame - * - * @return The new text, null to use the cached value - */ - protected String getTextFrequent() { - return null; + @Override + public void addNewOptions(String category, String subcategory, ArrayList<BasicOption> options) { + if (caching) { + try { + options.add(new ConfigSwitch(getClass().getField("cacheText"), this, "Cache Text", category, subcategory, 1)); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } } - /** - * This function is called every tick in the move GUI - * - * @return The new text - */ - protected String getExampleText() { - return getText(); - } + @Exclude(type = Exclude.ExcludeType.HUD) + public boolean cacheText = true; - /** - * This function is called every frame in the move GUI - * - * @return The new text, null to use the cached value - */ - protected String getExampleTextFrequent() { - return getTextFrequent(); + @Switch( + name = "Brackets" + ) + public boolean brackets = false; + + @Text( + name = "Title" + ) + public String title; + + @Dropdown( + name = "Title Location", + options = {"Left", "Right"} + ) + public int titleLocation = 0; + + @Override + public int getWidth(float scale) { + return (int) (UMinecraft.getFontRenderer().getStringWidth(getCompleteText(false)) * scale); } @Override - protected List<String> update() { - return Collections.singletonList(getCompleteText(getText())); + public int getExampleWidth(float scale) { + return (int) (UMinecraft.getFontRenderer().getStringWidth(getCompleteText(true)) * scale); } @Override - protected List<String> updateFrequent() { - String text = getTextFrequent(); - if (text == null) return null; - return Collections.singletonList(getCompleteText(text)); + public int getHeight(float scale) { + return (int) (UMinecraft.getFontRenderer().FONT_HEIGHT * scale); } @Override - protected List<String> updateExampleFrequent() { - String text = getExampleTextFrequent(); - if (text == null) return null; - return Collections.singletonList(getCompleteText(text)); + public void draw(int x, int y, float scale) { + update(x, y, scale); + RenderManager.drawScaledString(getCompleteText(false), x, y, color.getRGB(), RenderManager.TextType.toType(textType), scale); } @Override - protected List<String> updateExample() { - return Collections.singletonList(getCompleteText(getExampleText())); + public void drawExample(int x, int y, float scale) { + update(x, y, scale); + RenderManager.drawScaledString(getCompleteText(true), x, y, color.getRGB(), RenderManager.TextType.toType(textType), scale); } - protected final String getCompleteText(String text) { + protected final String getCompleteText(boolean example) { boolean showTitle = !title.trim().isEmpty(); StringBuilder builder = new StringBuilder(); if (brackets) { @@ -86,7 +113,7 @@ public abstract class SingleTextHud extends TextHud { builder.append(title).append(": "); } - builder.append(text); + builder.append(example ? getExampleText() : (cachedString == null ? getText() : cachedString)); if (showTitle && titleLocation == 1) { builder.append(" ").append(title); @@ -98,20 +125,32 @@ public abstract class SingleTextHud extends TextHud { return builder.toString(); } + public abstract String getText(); - @Switch( - name = "Brackets" - ) - public boolean brackets = false; + public String getExampleText() { + return getText(); + } - @Text( - name = "Title" - ) - public String title; + /** + * Ran before the HUD is drawn. + * + * Can be used to update values but not necessarily process / render them. + * This should only be used if absolutely necessary. + */ + protected void update(int x, int y, float scale) { - @Dropdown( - name = "Title Location", - options = {"Left", "Right"} - ) - public int titleLocation = 0; + } + + private class TextCacher { + @Subscribe + private void onTick(TickEvent event) { + if (event.stage == Stage.START) { + if (cacheText) { + cachedString = getText(); + } else { + cachedString = null; + } + } + } + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java index 7895f26..74a7602 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java @@ -3,17 +3,8 @@ package cc.polyfrost.oneconfig.hud; import cc.polyfrost.oneconfig.config.annotations.Color; import cc.polyfrost.oneconfig.config.annotations.Dropdown; import cc.polyfrost.oneconfig.config.core.OneColor; -import cc.polyfrost.oneconfig.internal.hud.HudCore; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; -import cc.polyfrost.oneconfig.renderer.RenderManager; - -import java.util.List; - -public abstract class TextHud extends Hud { - protected transient List<String> lines = null; - private transient int width; - private transient int height; +abstract class TextHud extends Hud { @Color( name = "Text Color" ) @@ -25,75 +16,8 @@ public abstract class TextHud extends Hud { ) public int textType = 0; + public TextHud(boolean enabled, int x, int y) { super(enabled, x, y); } - public TextHud(boolean enabled) { - this(enabled, 0, 0); - } - - /** - * This function is called every tick - * - * @return The new lines - */ - protected abstract List<String> update(); - - /** - * This function is called every frame - * - * @return The new lines, null if you want to use the cached lines - */ - protected List<String> updateFrequent() { - return null; - } - - /** - * This function is called every tick in the move GUI - * - * @return The new lines - */ - protected List<String> updateExample() { - return update(); - } - - /** - * This function is called every frame in the move GUI - * - * @return The new lines, null if you want to use the cached lines - */ - protected List<String> updateExampleFrequent() { - return updateFrequent(); - } - - @Override - public void draw(int x, int y, float scale) { - List<String> frequentLines = HudCore.editing ? updateExampleFrequent() : updateFrequent(); - if (frequentLines != null) lines = frequentLines; - if (lines == null) return; - - int textY = y; - width = 0; - for (String line : lines) { - RenderManager.drawScaledString(line, x, textY, color.getRGB(), RenderManager.TextType.toType(textType), scale); - width = Math.max(width, UMinecraft.getFontRenderer().getStringWidth(line)); - textY += 12 * scale; - } - height = (int) ((textY - y) / scale - 3); - } - - @Override - public int getWidth(float scale) { - return (int) (width * scale); - } - - @Override - public int getHeight(float scale) { - return (int) (height * scale); - } - - public void tick() { - if (!HudCore.editing) lines = update(); - else lines = updateExample(); - } } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java index 3057c4f..90c1062 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java @@ -12,14 +12,14 @@ import java.util.TimerTask; import java.util.stream.Collectors; public class ConfigCore { - /*static { + static { new Timer().scheduleAtFixedRate(new TimerTask() { @Override public void run() { saveAll(); } }, 30000, 30000); - }*/ + } public static List<Mod> oneConfigMods = new ArrayList<>(); public static void saveAll() { diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java index 79bf4d8..7912ec5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java @@ -1,11 +1,9 @@ package cc.polyfrost.oneconfig.internal.hud; import cc.polyfrost.oneconfig.events.event.HudRenderEvent; -import cc.polyfrost.oneconfig.events.event.TickEvent; import cc.polyfrost.oneconfig.hud.Hud; -import cc.polyfrost.oneconfig.hud.TextHud; -import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import java.util.ArrayList; @@ -21,13 +19,4 @@ public class HudCore { hud.drawAll(hud.getXScaled(UResolution.getScaledWidth()), hud.getYScaled(UResolution.getScaledHeight()), hud.scale, true); } } - - @Subscribe - public void onTick(TickEvent event) { - for (Hud hud : huds) { - if (hud instanceof TextHud) { - ((TextHud) hud).tick(); - } - } - } } diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java index 48ccfb2..c94f5f7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java @@ -1,18 +1,18 @@ package cc.polyfrost.oneconfig.test; -import cc.polyfrost.oneconfig.hud.TextHud; +import cc.polyfrost.oneconfig.hud.MultiTextHud; import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; import java.util.List; -public class TestMultilineHud_Test extends TextHud { +public class TestMultilineHud_Test extends MultiTextHud { public TestMultilineHud_Test() { super(true); } @Override - public List<String> update() { + protected List<String> getLines() { return Lists.newArrayList(String.valueOf(System.currentTimeMillis()), String.valueOf(Minecraft.getSystemTime())); } } |