From 393f3c8f9279f5d8f5e33933ce6ef985d65a92f0 Mon Sep 17 00:00:00 2001 From: ThatGravyBoat Date: Fri, 18 Feb 2022 04:58:10 -0330 Subject: Move commands to separate classes (#82) --- .../commands/dev/PackDevCommand.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java (limited to 'src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java new file mode 100644 index 00000000..e73fc6b1 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java @@ -0,0 +1,52 @@ +package io.github.moulberry.notenoughupdates.commands.dev; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; +import io.github.moulberry.notenoughupdates.core.util.MiscUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +public class PackDevCommand extends ClientCommandBase { + + public PackDevCommand() { + super("neupackdev"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { + double distSq = 25; + EntityPlayer closestNPC = null; + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if (player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { + double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); + if (dSq < distSq) { + distSq = dSq; + closestNPC = player; + } + } + } + + if (closestNPC == null) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No NPCs found within 5 blocks :(")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Copied entity texture id to clipboard")); + MiscUtils.copyToClipboard(((AbstractClientPlayer) closestNPC).getLocationSkin().getResourcePath().replace("skins/", "")); + } + return; + } + NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; + if (NotEnoughUpdates.INSTANCE.packDevEnabled) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Enabled pack developer mode.")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Disabled pack developer mode.")); + } + } +} -- cgit From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../commands/dev/PackDevCommand.java | 73 ++++++++++++---------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java index e73fc6b1..e809ed72 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java @@ -14,39 +14,46 @@ import net.minecraft.util.EnumChatFormatting; public class PackDevCommand extends ClientCommandBase { - public PackDevCommand() { - super("neupackdev"); - } + public PackDevCommand() { + super("neupackdev"); + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { - double distSq = 25; - EntityPlayer closestNPC = null; - EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; - for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - if (player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { - double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); - if (dSq < distSq) { - distSq = dSq; - closestNPC = player; - } - } - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { + double distSq = 25; + EntityPlayer closestNPC = null; + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if (player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { + double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); + if (dSq < distSq) { + distSq = dSq; + closestNPC = player; + } + } + } - if (closestNPC == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No NPCs found within 5 blocks :(")); - } else { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Copied entity texture id to clipboard")); - MiscUtils.copyToClipboard(((AbstractClientPlayer) closestNPC).getLocationSkin().getResourcePath().replace("skins/", "")); - } - return; - } - NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; - if (NotEnoughUpdates.INSTANCE.packDevEnabled) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Enabled pack developer mode.")); - } else { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Disabled pack developer mode.")); - } - } + if (closestNPC == null) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "No NPCs found within 5 blocks :(")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.GREEN + "Copied entity texture id to clipboard")); + MiscUtils.copyToClipboard(((AbstractClientPlayer) closestNPC) + .getLocationSkin() + .getResourcePath() + .replace("skins/", "")); + } + return; + } + NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; + if (NotEnoughUpdates.INSTANCE.packDevEnabled) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.GREEN + "Enabled pack developer mode.")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "Disabled pack developer mode.")); + } + } } -- cgit