diff --git a/src/main/java/net/silentclient/client/gui/resourcepacks/SilentResourcePacksGui.java b/src/main/java/net/silentclient/client/gui/resourcepacks/SilentResourcePacksGui.java index 608f139..ae61f6f 100644 --- a/src/main/java/net/silentclient/client/gui/resourcepacks/SilentResourcePacksGui.java +++ b/src/main/java/net/silentclient/client/gui/resourcepacks/SilentResourcePacksGui.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.net.URI; import java.util.Collections; import java.util.List; +import java.util.Random; public class SilentResourcePacksGui extends SilentScreen { private final GuiScreen parentScreen; @@ -40,6 +41,7 @@ public class SilentResourcePacksGui extends SilentScreen { private int blockHeight = 0; private ScrollHelper scrollHelper = new ScrollHelper(); private ScrollHelper scrollHelper2 = new ScrollHelper(); + private Random random = new Random(); public SilentResourcePacksGui(GuiScreen parentScreenIn) { @@ -61,6 +63,7 @@ public class SilentResourcePacksGui extends SilentScreen { if(mc.thePlayer != null) { this.buttonList.add(new TooltipIconButton(2, blockX + blockWidth - 14 - 5, blockY + blockHeight - 5 - 14, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/lightoverlay.png"), "Toggle Background Panorama")); } + this.buttonList.add(new TooltipIconButton(6, blockX + 5, blockY + blockHeight - 5 - 14, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/dice.png"), "Random Resource Pack")); this.buttonList.add(new Button(3, blockX + 40, blockY + blockHeight - 5 - 14, 100, 14, "Open Pack Folder")); this.buttonList.add(new Button(4, blockX + 40 + 100 + 5, blockY + blockHeight - 5 - 14, 100, 14, "Apply")); this.buttonList.add(new Button(5, blockX + 40 + 100 + 5 + 100 + 5, blockY + blockHeight - 5 - 14, 100, 14, "Done")); @@ -410,9 +413,30 @@ public class SilentResourcePacksGui extends SilentScreen { this.apply(); mc.displayGuiScreen(parentScreen); break; + case 6: + this.randomPack(); + break; } } + private void randomPack() { + if(!this.selectedResourcePacks.isEmpty()) { + for(ResourcePackRepository.Entry entry : this.selectedResourcePacks) { + this.availableResourcePacks.add(0, entry); + } + this.selectedResourcePacks.clear(); + } + + ResourcePackRepository.Entry randomPack = this.availableResourcePacks.get(random.nextInt(this.availableResourcePacks.size())); + + if(randomPack != null) { + this.selectedResourcePacks.add(0, randomPack); + this.availableResourcePacks.remove(randomPack); + } + + this.markChanged(); + } + @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); diff --git a/src/main/resources/assets/minecraft/silentclient/icons/dice.png b/src/main/resources/assets/minecraft/silentclient/icons/dice.png new file mode 100644 index 0000000..f2e18c9 Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/dice.png differ