(feature) new pack badge

This commit is contained in:
kirillsaint 2024-05-10 12:15:32 +06:00
parent 829d192992
commit 7a0903cef8
4 changed files with 66 additions and 4 deletions

View File

@ -374,6 +374,17 @@ public class Client {
Client.logger.info("STARTING > config-manager-post-init");
configManager.postInit();
if(!globalSettings.isResourcePacksFetched()) {
Client.logger.info("STARTING > resource-packs-fetching");
if(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks() != null && Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks().listFiles() != null) {
for (File file : Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks().listFiles()) {
globalSettings.addToUsedResourcePacks(file.getName());
}
globalSettings.setResourcePacksFetched(true);
globalSettings.save();
}
}
if(!globalSettings.isDisplayedTutorial()) {
Minecraft.getMinecraft().displayGuiScreen(new UserTutorial());
}

View File

@ -26,6 +26,7 @@ import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@ -170,6 +171,12 @@ public class SilentResourcePacksGui extends SilentScreen {
{
this.mc.fontRendererObj.drawStringWithShadow(list.get(l), x + 5 + 31 + 3, itemY + 3 + 12 + 10 * l, 8421504);
}
if(!Client.getInstance().getGlobalSettings().getUsedResourcePacks().contains(entry.getResourcePackName())) {
RenderUtil.drawRoundedRect(x + 187 - 23, itemY + 35 - 12, 23, 10, 8, new Color(255, 255, 255).getRGB());
ColorUtils.setColor(new Color(0, 0, 0).getRGB());
Client.getInstance().getSilentFontRenderer().drawCenteredString("NEW", (int) x + 187 - 23 + (23 / 2), (int) (itemY + 35 - 12 + 10 - 9), 8, SilentFontRenderer.FontType.HEADER);
ColorUtils.resetColor();
}
}
itemY += 37;
}
@ -256,6 +263,12 @@ public class SilentResourcePacksGui extends SilentScreen {
{
this.mc.fontRendererObj.drawStringWithShadow(list.get(l), x + 5 + 31 + 3, itemY + 3 + 12 + 10 * l, 8421504);
}
if(!Client.getInstance().getGlobalSettings().getUsedResourcePacks().contains(entry.getResourcePackName())) {
RenderUtil.drawRoundedRect(x + 187 - 23, itemY + 35 - 12, 23, 10, 8, new Color(255, 255, 255).getRGB());
ColorUtils.setColor(new Color(0, 0, 0).getRGB());
Client.getInstance().getSilentFontRenderer().drawCenteredString("NEW", (int) x + 187 - 23 + (23 / 2), (int) (itemY + 35 - 12 + 10 - 9), 8, SilentFontRenderer.FontType.HEADER);
ColorUtils.resetColor();
}
}
itemY += 37;
packIndex++;
@ -329,7 +342,7 @@ public class SilentResourcePacksGui extends SilentScreen {
for (ResourcePackRepository.Entry resourcepackrepository$entry : list)
{
this.mc.gameSettings.resourcePacks.add(resourcepackrepository$entry.getResourcePackName());
Client.getInstance().getGlobalSettings().addToUsedResourcePacks(resourcepackrepository$entry.getResourcePackName());
if (resourcepackrepository$entry.func_183027_f() != 1)
{
this.mc.gameSettings.incompatibleResourcePacks.add(resourcepackrepository$entry.getResourcePackName());
@ -341,6 +354,7 @@ public class SilentResourcePacksGui extends SilentScreen {
this.initGui();
this.scrollHelper2.resetScroll();
this.scrollHelper.resetScroll();
Client.getInstance().getGlobalSettings().save();
}
}
@ -428,7 +442,19 @@ public class SilentResourcePacksGui extends SilentScreen {
this.selectedResourcePacks.clear();
}
ResourcePackRepository.Entry randomPack = this.availableResourcePacks.get(random.nextInt(this.availableResourcePacks.size()));
ArrayList<ResourcePackRepository.Entry> newPacks = new ArrayList<>();
for(ResourcePackRepository.Entry entry : this.availableResourcePacks) {
if(!Client.getInstance().getGlobalSettings().getUsedResourcePacks().contains(entry.getResourcePackName())) {
newPacks.add(entry);
}
}
ResourcePackRepository.Entry randomPack;
if(!newPacks.isEmpty()) {
randomPack = newPacks.get(random.nextInt(newPacks.size()));
} else {
randomPack = this.availableResourcePacks.get(random.nextInt(this.availableResourcePacks.size()));
}
if(randomPack != null) {
this.selectedResourcePacks.add(0, randomPack);

View File

@ -67,8 +67,8 @@ public class RawInputHandler {
if (Thread.currentThread().isInterrupted()) {
break;
}
reload();
rescan();
// reload();
// rescan();
if (mouse != null && Minecraft.getMinecraft().currentScreen == null) {
mouse.poll();
dx += (int)mouse.getX().getPollData();

View File

@ -15,6 +15,8 @@ public class GlobalSettings {
public boolean packsPanoramaEnabled;
public ArrayList<FeaturedServers.FeaturedServerInfo> savedFeaturedServers;
public ArrayList<GlobalSettings.CustomColor> latestColors;
public boolean resourcePacksFetched;
public ArrayList<String> usedResourcePacks;
public GlobalSettings() {
@ -24,6 +26,8 @@ public class GlobalSettings {
this.packsPanoramaEnabled = true;
this.savedFeaturedServers = new ArrayList<>();
this.latestColors = new ArrayList<>();
this.resourcePacksFetched = false;
this.usedResourcePacks = new ArrayList<>();
}
public String getConfig() {
@ -107,6 +111,27 @@ public class GlobalSettings {
latestColors.add(0, new CustomColor(color));
}
public boolean isResourcePacksFetched() {
return resourcePacksFetched;
}
public void setResourcePacksFetched(boolean resourcePacksFetched) {
this.resourcePacksFetched = resourcePacksFetched;
}
public ArrayList<String> getUsedResourcePacks() {
if(usedResourcePacks == null) {
this.usedResourcePacks = new ArrayList<>();
}
return usedResourcePacks;
}
public void addToUsedResourcePacks(String pack) {
if(!this.usedResourcePacks.contains(pack)) {
this.usedResourcePacks.add(pack);
}
}
public void save() {
try {
FileOutputStream outputStream = new FileOutputStream(Client.getInstance().getGlobalSettingsFile());