From c7aaa15a199d87e23efb96d32eea982896ebcac6 Mon Sep 17 00:00:00 2001
From: embeddedt <42941056+embeddedt@users.noreply.github.com>
Date: Tue, 11 Jul 2023 17:25:26 -0400
Subject: [PATCH 1/4] Remove emptyCacheFlag from item stacks (fixes MC-258939)
---
.../item_cache_flag/ItemStackMixin.java | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
new file mode 100644
index 00000000..ebff609f
--- /dev/null
+++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
@@ -0,0 +1,40 @@
+package org.embeddedt.modernfix.common.mixin.bugfix.item_cache_flag;
+
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+import org.objectweb.asm.Opcodes;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Overwrite;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+/**
+ * Remove emptyCacheFlag from ItemStack, as Mojang did in 1.20 due to MC-258939.
+ */
+@Mixin(ItemStack.class)
+public class ItemStackMixin {
+ @Shadow @Final @Deprecated private Item item;
+
+ /**
+ * @author embeddedt, Mojang
+ * @reason avoid getItem()
+ */
+ @Redirect(method = "isEmpty", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;"))
+ private Item getItemDirect(ItemStack stack) {
+ return this.item;
+ }
+
+ @Redirect(method = "*", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/world/item/ItemStack;emptyCacheFlag:Z"))
+ private boolean checkEmptyDirect(ItemStack stack) {
+ return stack.isEmpty();
+ }
+
+ /**
+ * @author embeddedt, Mojang
+ * @reason flag is no longer used
+ */
+ @Overwrite
+ private void updateEmptyCacheFlag() {}
+}
From 4c484f51251e538e3c97c273231857a69e7c71e3 Mon Sep 17 00:00:00 2001
From: embeddedt <42941056+embeddedt@users.noreply.github.com>
Date: Tue, 11 Jul 2023 19:03:20 -0400
Subject: [PATCH 2/4] Recognize ThreadTweak when disabling overlapping patches
---
.../embeddedt/modernfix/core/config/ModernFixEarlyConfig.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
index 8c0f40db..1a3895f1 100644
--- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
+++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
@@ -217,8 +217,8 @@ public class ModernFixEarlyConfig {
*/
/* Mod compat */
- disableIfModPresent("mixin.perf.thread_priorities", "smoothboot");
- disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot");
+ disableIfModPresent("mixin.perf.thread_priorities", "smoothboot", "threadtweak");
+ disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot", "threadtweak");
disableIfModPresent("mixin.perf.async_jei", "modernui");
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder");
disableIfModPresent("mixin.bugfix.mc218112", "performant");
From 816346e9193e07fbbfbd612c55303695849b0cfa Mon Sep 17 00:00:00 2001
From: embeddedt <42941056+embeddedt@users.noreply.github.com>
Date: Tue, 11 Jul 2023 21:13:02 -0400
Subject: [PATCH 3/4] Make mod overrides higher priority than user
configuration
Prevents players inadvertently enabling incompatible options
---
.../modernfix/core/config/ModernFixEarlyConfig.java | 5 ++++-
.../org/embeddedt/modernfix/screen/OptionList.java | 13 +++++++++++++
.../main/resources/assets/modernfix/lang/en_us.json | 3 +++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
index 1a3895f1..18137c88 100644
--- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
+++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java
@@ -285,7 +285,10 @@ public class ModernFixEarlyConfig {
continue;
}
- option.setEnabled(enabled, true);
+ if(!option.isModDefined())
+ option.setEnabled(enabled, true);
+ else
+ LOGGER.warn("Option '{}' already disabled by a mod. Ignoring user configuration", key);
}
}
diff --git a/common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java b/common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java
index 271d73c2..c5ed97bb 100644
--- a/common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java
+++ b/common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java
@@ -128,7 +128,20 @@ public class OptionList extends ContainerObjectSelectionList {
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
ModernFix.LOGGER.error("Unable to save config", e);
}
+ }, (btn, gfx, x, y) -> {
+ if(this.option.isModDefined()) {
+ String disablingMods = String.join(", ", this.option.getDefiningMods());
+ OptionList.this.mainScreen.renderTooltip(
+ gfx,
+ new TranslatableComponent("modernfix.option." + (this.option.isEnabled() ? "enabled" : "disabled"))
+ .append(new TranslatableComponent("modernfix.option.mod_override", disablingMods)),
+ x,
+ y
+ );
+ }
});
+ if(this.option.isModDefined())
+ this.toggleButton.active = false;
this.helpButton = new Button(75, 0, 20, 20, new TextComponent("?"), (arg) -> {
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
});
diff --git a/common/src/main/resources/assets/modernfix/lang/en_us.json b/common/src/main/resources/assets/modernfix/lang/en_us.json
index 061363ff..0ae67db5 100644
--- a/common/src/main/resources/assets/modernfix/lang/en_us.json
+++ b/common/src/main/resources/assets/modernfix/lang/en_us.json
@@ -9,6 +9,9 @@
"modernfix.config.done_restart": "Done (restart required)",
"modernfix.option.on": "on",
"modernfix.option.off": "off",
+ "modernfix.option.disabled": "disabled",
+ "modernfix.option.enabled": "enabled",
+ "modernfix.option.mod_override": " by mods [%s]",
"modernfix.config.not_default": " (modified)",
"asynclocator.map.locating": "Map (Locating...)",
"asynclocator.map.none": "Map (No nearby feature found)",
From c1e40ebe1fc29387866b573a632f00d84dfdc410 Mon Sep 17 00:00:00 2001
From: embeddedt <42941056+embeddedt@users.noreply.github.com>
Date: Tue, 11 Jul 2023 21:23:22 -0400
Subject: [PATCH 4/4] Update item empty cache patch for 1.18
---
.../mixin/bugfix/item_cache_flag/ItemStackMixin.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
index ebff609f..4a106da1 100644
--- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
+++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/bugfix/item_cache_flag/ItemStackMixin.java
@@ -26,6 +26,15 @@ public class ItemStackMixin {
return this.item;
}
+ /**
+ * @author embeddedt, Mojang
+ * @reason avoid getItem()
+ */
+ @Redirect(method = "isEmpty", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;is(Lnet/minecraft/world/item/Item;)Z"))
+ private boolean checkIsDirect(ItemStack stack, Item item) {
+ return this.item == item;
+ }
+
@Redirect(method = "*", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/world/item/ItemStack;emptyCacheFlag:Z"))
private boolean checkEmptyDirect(ItemStack stack) {
return stack.isEmpty();