Commit a4fe8a2ddd1fd7a8328729b91ebf72ae46b13498
1 parent
a954e687
LiteLoader 1.6.2_02 - fix for sound issue
Showing
4 changed files
with
159 additions
and
12 deletions
java/com/mumfrey/liteloader/core/LiteLoader.java
... | ... | @@ -294,6 +294,12 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
294 | 294 | */ |
295 | 295 | private static PermissionsManagerClient permissionsManager = PermissionsManagerClient.getInstance(); |
296 | 296 | |
297 | + private boolean pendingResourceReload; | |
298 | + | |
299 | + private boolean inhibitSoundManagerReload = true; | |
300 | + | |
301 | + private SoundManagerReloadInhibitor soundManagerReloadInhibitor; | |
302 | + | |
297 | 303 | public static final void init(File gameDirectory, File assetsDirectory, String profile, List<String> modNameFilter) |
298 | 304 | { |
299 | 305 | if (instance == null) |
... | ... | @@ -419,7 +425,7 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
419 | 425 | return this.modsFolder; |
420 | 426 | } |
421 | 427 | |
422 | - return new File(this.configBaseFolder, String.format("config.%s", version.getLoaderVersion())); | |
428 | + return new File(this.configBaseFolder, String.format("config.%s", version.getMinecraftVersion())); | |
423 | 429 | } |
424 | 430 | |
425 | 431 | /** |
... | ... | @@ -433,7 +439,7 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
433 | 439 | // Set up loader, initialises any reflection methods needed |
434 | 440 | if (this.prepareLoader()) |
435 | 441 | { |
436 | - logger.info(String.format("LiteLoader %s starting up...", VERSION)); | |
442 | + logger.info(String.format("LiteLoader %s starting up...", VERSION.getLoaderVersion())); | |
437 | 443 | |
438 | 444 | // Print the branding version if any was provided |
439 | 445 | if (this.branding != null) |
... | ... | @@ -495,6 +501,9 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
495 | 501 | this.paginateControls = this.localProperties.getProperty("controls.pages", "true").equalsIgnoreCase("true"); |
496 | 502 | this.localProperties.setProperty("controls.pages", String.valueOf(this.paginateControls)); |
497 | 503 | |
504 | + this.inhibitSoundManagerReload = this.localProperties.getProperty("soundManagerFix", "true").equalsIgnoreCase("true"); | |
505 | + this.localProperties.setProperty("soundManagerFix", String.valueOf(this.inhibitSoundManagerReload)); | |
506 | + | |
498 | 507 | this.branding = this.internalProperties.getProperty("brand", null); |
499 | 508 | if (this.branding != null && this.branding.length() < 1) |
500 | 509 | this.branding = null; |
... | ... | @@ -616,6 +625,8 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
616 | 625 | { |
617 | 626 | if (!this.registeredResourcePacks.containsKey(resourcePack.func_130077_b())) // TODO adamsrc -> getName() |
618 | 627 | { |
628 | + this.pendingResourceReload = true; | |
629 | + | |
619 | 630 | List<ResourcePack> defaultResourcePacks = PrivateFields.defaultResourcePacks.get(this.minecraft); |
620 | 631 | if (!defaultResourcePacks.contains(resourcePack)) |
621 | 632 | { |
... | ... | @@ -636,6 +647,8 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
636 | 647 | { |
637 | 648 | if (this.registeredResourcePacks.containsValue(resourcePack)) |
638 | 649 | { |
650 | + this.pendingResourceReload = true; | |
651 | + | |
639 | 652 | List<ResourcePack> defaultResourcePacks = PrivateFields.defaultResourcePacks.get(this.minecraft); |
640 | 653 | this.registeredResourcePacks.remove(resourcePack.func_130077_b()); // TODO adamsrc -> getName() |
641 | 654 | defaultResourcePacks.remove(resourcePack); |
... | ... | @@ -1178,7 +1191,9 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1178 | 1191 | |
1179 | 1192 | logger.info("Discovered " + this.modsToLoad.size() + " total mod(s)"); |
1180 | 1193 | |
1181 | - boolean addedResources = false; | |
1194 | + this.pendingResourceReload = false; | |
1195 | + this.soundManagerReloadInhibitor = new SoundManagerReloadInhibitor((SimpleReloadableResourceManager)minecraft.getResourceManager(), minecraft.sndManager); | |
1196 | + if (this.inhibitSoundManagerReload) this.soundManagerReloadInhibitor.inhibit(); | |
1182 | 1197 | |
1183 | 1198 | for (Class<? extends LiteMod> mod : this.modsToLoad.values()) |
1184 | 1199 | { |
... | ... | @@ -1198,7 +1213,6 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1198 | 1213 | if (modFile != null && modFile.registerAsResourcePack(newMod.getName())) |
1199 | 1214 | { |
1200 | 1215 | logger.info("Adding " + modFile.getAbsolutePath() + " to resources list"); |
1201 | - addedResources = true; | |
1202 | 1216 | } |
1203 | 1217 | } |
1204 | 1218 | else |
... | ... | @@ -1212,11 +1226,6 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1212 | 1226 | th.printStackTrace(); |
1213 | 1227 | } |
1214 | 1228 | } |
1215 | - | |
1216 | - if (addedResources) | |
1217 | - { | |
1218 | - this.minecraft.func_110436_a(); // TODO adamsrc -> refreshResourcePacks | |
1219 | - } | |
1220 | 1229 | } |
1221 | 1230 | |
1222 | 1231 | /** |
... | ... | @@ -1264,7 +1273,7 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1264 | 1273 | if (LiteLoader.VERSION.getLoaderRevision() > lastModVersion.getLoaderRevision()) |
1265 | 1274 | { |
1266 | 1275 | logger.info("Performing config upgrade for mod " + modName + ". Upgrading " + lastModVersion + " to " + LiteLoader.VERSION + "..."); |
1267 | - mod.upgradeSettings(LiteLoader.getVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); | |
1276 | + mod.upgradeSettings(VERSION.getMinecraftVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); | |
1268 | 1277 | |
1269 | 1278 | this.storeLastKnownModRevision(modKey); |
1270 | 1279 | logger.info("Config upgrade succeeded for mod " + modName); |
... | ... | @@ -1724,6 +1733,12 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1724 | 1733 | */ |
1725 | 1734 | public void onInit() |
1726 | 1735 | { |
1736 | + if (this.pendingResourceReload) | |
1737 | + { | |
1738 | + this.pendingResourceReload = false; | |
1739 | + this.minecraft.func_110436_a(); // TODO adamsrc -> refreshResourcePacks | |
1740 | + } | |
1741 | + | |
1727 | 1742 | if (!this.lateInitDone) |
1728 | 1743 | { |
1729 | 1744 | this.lateInitDone = true; |
... | ... | @@ -1741,6 +1756,11 @@ public final class LiteLoader implements FilenameFilter, IPlayerUsage |
1741 | 1756 | } |
1742 | 1757 | } |
1743 | 1758 | } |
1759 | + | |
1760 | + if (this.soundManagerReloadInhibitor != null && this.soundManagerReloadInhibitor.isInhibited()) | |
1761 | + { | |
1762 | + this.soundManagerReloadInhibitor.unInhibit(true); | |
1763 | + } | |
1744 | 1764 | } |
1745 | 1765 | |
1746 | 1766 | /** | ... | ... |
java/com/mumfrey/liteloader/core/LiteLoaderVersion.java
... | ... | @@ -7,7 +7,7 @@ import java.util.Set; |
7 | 7 | * LiteLoader version table |
8 | 8 | * |
9 | 9 | * @author Adam Mummery-Smith |
10 | - * @version 1.6.2_01 | |
10 | + * @version 1.6.2_02 | |
11 | 11 | */ |
12 | 12 | public enum LiteLoaderVersion |
13 | 13 | { |
... | ... | @@ -16,7 +16,7 @@ public enum LiteLoaderVersion |
16 | 16 | MC_1_5_2_R2(10, "1.5.2", "1.5.2", "1.5.2"), |
17 | 17 | MC_1_6_1_R0(11, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"), |
18 | 18 | MC_1_6_2_R0(12, "1.6.2", "1.6.2", "1.6.2", "1.6.r2"), |
19 | - MC_1_6_2_R1(13, "1.6.2", "1.6.2", "1.6.2", "1.6.r2"); | |
19 | + MC_1_6_2_R1(13, "1.6.2", "1.6.2_02", "1.6.2", "1.6.r2"); | |
20 | 20 | |
21 | 21 | private int revision; |
22 | 22 | ... | ... |
java/com/mumfrey/liteloader/core/SoundManagerReloadInhibitor.java
0 โ 100644
1 | +package com.mumfrey.liteloader.core; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import com.mumfrey.liteloader.util.PrivateFields; | |
6 | + | |
7 | +import net.minecraft.src.ResourceManagerReloadListener; | |
8 | +import net.minecraft.src.SimpleReloadableResourceManager; | |
9 | +import net.minecraft.src.SoundManager; | |
10 | + | |
11 | +/** | |
12 | + * Manager object which handles inhibiting the sound manager's reload notification at startup | |
13 | + * | |
14 | + * @author Adam Mummery-Smith | |
15 | + */ | |
16 | +public class SoundManagerReloadInhibitor | |
17 | +{ | |
18 | + /** | |
19 | + * Resource Manager | |
20 | + */ | |
21 | + private SimpleReloadableResourceManager resourceManager; | |
22 | + | |
23 | + /** | |
24 | + * Sound manager | |
25 | + */ | |
26 | + private SoundManager soundManager; | |
27 | + | |
28 | + /** | |
29 | + * True if inhibition is currently active | |
30 | + */ | |
31 | + private boolean inhibited; | |
32 | + | |
33 | + /** | |
34 | + * So that we can re-insert the sound manager at the same index, we store the index we remove it from | |
35 | + */ | |
36 | + private int storedIndex; | |
37 | + | |
38 | + public SoundManagerReloadInhibitor(SimpleReloadableResourceManager resourceManager, SoundManager soundManager) | |
39 | + { | |
40 | + this.resourceManager = resourceManager; | |
41 | + this.soundManager = soundManager; | |
42 | + } | |
43 | + | |
44 | + /** | |
45 | + * Inhibit the sound manager reload notification | |
46 | + * | |
47 | + * @return true if inhibit was applied | |
48 | + */ | |
49 | + public boolean inhibit() | |
50 | + { | |
51 | + try | |
52 | + { | |
53 | + if (!this.inhibited) | |
54 | + { | |
55 | + List<ResourceManagerReloadListener> reloadListeners = PrivateFields.reloadListeners.get(this.resourceManager); | |
56 | + if (reloadListeners != null) | |
57 | + { | |
58 | + this.storedIndex = reloadListeners.indexOf(this.soundManager); | |
59 | + if (this.storedIndex > -1) | |
60 | + { | |
61 | + LiteLoader.getLogger().info("Inhibiting sound manager reload"); | |
62 | + reloadListeners.remove(this.soundManager); | |
63 | + this.inhibited = true; | |
64 | + return true; | |
65 | + } | |
66 | + } | |
67 | + } | |
68 | + } | |
69 | + catch (Exception ex) | |
70 | + { | |
71 | + LiteLoader.getLogger().warning("Error inhibiting sound manager reload"); | |
72 | + } | |
73 | + | |
74 | + return false; | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * Remove the sound manager reload inhibit | |
79 | + * | |
80 | + * @param reload True to reload the sound manager now | |
81 | + * @return true if the sound manager was successfully restored | |
82 | + */ | |
83 | + public boolean unInhibit(boolean reload) | |
84 | + { | |
85 | + try | |
86 | + { | |
87 | + if (this.inhibited) | |
88 | + { | |
89 | + List<ResourceManagerReloadListener> reloadListeners = PrivateFields.reloadListeners.get(this.resourceManager); | |
90 | + if (reloadListeners != null) | |
91 | + { | |
92 | + if (this.storedIndex > -1) | |
93 | + { | |
94 | + reloadListeners.add(this.storedIndex, this.soundManager); | |
95 | + } | |
96 | + else | |
97 | + { | |
98 | + reloadListeners.add(this.soundManager); | |
99 | + } | |
100 | + | |
101 | + LiteLoader.getLogger().info("Sound manager reload inhibit removed"); | |
102 | + | |
103 | + if (reload) | |
104 | + { | |
105 | + LiteLoader.getLogger().info("Reloading sound manager"); | |
106 | + this.soundManager.onReload(this.resourceManager); | |
107 | + } | |
108 | + | |
109 | + this.inhibited = false; | |
110 | + return true; | |
111 | + } | |
112 | + } | |
113 | + } | |
114 | + catch (Exception ex) | |
115 | + { | |
116 | + LiteLoader.getLogger().warning("Error removing sound manager reload inhibit"); | |
117 | + } | |
118 | + | |
119 | + return false; | |
120 | + } | |
121 | + | |
122 | + public boolean isInhibited() | |
123 | + { | |
124 | + return this.inhibited; | |
125 | + } | |
126 | +} | ... | ... |
java/com/mumfrey/liteloader/util/PrivateFields.java
... | ... | @@ -147,5 +147,6 @@ public class PrivateFields<P, T> |
147 | 147 | public static final PrivateFields<RenderManager, Map> entityRenderMap = new PrivateFields<RenderManager, Map> (RenderManager.class, "entityRenderMap", "q", "field_78729_o"); // RenderManager/entityRenderMap |
148 | 148 | public static final PrivateFields<GuiControls, GuiScreen> guiControlsParentScreen = new PrivateFields<GuiControls, GuiScreen> (GuiControls.class, "parentScreen", "b", "field_73909_b"); // GuiControls/parentScreen |
149 | 149 | public static final PrivateFields<PlayerUsageSnooper, IPlayerUsage> playerStatsCollector = new PrivateFields<PlayerUsageSnooper, IPlayerUsage>(PlayerUsageSnooper.class, "playerStatsCollector", "d", "field_76478_d"); // PlayerUsageSnooper/playerStatsCollector |
150 | + public static final PrivateFields<SimpleReloadableResourceManager, List<ResourceManagerReloadListener>> reloadListeners = new PrivateFields<SimpleReloadableResourceManager, List<ResourceManagerReloadListener>>(SimpleReloadableResourceManager.class, "field_110546_b", "c", "field_110546_b"); // SimpleReloadableResourceManager/field_110546_b | |
150 | 151 | } |
151 | 152 | ... | ... |