Skip to content

Commit 5b6518e

Browse files
committed
Tweak IconUtil
Signed-off-by: Hendrix-Shen <[email protected]>
1 parent cc61506 commit 5b6518e

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

src/main/java/top/hendrixshen/tweakmyclient/util/IconUtil.java

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ private static void setIcon(ArrayList<InputStream> inputStreams) throws IOExcept
7272
//$$ RenderSystem.assertThread(RenderSystem::isInInitPhase);
7373
//#endif
7474

75-
if (Minecraft.ON_OSX) {
76-
// TODO: MAC_OS support, Low Priority because I'm lazy,meow~
77-
return;
78-
}
79-
8075
ArrayList<ByteBuffer> byteBuffers = new ArrayList<>(inputStreams.size());
8176

8277
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
@@ -128,26 +123,18 @@ public static void updateIcon() {
128123

129124
try {
130125
if (Configs.featureCustomWindowIcon) {
131-
//#if MC > 11802
132-
inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_16X : IconUtil.TMC_SNAPSHOT_16X).orElseThrow(RuntimeException::new).open());
133-
inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_32X : IconUtil.TMC_SNAPSHOT_32X).orElseThrow(RuntimeException::new).open());
134-
inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_48X : IconUtil.TMC_SNAPSHOT_48X).orElseThrow(RuntimeException::new).open());
135-
inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_128X : IconUtil.TMC_SNAPSHOT_128X).orElseThrow(RuntimeException::new).open());
136-
inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_256X : IconUtil.TMC_SNAPSHOT_256X).orElseThrow(RuntimeException::new).open());
137-
//#else
138-
//$$ inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_16X : IconUtil.TMC_SNAPSHOT_16X).getInputStream());
139-
//$$ inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_32X : IconUtil.TMC_SNAPSHOT_32X).getInputStream());
140-
//$$ inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_48X : IconUtil.TMC_SNAPSHOT_48X).getInputStream());
141-
//$$ inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_128X : IconUtil.TMC_SNAPSHOT_128X).getInputStream());
142-
//$$ inputStreams.add(mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.TMC_STABLE_256X : IconUtil.TMC_SNAPSHOT_256X).getInputStream());
143-
//#endif
126+
IconUtil.pushResource(inputStreams, TMC_STABLE_16X, TMC_SNAPSHOT_16X);
127+
IconUtil.pushResource(inputStreams, TMC_STABLE_32X, TMC_SNAPSHOT_32X);
128+
IconUtil.pushResource(inputStreams, TMC_STABLE_48X, TMC_SNAPSHOT_48X);
129+
IconUtil.pushResource(inputStreams, TMC_STABLE_128X, TMC_SNAPSHOT_128X);
130+
IconUtil.pushResource(inputStreams, TMC_STABLE_256X, TMC_SNAPSHOT_256X);
144131
} else {
145132
//#if MC > 11904
146-
inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.VANILLA_STABLE_16X : IconUtil.VANILLA_SNAPSHOT_16X)).get());
147-
inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.VANILLA_STABLE_32X : IconUtil.VANILLA_SNAPSHOT_32X)).get());
148-
inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.VANILLA_STABLE_48X : IconUtil.VANILLA_SNAPSHOT_48X)).get());
149-
inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.VANILLA_STABLE_128X : IconUtil.VANILLA_SNAPSHOT_128X)).get());
150-
inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(SharedConstants.getCurrentVersion().isStable() ? IconUtil.VANILLA_STABLE_256X : IconUtil.VANILLA_SNAPSHOT_256X)).get());
133+
IconUtil.pushVanillaResource(inputStreams, IconUtil.VANILLA_STABLE_16X, IconUtil.VANILLA_SNAPSHOT_16X);
134+
IconUtil.pushVanillaResource(inputStreams, IconUtil.VANILLA_STABLE_32X, IconUtil.VANILLA_SNAPSHOT_32X);
135+
IconUtil.pushVanillaResource(inputStreams, IconUtil.VANILLA_STABLE_48X, IconUtil.VANILLA_SNAPSHOT_48X);
136+
IconUtil.pushVanillaResource(inputStreams, IconUtil.VANILLA_STABLE_128X, IconUtil.VANILLA_SNAPSHOT_128X);
137+
IconUtil.pushVanillaResource(inputStreams, IconUtil.VANILLA_STABLE_256X, IconUtil.VANILLA_SNAPSHOT_256X);
151138
//#elseif MC > 11902
152139
//$$ inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(IconUtil.VANILLA_STABLE_16X)).get());
153140
//$$ inputStreams.add(Objects.requireNonNull(mc.getVanillaPackResources().getRootResource(IconUtil.VANILLA_STABLE_32X)).get());
@@ -162,4 +149,26 @@ public static void updateIcon() {
162149
TweakMyClientReference.getLogger().error("Couldn't set icon");
163150
}
164151
}
152+
153+
private static void pushResource(@NotNull ArrayList<InputStream> list, ResourceLocation stable,
154+
ResourceLocation snapshot) throws IOException {
155+
Minecraft mc = TweakMyClient.getMinecraftClient();
156+
list.add(
157+
mc.getResourceManager().getResource(SharedConstants.getCurrentVersion().isStable() ? stable : snapshot)
158+
//#if MC > 11802
159+
.orElseThrow(RuntimeException::new).open()
160+
//#else
161+
//$$ .getInputStream()
162+
//#endif
163+
);
164+
}
165+
166+
//#if MC > 11904
167+
private static void pushVanillaResource(@NotNull ArrayList<InputStream> list, String[] stable,
168+
String[] snapshot) throws IOException {
169+
Minecraft mc = TweakMyClient.getMinecraftClient();
170+
list.add(Objects.requireNonNull(mc.getVanillaPackResources()
171+
.getRootResource(SharedConstants.getCurrentVersion().isStable() ? stable : snapshot)).get());
172+
}
173+
//#endif
165174
}

0 commit comments

Comments
 (0)