Skip to content

Commit 94daa76

Browse files
committed
Release 4.5.0 for Minecraft 1.21.2
1 parent f53ad86 commit 94daa76

File tree

10 files changed

+50
-69
lines changed

10 files changed

+50
-69
lines changed

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("fabric-loom") version "1.7-SNAPSHOT"
2+
id("fabric-loom") version "1.8-SNAPSHOT"
33
}
44

55
base {
@@ -12,6 +12,10 @@ java.toolchain {
1212
languageVersion.set(JavaLanguageVersion.of(21))
1313
}
1414

15+
loom {
16+
accessWidenerPath.set(file("src/main/resources/chameleon.accesswidener"))
17+
}
18+
1519
repositories {
1620
maven(url = "https://maven.terraformersmc.com/") // mod-menu
1721
}

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://modmuss50.me/fabric.html
5-
minecraft_version=1.21
6-
loader_version=0.15.11
5+
minecraft_version=1.21.2
6+
loader_version=0.16.7
77

88
#Fabric api
9-
fabric_version=0.100.4+1.21
9+
fabric_version=0.106.1+1.21.2
1010

1111
#Mod Menu
12-
mod-menu_version=11.0.1
12+
mod-menu_version=12.0.0-beta.1
1313

1414
# Mod Properties
15-
mod_version=4.4.0
15+
mod_version=4.5.0
1616
maven_group=moe.caramel
1717
archives_base_name=chameleon

gradle/wrapper/gradle-wrapper.jar

79 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/moe/caramel/chameleon/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ResourceLocation getFabricId() {
4141
@Override
4242
public void onResourceManagerReload(final ResourceManager manager) {
4343
while (!INIT_TOAST_QUEUE.isEmpty()) {
44-
Minecraft.getInstance().getToasts().addToast(INIT_TOAST_QUEUE.poll());
44+
Minecraft.getInstance().getToastManager().addToast(INIT_TOAST_QUEUE.poll());
4545
}
4646
}
4747
});

