(feature) random resource pack button

This commit is contained in:
kirillsaint 2024-01-24 17:09:08 +06:00
parent 140a9f8568
commit ef860979a3
2 changed files with 24 additions and 0 deletions

View File

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB