diff options
Diffstat (limited to 'versions/src')
23 files changed, 293 insertions, 124 deletions
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java index 4f73198..7eb5ef9 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java @@ -24,43 +24,32 @@ import java.io.File; //#if MC<=11202 @net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") //#else +//#if FORGE==1 //$$ @net.minecraftforge.fml.common.Mod("@ID@") //#endif +//#endif public class OneConfig { public OneConfig() { EventManager.INSTANCE.register(this); } - public static final File oneConfigDir = new File("./OneConfig"); public static final Logger LOGGER = LogManager.getLogger("@NAME@"); - private static boolean preLaunched = false; private static boolean initialized = false; /** - * Called before mods are loaded. + * Called after mods are loaded. * <p><b>SHOULD NOT BE CALLED!</b></p> */ - public static void preLaunch() { - if (preLaunched) return; - oneConfigDir.mkdirs(); - new File(oneConfigDir, "profiles").mkdirs(); + @SuppressWarnings("ResultOfMethodCallIgnored") + public static void init() { + if (initialized) return; if (OneConfigConfig.getInstance() == null) { OneConfigConfig.getInstance(); } if (Preferences.getInstance() == null) { Preferences.getInstance(); } - preLaunched = true; - } - - /** - * Called after mods are loaded. - * <p><b>SHOULD NOT BE CALLED!</b></p> - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - public static void init() { - if (initialized) return; GuiUtils.getDeltaTime(); // called to make sure static initializer is called try { EventManager.INSTANCE.register(BlurHandler.INSTANCE); diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/eggs/TechnobladeCrownRenderer.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/eggs/TechnobladeCrownRenderer.java deleted file mode 100644 index f5e7bed..0000000 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/eggs/TechnobladeCrownRenderer.java +++ /dev/null @@ -1,39 +0,0 @@ -//#if MC<=11202 -package cc.polyfrost.oneconfig.internal.eggs; - -import cc.polyfrost.oneconfig.internal.config.Preferences; -import net.minecraft.client.model.ModelPig; -import net.minecraft.client.renderer.entity.RenderPig; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.passive.EntityPig; -import net.minecraft.util.ResourceLocation; - -/** - * Adapted from technomodel under MIT - * <a href="https://github.com/thecolonel63/technomodel/blob/master/LICENSE">...</a> - */ -public class TechnobladeCrownRenderer<T extends EntityPig> implements LayerRenderer<T> { - - private static final ResourceLocation CROWN_TEXTURE = new ResourceLocation("oneconfig", "textures/entity/pig/technocrown.png"); - private final RenderPig renderer; - private final ModelPig pigModel = new ModelPig(0.5F); - - public TechnobladeCrownRenderer(RenderPig renderPig) { - renderer = renderPig; - } - - @Override - public void doRenderLayer(T entitylivingbaseIn, float f, float g, float partialTicks, float h, float i, float j, float scale) { - if (Preferences.easterEgg1 && entitylivingbaseIn.hasCustomName() && entitylivingbaseIn.getCustomNameTag().equals("Technoblade")) { - this.renderer.bindTexture(CROWN_TEXTURE); - this.pigModel.setModelAttributes(renderer.getMainModel()); - this.pigModel.render(entitylivingbaseIn, f, g, h, i, j, scale); - } - } - - @Override - public boolean shouldCombineTextures() { - return true; - } -} -//#endif
\ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java index 3424d2b..f4d15a4 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java @@ -7,6 +7,9 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.internal.config.Preferences; import cc.polyfrost.oneconfig.internal.gui.BlurHandler; import cc.polyfrost.oneconfig.internal.mixin.ShaderGroupAccessor; +//#if FABRIC==1 +//$$ import cc.polyfrost.oneconfig.internal.mixin.GameRendererAccessor; +//#endif import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.libs.universal.UScreen; @@ -102,7 +105,11 @@ public class BlurHandlerImpl implements BlurHandler { // a one of ours, we should load our own blur! if (!isShaderActive() && gui instanceof OneConfigGui && Preferences.enableBlur) { + //#if FABRIC==1 + //$$ ((GameRendererAccessor) UMinecraft.getMinecraft().gameRenderer).invokeLoadShader(this.blurShader); + //#else UMinecraft.getMinecraft().entityRenderer.loadShader(this.blurShader); + //#endif this.start = System.currentTimeMillis(); this.progress = 0; diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java index 23d7d84..d49ea5d 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -32,11 +32,6 @@ public class MinecraftMixin { Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); } - @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;)V", remap = false), remap = true) - private void onPreLaunch(CallbackInfo ci) { - OneConfig.preLaunch(); - } - @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) private void onInit(CallbackInfo ci) { EventManager.INSTANCE.post(new InitializationEvent()); diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/RenderPigMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/RenderPigMixin.java deleted file mode 100644 index 1bd1fae..0000000 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/RenderPigMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -//#if MC<=11202 -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.internal.eggs.TechnobladeCrownRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.renderer.entity.RenderLiving; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPig; -import net.minecraft.entity.passive.EntityPig; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(RenderPig.class) -public abstract class RenderPigMixin extends RenderLiving<EntityPig> { - public RenderPigMixin(RenderManager renderManager, ModelBase modelBase, float f) { - super(renderManager, modelBase, f); - } - @Inject(method = "<init>", at = @At("TAIL")) - private void addCrown(RenderManager renderManager, ModelBase modelBase, float f, CallbackInfo ci) { - addLayer(new TechnobladeCrownRenderer<>((RenderPig) (Object) this)); - } -} -//#endif
\ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java index 6a76a09..0ef5414 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java @@ -43,11 +43,16 @@ public class OneConfigMixinPlugin implements IMixinConfigPlugin { public List<String> getMixins() { if (Platform.getInstance().getMinecraftVersion() >= 11600) { ArrayList<String> mixins = new ArrayList<>(); - mixins.add("ClientModLoaderMixin"); - mixins.add("KeyboardListenerMixin"); - mixins.add("MouseHelperAccessor"); - mixins.add("MouseHelperMixin"); - mixins.add("TimeTrackerMixin"); + if (Platform.getInstance().getLoader() == Platform.Loader.FORGE) { + mixins.add("ClientModLoaderMixin"); + } else { + mixins.add("FramebufferMixin"); + mixins.add("GameRendererAccessor"); + } + mixins.add("KeyboardMixin"); + mixins.add("MouseAccessor"); + mixins.add("MouseMixin"); + mixins.add("TickTimeTrackerMixin"); return mixins; } else { return null; diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java index b53b357..16ff25c 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java @@ -7,9 +7,13 @@ import cc.polyfrost.oneconfig.platform.GLPlatform; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; + +//#if FORGE==1 import net.minecraft.client.shader.Framebuffer; +//#else +//$$ import cc.polyfrost.oneconfig.internal.hook.FramebufferHook; +//#endif -@SuppressWarnings("unused") public class GLPlatformImpl implements GLPlatform { @Override @@ -48,7 +52,11 @@ public class GLPlatformImpl implements GLPlatform { @Override public void enableStencil() { + //#if FORGE==1 Framebuffer framebuffer = UMinecraft.getMinecraft().getFramebuffer(); + //#else + //$$ FramebufferHook framebuffer = ((FramebufferHook) UMinecraft.getMinecraft().getFramebuffer()); + //#endif if (!framebuffer.isStencilEnabled()) { framebuffer.enableStencil(); } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GuiPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GuiPlatformImpl.java index 6ea3c03..e4628c1 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GuiPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GuiPlatformImpl.java @@ -6,7 +6,6 @@ import cc.polyfrost.oneconfig.platform.GuiPlatform; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiScreen; -@SuppressWarnings("unused") public class GuiPlatformImpl implements GuiPlatform { @Override diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/I18nPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/I18nPlatformImpl.java index 1913238..6245bc4 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/I18nPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/I18nPlatformImpl.java @@ -3,7 +3,6 @@ package cc.polyfrost.oneconfig.platform.impl; import cc.polyfrost.oneconfig.platform.I18nPlatform; import net.minecraft.client.resources.I18n; -@SuppressWarnings("unused") public class I18nPlatformImpl implements I18nPlatform { @Override diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java index c984ac3..f4a78ac 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java @@ -2,17 +2,26 @@ package cc.polyfrost.oneconfig.platform.impl; import cc.polyfrost.oneconfig.platform.LoaderPlatform; //#if MC>=11600 -//$$ import net.minecraftforge.fml.ModList; + //#if FORGE==1 + //$$ import net.minecraftforge.fml.ModList; + //#else + //$$ import net.fabricmc.loader.api.FabricLoader; + //#endif //#endif +//#if FORGE==1 import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; +//#endif -@SuppressWarnings("unused") public class LoaderPlatformImpl implements LoaderPlatform { @Override public boolean isModLoaded(String id) { //#if MC>=11600 - //$$ return ModList.get().isLoaded(id); + //#if FORGE==1 + //$$ return ModList.get().isLoaded(id); + //#else + //$$ return FabricLoader.getInstance().isModLoaded(id); + //#endif //#else return Loader.isModLoaded(id); //#endif @@ -20,17 +29,25 @@ public class LoaderPlatformImpl implements LoaderPlatform { @Override public boolean hasActiveModContainer() { + //#if FORGE==1 return Loader.instance().activeModContainer() != null; + //#else + //$$ return false; + //#endif } @Override public ActiveMod getActiveModContainer() { + //#if FORGE==1 ModContainer container = Loader.instance().activeModContainer(); if (container == null) return null; - //#if MC==11202 - return new ActiveMod(container.getName(), container.getModId(), container.getVersion()); + //#if MC==11202 + return new ActiveMod(container.getName(), container.getModId(), container.getVersion()); + //#else + //$$ return new ActiveMod(container.getModInfo().getDisplayName(), container.getModId(), container.getModInfo().getVersion().getQualifier()); + //#endif //#else - //$$ return new ActiveMod(container.getModInfo().getDisplayName(), container.getModId(), container.getModInfo().getVersion().getQualifier()); + //$$ return null; //#endif } } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java index e368a91..74fdd04 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java @@ -3,13 +3,12 @@ package cc.polyfrost.oneconfig.platform.impl; import cc.polyfrost.oneconfig.platform.MousePlatform; //#if MC>=11600 //$$ import cc.polyfrost.oneconfig.libs.universal.UMinecraft; -//$$ import cc.polyfrost.oneconfig.internal.mixin.MouseHelperAccessor; +//$$ import cc.polyfrost.oneconfig.internal.mixin.MouseAccessor; //$$ import org.lwjgl.glfw.GLFW; //#else import org.lwjgl.input.Mouse; //#endif -@SuppressWarnings("unused") public class MousePlatformImpl implements MousePlatform { //#if MC>11600 @@ -37,7 +36,7 @@ public class MousePlatformImpl implements MousePlatform { @Override public double getDWheel() { //#if MC>=11600 - //$$ double scrollDelta = ((MouseHelperAccessor) UMinecraft.getMinecraft().mouseHelper).getAccumulatedScrollDelta(); + //$$ double scrollDelta = ((MouseAccessor) UMinecraft.getMinecraft().mouseHelper).getEventDeltaWheel(); //$$ double amount = scrollDelta - prevScroll; //$$ prevScroll = scrollDelta; //$$ return amount; @@ -49,7 +48,11 @@ public class MousePlatformImpl implements MousePlatform { @Override public double getMouseDX() { //#if MC>=11600 - //$$ return UMinecraft.getMinecraft().mouseHelper.getXVelocity(); + //#if FORGE==1 + //$$ return UMinecraft.getMinecraft().mouseHelper.getXVelocity(); + //#else + //$$ return ((MouseAccessor) UMinecraft.getMinecraft().mouse).getCursorDeltaX(); + //#endif //#else return Mouse.getDX(); //#endif @@ -58,7 +61,11 @@ public class MousePlatformImpl implements MousePlatform { @Override public double getMouseDY() { //#if MC>=11600 - //$$ return UMinecraft.getMinecraft().mouseHelper.getYVelocity(); + //#if FORGE==1 + //$$ return UMinecraft.getMinecraft().mouseHelper.getYVelocity(); + //#else + //$$ return ((MouseAccessor) UMinecraft.getMinecraft().mouse).getCursorDeltaY(); + //#endif //#else return Mouse.getDY(); //#endif diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/NanoVGPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/NanoVGPlatformImpl.java new file mode 100644 index 0000000..8469fcc --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/NanoVGPlatformImpl.java @@ -0,0 +1,88 @@ +package cc.polyfrost.oneconfig.platform.impl; + +import cc.polyfrost.oneconfig.platform.NanoVGPlatform; +import org.jetbrains.annotations.Nullable; +import org.lwjgl.nanovg.NVGLUFramebuffer; +import org.lwjgl.nanovg.NanoVGGL2; + +public class NanoVGPlatformImpl implements NanoVGPlatform { + @Override + public int nnvglCreateImageFromHandle(long var0, int var2, int var3, int var4, int var5) { + return NanoVGGL2.nnvglCreateImageFromHandle(var0, var2, var3, var4, var5); + } + + @Override + public int nvglCreateImageFromHandle(long ctx, int textureId, int w, int h, int flags) { + return NanoVGGL2.nvglCreateImageFromHandle(ctx, textureId, w, h, flags); + } + + @Override + public int nnvglImageHandle(long var0, int var2) { + return NanoVGGL2.nnvglImageHandle(var0, var2); + } + + @Override + public int nvglImageHandle(long ctx, int image) { + return NanoVGGL2.nvglImageHandle(ctx, image); + } + + @Override + public long nnvgCreate(int var0) { + return NanoVGGL2.nnvgCreate(var0); + } + + @Override + public long nvgCreate(int flags) { + return NanoVGGL2.nvgCreate(flags); + } + + @Override + public void nnvgDelete(long var0) { + NanoVGGL2.nnvgDelete(var0); + } + + @Override + public void nvgDelete(long ctx) { + NanoVGGL2.nvgDelete(ctx); + } + + @Override + public long nnvgluCreateFramebuffer(long var0, int var2, int var3, int var4) { + return NanoVGGL2.nnvgluCreateFramebuffer(var0, var2, var3, var4); + } + + @Nullable + @Override + public NVGLUFramebuffer nvgluCreateFramebuffer(long ctx, int w, int h, int imageFlags) { + return NanoVGGL2.nvgluCreateFramebuffer(ctx, w, h, imageFlags); + } + + @Override + public void nnvgluBindFramebuffer(long var0, long var2) { + NanoVGGL2.nnvgluBindFramebuffer(var0, var2); + } + + @Override + public void nvgluBindFramebuffer(long ctx, @Nullable NVGLUFramebuffer fb) { + NanoVGGL2.nvgluBindFramebuffer(ctx, fb); + } + + @Override + public void nnvgluDeleteFramebuffer(long var0, long var2) { + NanoVGGL2.nnvgluDeleteFramebuffer(var0, var2); + } + + @Override + public void nvgluDeleteFramebuffer(long ctx, NVGLUFramebuffer fb) { + NanoVGGL2.nvgluDeleteFramebuffer(ctx, fb); + } + + @Override + public void triggerStaticInitialization() { + try { + Class.forName(NanoVGGL2.class.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java index 91edc53..ef22285 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java @@ -3,7 +3,6 @@ package cc.polyfrost.oneconfig.platform.impl; import cc.polyfrost.oneconfig.platform.Platform; import net.minecraft.client.Minecraft; -@SuppressWarnings("unused") public class PlatformImpl implements Platform { @Override public boolean isCallingFromMinecraftThread() { @@ -38,4 +37,13 @@ public class PlatformImpl implements Platform { return 10800; //#endif } + + @Override + public Loader getLoader() { + //#if FORGE==1 + return Loader.FORGE; + //#else + //$$ return Loader.FABRIC; + //#endif + } } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/ServerPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/ServerPlatformImpl.java index 81454b0..8f145d3 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/ServerPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/ServerPlatformImpl.java @@ -4,7 +4,6 @@ import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.platform.ServerPlatform; import net.minecraft.client.entity.EntityPlayerSP; -@SuppressWarnings("unused") public class ServerPlatformImpl implements ServerPlatform { @Override diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java new file mode 100644 index 0000000..805937f --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java @@ -0,0 +1,23 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.hud.BasicHud; +import cc.polyfrost.oneconfig.internal.assets.Images; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.renderer.RenderManager; + +public class TestBasicHud_Test extends BasicHud { + @Override + protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) { + RenderManager.setupAndDraw(true, vg -> RenderManager.drawImage(vg, Images.HUE_GRADIENT, x, y, 50 * scale, 50f * scale)); + } + + @Override + protected float getWidth(float scale, boolean example) { + return 50 * scale; + } + + @Override + protected float getHeight(float scale, boolean example) { + return 50 * scale; + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java index 772bba7..09b3fe5 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java @@ -126,6 +126,12 @@ public class TestConfig_Test extends Config { ) public TestMultilineHud_Test multilineHud = new TestMultilineHud_Test(); + @HUD( + name = "Test Basic HUD", + category = "HUD" + ) + public TestBasicHud_Test basicHud = new TestBasicHud_Test(); + public TestConfig_Test() { super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json"); initialize(); diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java index ae557c7..4b380ca 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java @@ -15,7 +15,7 @@ public class TestHud_Test extends SingleTextHud { } @Override - public String getText() { + public String getText(boolean example) { times++; return String.valueOf(times); } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt new file mode 100644 index 0000000..fd6df6b --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt @@ -0,0 +1,45 @@ +package cc.polyfrost.oneconfig.test + +import cc.polyfrost.oneconfig.renderer.font.Fonts +import cc.polyfrost.oneconfig.utils.dsl.* +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen +import java.awt.Color +import kotlin.system.measureTimeMillis + +/** + * A kotlinified version of [TestNanoVGGui_Test]. + * Uses OneConfig's Kotlin DSL to render instead of RenderManager + * + * @see nanoVG + * @see TestNanoVGGui_Test + */ +class TestKotlinNanoVGGui_Test : OneUIScreen() { + + override fun draw(vg: Long, partialTicks: Float) { + nanoVG(vg) { + val millis = measureTimeMillis { + drawRect(0f, 0f, 100f, 100f, Color.BLUE.rgb) + drawRoundedRect( + 305f, 305f, 100f, 100f, 8f, Color.YELLOW.rgb + ) + drawText( + "Hello!", 100f, 100f, Color.WHITE.rgb, 50f, Fonts.BOLD + ) + drawLine( + 0f, 0f, 100f, 100f, 7f, Color.PINK.rgb + ) + drawCircle( + 200f, 200f, 50f, Color.WHITE.rgb + ) + } + drawText( + millis.toString() + "ms", + 500f, + 500f, + Color.WHITE.rgb, + 100f, + Fonts.BOLD + ) + } + } +}
\ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java index 1665062..f71b01d 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java @@ -10,7 +10,8 @@ public class TestMultilineHud_Test extends TextHud { } @Override - protected void getLines(List<String> lines) { + protected void getLines(List<String> lines, boolean example) { lines.add(String.valueOf(System.currentTimeMillis())); + lines.add("HEY!"); } } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java index e8b6b91..4182bb6 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java @@ -2,25 +2,27 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; -import cc.polyfrost.oneconfig.libs.universal.UScreen; -import org.jetbrains.annotations.NotNull; +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen; import java.awt.*; -public class TestNanoVGGui_Test extends UScreen { +/** + * A GUI that uses RenderManager, NanoVG, and OneUIScreen to render a simple GUI. + * + * @see OneUIScreen + * @see TestKotlinNanoVGGui_Test + * @see RenderManager + */ +public class TestNanoVGGui_Test extends OneUIScreen { @Override - public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks); + public void draw(long vg, float partialTicks) { long startTime = System.nanoTime(); - RenderManager.setupAndDraw((vg) -> { - RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); - RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); - RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); - RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); - RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); - RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); - }); + RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); + RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); + RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); + RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); + RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); + RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); } } diff --git a/versions/src/main/resources/META-INF/services/cc.polyfrost.oneconfig.platform.NanoVGPlatform b/versions/src/main/resources/META-INF/services/cc.polyfrost.oneconfig.platform.NanoVGPlatform new file mode 100644 index 0000000..7d256b7 --- /dev/null +++ b/versions/src/main/resources/META-INF/services/cc.polyfrost.oneconfig.platform.NanoVGPlatform @@ -0,0 +1 @@ +cc.polyfrost.oneconfig.platform.impl.NanoVGPlatformImpl
\ No newline at end of file diff --git a/versions/src/main/resources/fabric.mod.json b/versions/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..23d8e97 --- /dev/null +++ b/versions/src/main/resources/fabric.mod.json @@ -0,0 +1,35 @@ +{ + "schemaVersion": 1, + "id": "${id}", + "name": "${name}", + "version": "${version}", + "description": "OneConfig", + "authors": [ + "Polyfrost" + ], + "contact": { + "homepage": "https://polyfrost.cc", + "sources": "https://github.com/Polyfrost/OneConfig", + "issues": "https://inv.wtf/polyfrost" + }, + "license": "LGPL-3.0", + "environment": "client", + "mixins": [ + "mixins.oneconfig.json" + ], + "entrypoints": { + "preLaunch": [ + "cc.polyfrost.oneconfig.internal.plugin.OneConfigPreLaunch" + ] + }, + "depends": { + "fabricloader": ">=0.12.0", + "minecraft": "${mcVersionStr}", + "java": ">=${java}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +}
\ No newline at end of file diff --git a/versions/src/main/resources/mixins.oneconfig.json b/versions/src/main/resources/mixins.oneconfig.json index 1486c9d..4a03fd0 100644 --- a/versions/src/main/resources/mixins.oneconfig.json +++ b/versions/src/main/resources/mixins.oneconfig.json @@ -14,7 +14,6 @@ "NetHandlerPlayClientMixin", "NetworkManagerMixin", "OptifineConfigMixin", - "RenderPigMixin", "ShaderGroupAccessor", "VigilantMixin", "WorldClientMixin" |