diff options
| author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-02 06:12:23 +0700 |
|---|---|---|
| committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-02 06:12:23 +0700 |
| commit | d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051 (patch) | |
| tree | 9bb9b53e2823f73084780673763504f4098bae69 /src/main | |
| parent | d2b1d57120bb51e76191302a58d935afe52b89df (diff) | |
| download | OneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.tar.gz OneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.tar.bz2 OneConfig-d4bb5a94308d4379ef3d6cc7b9221ea0d98ff051.zip | |
Separate Minecraft dependant and non-dependant code
Diffstat (limited to 'src/main')
70 files changed, 355 insertions, 1572 deletions
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 1948e0a..97dd0cb 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 @@ -8,11 +8,11 @@ import cc.polyfrost.oneconfig.config.elements.OptionPage; import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.config.Config; import cc.polyfrost.oneconfig.gui.elements.config.*; +import cc.polyfrost.oneconfig.platform.Platform; import gg.essential.vigilance.Vigilant; import gg.essential.vigilance.data.*; import kotlin.reflect.KMutableProperty0; import kotlin.reflect.jvm.ReflectJvmMapping; -import net.minecraft.client.resources.I18n; import java.awt.*; import java.lang.reflect.Field; @@ -131,7 +131,7 @@ public class VigilanceConfig extends Config { private String getName(PropertyAttributesExt ext) { try { PropertyAttributesExt.class.getDeclaredField("i18nName").setAccessible(true); - return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nName").get(ext)); + return Platform.getI18nPlatform().format((String) PropertyAttributesExt.class.getDeclaredField("i18nName").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { return ext.getName(); } @@ -140,7 +140,7 @@ public class VigilanceConfig extends Config { private String getCategory(PropertyAttributesExt ext) { try { PropertyAttributesExt.class.getDeclaredField("i18nCategory").setAccessible(true); - return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nCategory").get(ext)); + return Platform.getI18nPlatform().format((String) PropertyAttributesExt.class.getDeclaredField("i18nCategory").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { return ext.getCategory(); } @@ -149,7 +149,7 @@ public class VigilanceConfig extends Config { private String getSubcategory(PropertyAttributesExt ext) { try { PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").setAccessible(true); - return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").get(ext)); + return Platform.getI18nPlatform().format((String) PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { return ext.getSubcategory(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java index 0f5ce09..29a9daa 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java @@ -1,9 +1,10 @@ package cc.polyfrost.oneconfig.config.profiles; -import cc.polyfrost.oneconfig.internal.OneConfig; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -11,13 +12,14 @@ import java.util.ArrayList; import java.util.Arrays; public class Profiles { + private static final Logger LOGGER = LogManager.getLogger("OneConfig Profiles"); public static final File nonProfileSpecificDir = new File("OneConfig/config"); public static final File profileDir = new File("OneConfig/profiles"); public static ArrayList<String> profiles; public static String getCurrentProfile() { if (!profileDir.exists() && !profileDir.mkdir()) { - OneConfig.LOGGER.fatal("Could not create profiles folder"); + LOGGER.fatal("Could not create profiles folder"); return null; } if (profiles == null) { @@ -33,7 +35,7 @@ public class Profiles { public static void createProfile(String name) { File folder = new File(profileDir, name); if (!folder.exists() && !folder.mkdir()) { - OneConfig.LOGGER.fatal("Could not create profile folder"); + LOGGER.fatal("Could not create profile folder"); return; } profiles.add(name); @@ -58,7 +60,7 @@ public class Profiles { public static void loadProfile(String profile) { ConfigCore.saveAll(); OneConfigConfig.currentProfile = profile; - OneConfig.config.save(); + //OneConfig.config.save(); todo do we actually need this ConfigCore.reInitAll(); } @@ -70,14 +72,14 @@ public class Profiles { profiles.remove(name); profiles.add(newName); } catch (IOException e) { - OneConfig.LOGGER.error("Failed to rename profile"); + LOGGER.error("Failed to rename profile"); } } public static void deleteProfile(String name) { if (name.equals(getCurrentProfile())) { if (profiles.size() == 1) { - OneConfig.LOGGER.error("Cannot delete only profile!"); + LOGGER.error("Cannot delete only profile!"); return; } loadProfile(profiles.stream().filter(entry -> !entry.equals(name)).findFirst().get()); @@ -86,7 +88,7 @@ public class Profiles { FileUtils.deleteDirectory(getProfileDir(name)); profiles.remove(name); } catch (IOException e) { - OneConfig.LOGGER.error("Failed to delete profile"); + LOGGER.error("Failed to delete profile"); } } } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/ChatReceiveEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/ChatReceiveEvent.java index 616479e..299ce12 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/event/ChatReceiveEvent.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/ChatReceiveEvent.java @@ -1,8 +1,5 @@ package cc.polyfrost.oneconfig.events.event; - -import net.minecraft.util.IChatComponent; - /** * Called when a chat message is received. */ @@ -10,9 +7,13 @@ public class ChatReceiveEvent extends CancellableEvent { /** * The message that was received. */ - public final IChatComponent message; + public final Object message; - public ChatReceiveEvent(IChatComponent message) { + public ChatReceiveEvent(Object message) { this.message = message; } + + public String getFullyUnformattedMessage() { + return ""; + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/ReceivePacketEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/ReceivePacketEvent.java index 17bc16d..f35bd0c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/event/ReceivePacketEvent.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/ReceivePacketEvent.java @@ -1,11 +1,9 @@ package cc.polyfrost.oneconfig.events.event; -import net.minecraft.network.Packet; - public class ReceivePacketEvent extends CancellableEvent { - public final Packet<?> packet; + public final Object packet; - public ReceivePacketEvent(Packet<?> packet) { + public ReceivePacketEvent(Object packet) { this.packet = packet; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/ScreenOpenEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/ScreenOpenEvent.java index 4593638..daee38b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/event/ScreenOpenEvent.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/ScreenOpenEvent.java @@ -1,6 +1,5 @@ package cc.polyfrost.oneconfig.events.event; -import net.minecraft.client.gui.GuiScreen; import org.jetbrains.annotations.Nullable; /** @@ -9,9 +8,9 @@ import org.jetbrains.annotations.Nullable; */ public class ScreenOpenEvent extends CancellableEvent { @Nullable - public final GuiScreen screen; + public final Object screen; - public ScreenOpenEvent(@Nullable GuiScreen screen) { + public ScreenOpenEvent(@Nullable Object screen) { this.screen = screen; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/SendPacketEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/SendPacketEvent.java index 3cee784..791f8d6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/event/SendPacketEvent.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/SendPacketEvent.java @@ -1,11 +1,10 @@ package cc.polyfrost.oneconfig.events.event; -import net.minecraft.network.Packet; public class SendPacketEvent extends CancellableEvent { - public final Packet<?> packet; + public final Object packet; - public SendPacketEvent(Packet<?> packet) { + public SendPacketEvent(Object packet) { this.packet = packet; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/TimerUpdateEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/TimerUpdateEvent.java index a8b88dc..c5f863c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/events/event/TimerUpdateEvent.java +++ b/src/main/java/cc/polyfrost/oneconfig/events/event/TimerUpdateEvent.java @@ -1,23 +1,12 @@ package cc.polyfrost.oneconfig.events.event; -import net.minecraft.util.Timer; - -/** - * Called when the {@link Timer} is updated. - * Can be used as an alternative to getting instances of {@link Timer} - * via Mixin or Access Wideners / Transformers - */ public class TimerUpdateEvent { - /** - * Whether the deltaTicks / renderPartialTicks was updated - */ + public final boolean updatedDeltaTicks; - /** - * The {@link Timer} instance - */ - public final Timer timer; - public TimerUpdateEvent(Timer timer, boolean updatedDeltaTicks) { + public final Object timer; + + public TimerUpdateEvent(Object timer, boolean updatedDeltaTicks) { this.timer = timer; this.updatedDeltaTicks = updatedDeltaTicks; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java new file mode 100644 index 0000000..44b2b5c --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java @@ -0,0 +1,9 @@ +package cc.polyfrost.oneconfig.gui; + +/** + * Hack that allows GUIs to set whether the game should pause when the GUI is displayed without depending on + * Minecraft itself. + */ +public interface GuiPause { + boolean doesGuiPauseGame(); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java index b13170a..2c3e681 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java @@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import cc.polyfrost.oneconfig.hud.Hud; import cc.polyfrost.oneconfig.internal.hud.HudCore; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; @@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.ArrayList; -public class HudGui extends UScreen { +public class HudGui extends UScreen implements GuiPause { private Hud editingHud; private boolean isDragging; private boolean isScaling; @@ -29,7 +30,7 @@ public class HudGui extends UScreen { @Override public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - RenderManager.drawGlRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB()); + RenderManager.drawGlRect(0, 0, UResolution.getScaledWidth(), UResolution.getScaledHeight(), new Color(80, 80, 80, 50).getRGB()); if (isDragging) { |