src/main/java/moe/caramel/chameleon/command/ChameleonCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class ChameleonCommand {
2929
public static void register(final @NotNull CommandDispatcher<FabricClientCommandSource> dispatcher) {
3030
dispatcher.register(literal("chameleon").executes(context -> {
3131
final Minecraft client = Minecraft.getInstance();
32-
client.tell(() -> client.setScreen(new ChangeDockIconScreen(null)));
32+
client.progressTasks.add(() -> client.setScreen(new ChangeDockIconScreen(null)));
3333
return 0;
3434
}).then(
3535
argument(ICON_NAME, ResourceLocationArgument.id()).suggests(SUGGEST).executes(context -> {

src/main/java/moe/caramel/chameleon/gui/ChangeDockIconScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected void init() {
3636
ModConfig.changeIcon(this.minecraft, entry.icon);
3737
} catch (final IOException exception) {
3838
exception.printStackTrace();
39-
this.minecraft.getToasts().addToast(new SystemToast(
39+
this.minecraft.getToastManager().addToast(new SystemToast(
4040
SystemToast.SystemToastId.PACK_LOAD_FAILURE,
4141
Component.translatable("caramel.chameleon.change.exception.title"),
4242
Component.translatable("caramel.chameleon.change.exception")
Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package moe.caramel.chameleon.util;
22

3+
import static java.util.Map.entry;
4+
import static net.minecraft.resources.ResourceLocation.withDefaultNamespace;
35
import com.mojang.blaze3d.platform.NativeImage;
4-
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
56
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
67
import net.minecraft.client.Minecraft;
78
import net.minecraft.core.RegistryAccess;
@@ -28,23 +29,25 @@ public final class ModConfig extends Settings<ModConfig> {
2829

2930
private static final Path MOD_CONFIG = new File("./config/caramel.chameleon.properties").toPath();
3031
private static final int CURRENT_CONFIG_VERSION = 1;
31-
public static final ResourceLocation ORIGINAL_MAC_ICON = ResourceLocation.withDefaultNamespace("icons/minecraft.icns");
32-
public static final ResourceLocation ORIGINAL_WIN_ICON = ResourceLocation.withDefaultNamespace("icons/icon_128x128.png");
33-
public static final Map<ResourceLocation, String[]> VANILLA_ICON_SET = new Object2ObjectOpenHashMap<>();
34-
static {
35-
VANILLA_ICON_SET.put(ORIGINAL_MAC_ICON, new String[]{ "icons", "minecraft.icns" });
36-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("icons/icon_16x16.png"), new String[]{ "icons", "icon_16x16.png" });
37-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("icons/icon_32x32.png"), new String[]{ "icons", "icon_32x32.png" });
38-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("icons/icon_48x48.png"), new String[]{ "icons", "icon_48x48.png" });
39-
VANILLA_ICON_SET.put(ORIGINAL_WIN_ICON, new String[]{ "icons", "icon_128x128.png" });
40-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("icons/icon_256x256.png"), new String[]{ "icons", "icon_256x256.png" });
41-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("snapshot/icons/icon_16x16.png"), new String[]{ "icons", "snapshot", "icon_16x16.png" });
42-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("snapshot/icons/icon_32x32.png"), new String[]{ "icons", "snapshot", "icon_32x32.png" });
43-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("snapshot/icons/icon_48x48.png"), new String[]{ "icons", "snapshot", "icon_48x48.png" });
44-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("snapshot/icons/icon_128x128.png"), new String[]{ "icons", "snapshot", "icon_128x128.png" });
45-
VANILLA_ICON_SET.put(ResourceLocation.withDefaultNamespace("snapshot/icons/icon_256x256.png"), new String[]{ "icons", "snapshot", "icon_256x256.png" });
46-
}
47-
public static final Function<Minecraft, Set<ResourceLocation>> GET_ICON_SET = client -> {
32+
33+
//<editor-fold desc="Icon registry" defaultstate="collapsed">
34+
public static final ResourceLocation ORIGINAL_MAC_ICON = withDefaultNamespace("icons/minecraft.icns");
35+
public static final ResourceLocation ORIGINAL_WIN_ICON = withDefaultNamespace("icons/icon_128x128.png");
36+
public static final Map<ResourceLocation, String[]> VANILLA_ICON_SET = Map.ofEntries(
37+
entry(ORIGINAL_MAC_ICON, new String[]{"icons", "minecraft.icns"}),
38+
entry(withDefaultNamespace("icons/icon_16x16.png"), new String[]{ "icons", "icon_16x16.png" }),
39+
entry(withDefaultNamespace("icons/icon_32x32.png"), new String[]{ "icons", "icon_32x32.png" }),
40+
entry(withDefaultNamespace("icons/icon_48x48.png"), new String[]{ "icons", "icon_48x48.png" }),
41+
entry(ORIGINAL_WIN_ICON, new String[]{ "icons", "icon_128x128.png" }),
42+
entry(withDefaultNamespace("icons/icon_256x256.png"), new String[]{ "icons", "icon_256x256.png" }),
43+
entry(withDefaultNamespace("snapshot/icons/icon_16x16.png"), new String[]{ "icons", "snapshot", "icon_16x16.png" }),
44+
entry(withDefaultNamespace("snapshot/icons/icon_32x32.png"), new String[]{ "icons", "snapshot", "icon_32x32.png" }),
45+
entry(withDefaultNamespace("snapshot/icons/icon_48x48.png"), new String[]{ "icons", "snapshot", "icon_48x48.png" }),
46+
entry(withDefaultNamespace("snapshot/icons/icon_128x128.png"), new String[]{ "icons", "snapshot", "icon_128x128.png" }),
47+
entry(withDefaultNamespace("snapshot/icons/icon_256x256.png"), new String[]{ "icons", "snapshot", "icon_256x256.png" })
48+
);
49+
50+
public static final Function<Minecraft, Set<ResourceLocation>> GET_ICON_SET = (client) -> {
4851
final Set<ResourceLocation> iconSet = new ObjectOpenHashSet<>();
4952
client.getResourceManager().listResources("icons", resource -> {
5053
if (resource != null) {
@@ -56,49 +59,33 @@ public final class ModConfig extends Settings<ModConfig> {
5659
iconSet.addAll(VANILLA_ICON_SET.keySet());
5760
return iconSet;
5861
};
62+
//</editor-fold>
5963

60-
/* ======================================== */
64+
//<editor-fold desc="Instance manager" defaultstate="collapsed">
6165
private static ModConfig instance;
6266

63-
/**
64-
* Get Mod config instance.
65-
* @return Mod config instance
66-
*/
6767
public static ModConfig getInstance() {
6868
if (instance == null) {
6969
instance = new ModConfig();
7070
}
7171

7272
return instance;
7373
}
74-
/* ======================================== */
75-
74+
//</editor-fold>
7675

77-
/* ======================================== */
76+
//<editor-fold desc="Instance" defaultstate="collapsed">
7877
public final Settings<ModConfig>.MutableValue<Integer> configVersion;
7978
public final Settings<ModConfig>.MutableValue<ResourceLocation> iconLocation;
8079

81-
/**
82-
* Mod config constructor
83-
*/
8480
private ModConfig() {
8581
this(Settings.loadFromFile(MOD_CONFIG));
8682
}
8783

88-
/**
89-
* Mod config constructor
90-
*/
9184
private ModConfig(final Properties properties) {
9285
super(properties);
9386
this.configVersion = this.getMutable(
9487
"config-version",
95-
s -> {
96-
if (s == null) {
97-
return 0;
98-
} else {
99-
return Integer.parseInt(s);
100-
}
101-
},
88+
s -> (s == null) ? 0 : Integer.parseInt(s),
10289
ModConfig.CURRENT_CONFIG_VERSION
10390
);
10491
this.iconLocation = this.getMutable(
@@ -107,23 +94,16 @@ private ModConfig(final Properties properties) {
10794
(Minecraft.ON_OSX ? ORIGINAL_MAC_ICON : ORIGINAL_WIN_ICON)
10895
);
10996
}
110-
/* ======================================== */
11197

11298
@Override
11399
protected @NotNull ModConfig reload(final RegistryAccess registryAccess, final Properties properties) {
114100
instance = new ModConfig(properties);
115101
instance.store(MOD_CONFIG);
116102
return getInstance();
117103
}
104+
//</editor-fold>
118105

119-
/* ======================================== */
120-
/**
121-
* Apply and save icon setting.
122-
*
123-
* @param client Minecraft object
124-
* @param icon Icon Resource location
125-
* @throws IOException InputStream open failed
126-
*/
106+
//<editor-fold desc="Icon applicator" defaultstate="collapsed">
127107
public static void changeIcon(final Minecraft client, final ResourceLocation icon) throws IOException {
128108
final String[] vanillaPath = ModConfig.VANILLA_ICON_SET.get(icon);
129109
final IoSupplier<InputStream> iconSupplier;
@@ -140,13 +120,6 @@ public static void changeIcon(final Minecraft client, final ResourceLocation ico
140120
ModConfig.getInstance().iconLocation.update(null, icon);
141121
}
142122

143-
/**
144-
* Change the icon in Windows OS.
145-
*
146-
* @param client Minecraft object
147-
* @param icon Icon Resource location
148-
* @throws IOException InputStream open failed
149-
*/
150123
public static void setWindowsIcon(final Minecraft client, final IoSupplier<InputStream> icon) throws IOException {
151124
ByteBuffer value = null;
152125

@@ -157,7 +130,7 @@ public static void setWindowsIcon(final Minecraft client, final IoSupplier<Input
157130
final GLFWImage.Buffer images = GLFWImage.malloc(1, stack);
158131

159132
value = MemoryUtil.memAlloc(image.getWidth() * image.getHeight() * 4);
160-
value.asIntBuffer().put(image.getPixelsRGBA());
133+
value.asIntBuffer().put(image.getPixelsABGR());
161134
images.position(0);
162135
images.width(image.getWidth());
163136
images.height(image.getHeight());
@@ -170,5 +143,5 @@ public static void setWindowsIcon(final Minecraft client, final IoSupplier<Input
170143
}
171144
}
172145
}
173-
/* ======================================== */
146+
//</editor-fold>
174147
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessWidener v2 named
2+
3+
accessible field net/minecraft/client/Minecraft progressTasks Ljava/util/Queue;

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
"main": [ "moe.caramel.chameleon.Main" ],
2222
"modmenu": [ "moe.caramel.chameleon.util.ModMenuImpl" ]
2323
},
24+
"accessWidener": "chameleon.accesswidener",
2425
"mixins": [ "chameleon-dock.mixins.json" ],
2526
"depends": {
2627
"fabric-command-api-v2": "*",
2728
"fabric-resource-loader-v0": "*",
28-
"fabricloader": ">=0.15.10",
29-
"minecraft": ">=1.21",
29+
"fabricloader": ">=0.16.7",
30+
"minecraft": ">=1.21.2",
3031
"java": ">=21"
3132
},
3233
"custom": {

0 commit comments

Comments
 (0)