Skip to content
This repository has been archived by the owner on Dec 4, 2022. It is now read-only.

Commit

Permalink
Fixed notification delay and renamed to rpd see: #2 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
1fxe committed Mar 5, 2021
1 parent e38442b commit 91e01c4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

# Resource Pack Display Revamp
# Resource Pack Display

A revamp of [Canelex's Pack Display Mod](https://www.youtube.com/watch?v=LeDNOdOdGyk) with some extra features

Expand Down Expand Up @@ -38,7 +38,7 @@ If you do not know how to install a Forge mod, then we recommended looking up "H
#### Commands

```
/rdp - Opens the Modcore config
/rpd - Opens the Modcore config
gui - Opens a GUI so you can drag the display to your preferred location
random - Chooses a random resource pack from your game and sets it
reset - Resets the random resource pack duplicates list
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ buildscript {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.0"
group= "dev.fxe"
archivesBaseName = "Resource Pack Display"
version = project.version
group= project.modGroup
archivesBaseName = project.archivesBaseName
sourceCompatibility = targetCompatibility = 1.8

minecraft {
version = "1.8.9-11.15.1.2318-1.8.9"
version = project.forgeVersion
runDir = "run"
mappings = "stable_22"
mappings = project.mcpVersion
makeObfSourceJar = false
}

Expand Down
12 changes: 12 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
modGroup=dev.fxe
modVersion=1.0-Beta
modBaseName=ResourcePackDisplay
forgeVersion=1.8.9-11.15.1.2318-1.8.9
mcpVersion=stable_22
tweakClass=dev.fxe.mods.resourcepackdisplay.tweaker.TweakClass

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
org.gradle.jvmargs=-Xmx4G
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Config getConfig() {
}

public void sendMessage(String message) {
MinecraftUtils.sendMessage(ChatColor.BLUE + "[RDP] ",
MinecraftUtils.sendMessage(ChatColor.BLUE + "[RPD] ",
ChatColor.translateAlternateColorCodes('&', message));
}

Expand Down Expand Up @@ -106,25 +106,28 @@ public void selectRandomPack() {
ListenableFuture<Object> future = mc.scheduleResourcesRefresh();
Multithreading.runAsync(() -> {
while (!future.isDone()) ;
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {}
long end = System.currentTimeMillis();
Notifications.INSTANCE.pushNotification(MOD_NAME,
"Minecraft took " + (end - start) / 1000 + "s to load " + packName
"Minecraft took " + ((end-1000) - start) / 1000 + "s to load " + packName
);
});
}
}

private void sendRandomPrompt() {
ChatComponentText text = new ChatComponentText(ChatColor.BLUE + "[RDP] " +
ChatComponentText text = new ChatComponentText(ChatColor.BLUE + "[RPD] " +
ChatColor.RESET + "Select a new pack?");
ChatComponentText childComponent = new ChatComponentText(ChatColor.BLACK + " [" + ChatColor.GREEN +
"Random" + ChatColor.BLACK + "] " + ChatColor.RESET);
ChatComponentText childTwo = new ChatComponentText(ChatColor.BLACK + " [" + ChatColor.GREEN +
"Reset" + ChatColor.BLACK + "] " + ChatColor.RESET);
ChatStyle chatStyle = new ChatStyle();
ChatStyle chatStyleTwo = new ChatStyle();
final String cmd = "/rdp random";
final String cmd2 = "/rdp reset";
final String cmd = "/rpd random";
final String cmd2 = "/rpd reset";
chatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd));
chatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(cmd)));
chatStyleTwo.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, cmd2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Command extends CommandBase {

@Override
public String getCommandName() {
return "rdp";
return "rpd";
}

@Override
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/dev/fxe/mods/resourcepackdisplay/ui/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@
public class UI {
private static final int imageWidth = 32;
private static final int textPadding = 5;

public static UI instance;
private final Minecraft mc = Minecraft.getMinecraft();
private final ResourcePackRepository resourcePackRepository = mc.getResourcePackRepository();
private final FontRenderer fontRenderer = mc.fontRendererObj;
private final HashMap<String, String> packSize = new HashMap<>();
// private static final HashMap<String, ResourceLocation> packTexture = new HashMap<>();
private final ShaderManager shaderManager = new ShaderManager(Shaders.vert, Shaders.frag);
private final List<ResourcePackRepository.Entry> packs = resourcePackRepository.getRepositoryEntries();
private ResourceLocation currentPack;

public UI() {
Expand All @@ -80,7 +79,6 @@ public static void drawPackDisplay() {
int yOffset = 2;
if (Config.displayPackName) {
height += 9;

UI.instance.fontRenderer.drawString(currentPack.getPackName(),
offset + textPadding, y + padding + yOffset,
0xffffff);
Expand All @@ -95,10 +93,8 @@ public static void drawPackDisplay() {
}
if (Config.displayPackSize) {
height += 9;
String size = UI.instance.getPackSize(currentPack);
if (!size.equalsIgnoreCase(""))
UI.instance.fontRenderer.drawString("Size: " + size, offset + textPadding, y + yOffset + padding,
0xffffff);
UI.instance.fontRenderer.drawString("Size: " + UI.instance.getPackSize(currentPack), offset + textPadding, y + yOffset + padding,
0xffffff);
}

if (Config.displayPackIcon) {
Expand Down Expand Up @@ -158,8 +154,6 @@ private void loadTexture() {
}

private IResourcePack getCurrentPack() {
List<ResourcePackRepository.Entry> packs =
resourcePackRepository.getRepositoryEntries();
return packs.size() > 0 ? packs.get(0).getResourcePack() :
mc.mcDefaultResourcePack;
}
Expand Down

0 comments on commit 91e01c4

Please sign in to comment.