diff options
Diffstat (limited to 'versions/src/main/java/cc/polyfrost/oneconfig/platform')
3 files changed, 86 insertions, 20 deletions
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 2755f7f..c984ac3 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 @@ -1,6 +1,9 @@ package cc.polyfrost.oneconfig.platform.impl; import cc.polyfrost.oneconfig.platform.LoaderPlatform; +//#if MC>=11600 +//$$ import net.minecraftforge.fml.ModList; +//#endif import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; @@ -8,7 +11,11 @@ import net.minecraftforge.fml.common.ModContainer; public class LoaderPlatformImpl implements LoaderPlatform { @Override public boolean isModLoaded(String id) { + //#if MC>=11600 + //$$ return ModList.get().isLoaded(id); + //#else return Loader.isModLoaded(id); + //#endif } @Override @@ -19,9 +26,8 @@ public class LoaderPlatformImpl implements LoaderPlatform { @Override public ActiveMod getActiveModContainer() { ModContainer container = Loader.instance().activeModContainer(); - if (container == null) - return null; - //#if MC<=11202 + if (container == null) return null; + //#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()); 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 1276000..e368a91 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 @@ -1,53 +1,84 @@ 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 org.lwjgl.glfw.GLFW; +//#else import org.lwjgl.input.Mouse; +//#endif @SuppressWarnings("unused") public class MousePlatformImpl implements MousePlatform { + //#if MC>11600 + //$$ private double prevScroll = 0; + //#endif + @Override - public int getMouseX() { + public double getMouseX() { + //#if MC>=11600 + //$$ return UMinecraft.getMinecraft().mouseHelper.getMouseX(); + //#else return Mouse.getX(); + //#endif } @Override - public int getMouseY() { + public double getMouseY() { + //#if MC>=11600 + //$$ return UMinecraft.getMinecraft().mouseHelper.getMouseY(); + //#else return Mouse.getY(); + //#endif } @Override - public int getDWheel() { + public double getDWheel() { + //#if MC>=11600 + //$$ double scrollDelta = ((MouseHelperAccessor) UMinecraft.getMinecraft().mouseHelper).getAccumulatedScrollDelta(); + //$$ double amount = scrollDelta - prevScroll; + //$$ prevScroll = scrollDelta; + //$$ return amount; + //#else return Mouse.getDWheel(); + //#endif } @Override - public int getMouseDX() { + public double getMouseDX() { + //#if MC>=11600 + //$$ return UMinecraft.getMinecraft().mouseHelper.getXVelocity(); + //#else return Mouse.getDX(); + //#endif } @Override - public int getMouseDY() { + public double getMouseDY() { + //#if MC>=11600 + //$$ return UMinecraft.getMinecraft().mouseHelper.getYVelocity(); + //#else return Mouse.getDY(); + //#endif } @Override - public boolean next() { - return Mouse.next(); - } - - @Override - public boolean getEventButtonState() { - return Mouse.getEventButtonState(); - } - - @Override - public int getEventButton() { - return Mouse.getEventButton(); + public int getButtonState(int button) { + //#if MC>=11600 + //$$ return GLFW.glfwGetMouseButton(UMinecraft.getMinecraft().getMainWindow().getHandle(), button); + //#else + return Mouse.isButtonDown(button) ? 1 : 0; + //#endif } @Override public boolean isButtonDown(int button) { + //#if MC>=11600 + //$$ return GLFW.glfwGetMouseButton(UMinecraft.getMinecraft().getMainWindow().getHandle(), button) == GLFW.GLFW_PRESS; + //#else return Mouse.isButtonDown(button); + //#endif } } 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 7ad639c..91edc53 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 @@ -9,4 +9,33 @@ public class PlatformImpl implements Platform { public boolean isCallingFromMinecraftThread() { return Minecraft.getMinecraft().isCallingFromMinecraftThread(); } + + @Override + public int getMinecraftVersion() { + //#if MC>=11900 + //$$ return 11900; + //#elseif MC>=11800 + //$$ return 11800; + //#elseif MC>=11700 + //$$ return 11700; + //#elseif MC>=11600 + //$$ return 11600; + //#elseif MC>=11500 + //$$ return 11500; + //#elseif MC>=11400 + //$$ return 11400; + //#elseif MC>=11300 + //$$ return 11300; + //#elseif MC>=11200 + //$$ return 11200; + //#elseif MC>=11100 + //$$ return 11100; + //#elseif MC>=11000 + //$$ return 11000; + //#elseif MC>=10900 + //$$ return 10900; + //#else + return 10800; + //#endif + } } |