diff options
author | makamys <makamys@outlook.com> | 2023-04-16 03:27:14 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2023-04-16 03:34:27 +0200 |
commit | 9c8c5a611ff6ba367e44c9bf0d9e2840ba88ddd4 (patch) | |
tree | 98d70d132a8b8b94b63f7c3decbde62bbaf39722 /src/main/java/makamys/neodymium | |
parent | e3ad4353c545837f77f8192b724127e735b53554 (diff) | |
download | Neodymium-9c8c5a611ff6ba367e44c9bf0d9e2840ba88ddd4.tar.gz Neodymium-9c8c5a611ff6ba367e44c9bf0d9e2840ba88ddd4.tar.bz2 Neodymium-9c8c5a611ff6ba367e44c9bf0d9e2840ba88ddd4.zip |
Add some extra polish to the advanced opengl warning
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r-- | src/main/java/makamys/neodymium/command/ISubCommand.java | 1 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/command/NeodymiumCommand.java | 26 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/makamys/neodymium/command/ISubCommand.java b/src/main/java/makamys/neodymium/command/ISubCommand.java index 91eccff..837f67a 100644 --- a/src/main/java/makamys/neodymium/command/ISubCommand.java +++ b/src/main/java/makamys/neodymium/command/ISubCommand.java @@ -5,5 +5,6 @@ import net.minecraft.command.ICommandSender; public interface ISubCommand { void processCommand(ICommandSender sender, String[] args); + default boolean isSecret() { return false; } } diff --git a/src/main/java/makamys/neodymium/command/NeodymiumCommand.java b/src/main/java/makamys/neodymium/command/NeodymiumCommand.java index 122e934..3040ba9 100644 --- a/src/main/java/makamys/neodymium/command/NeodymiumCommand.java +++ b/src/main/java/makamys/neodymium/command/NeodymiumCommand.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.function.Consumer; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.input.Mouse; import makamys.neodymium.Compat; import makamys.neodymium.Compat.Warning; @@ -68,7 +69,14 @@ public class NeodymiumCommand extends CommandBase { return; } } - throw new WrongUsageException(getCommandName() + " <" + String.join("|", subCommands.keySet()) + ">", new Object[0]); + throw new WrongUsageException(getCommandName() + " <" + String.join("|", getNonSecretSubCommands()) + ">", new Object[0]); + } + + private String[] getNonSecretSubCommands() { + return subCommands.entrySet() + .stream() + .filter(e -> !e.getValue().isSecret()) + .map(e -> e.getKey()).toArray(String[]::new); } public static void addChatMessage(ICommandSender sender, String text) { @@ -88,8 +96,9 @@ public class NeodymiumCommand extends CommandBase { sender.addChatMessage(msg); } + @SuppressWarnings("unchecked") public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, subCommands.keySet().toArray(new String[0])) : null; + return args.length == 1 ? getListOfStringsMatchingLastWord(args, getNonSecretSubCommands()) : null; } public static class StatusCommand implements ISubCommand { @@ -130,13 +139,22 @@ public class NeodymiumCommand extends CommandBase { @Override public void processCommand(ICommandSender sender, String[] args) { + Minecraft mc = Minecraft.getMinecraft(); if(Compat.disableAdvancedOpenGL()) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); ChatUtil.showNeoChatMessage(EnumChatFormatting.AQUA + "Disabled Advanced OpenGL.", MessageVerbosity.INFO); - Minecraft.getMinecraft().renderGlobal.loadRenderers(); + mc.renderGlobal.loadRenderers(); + } else { + float x = Mouse.getX() / (float)Minecraft.getMinecraft().displayWidth; + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("note.bass"), 0.7F + x * 0.2F)); } } + @Override + public boolean isSecret() { + return true; + } + } } |