Skip to content

Commit 406a4a3

Browse files
committed
Merge remote-tracking branch 'origin/1.18' into 1.19.2
2 parents 2ca29ef + 896c8d1 commit 406a4a3

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.embeddedt.modernfix.common.mixin.bugfix.item_cache_flag;
2+
3+
import net.minecraft.world.item.Item;
4+
import net.minecraft.world.item.ItemStack;
5+
import org.objectweb.asm.Opcodes;
6+
import org.spongepowered.asm.mixin.Final;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Overwrite;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Redirect;
12+
13+
/**
14+
* Remove emptyCacheFlag from ItemStack, as Mojang did in 1.20 due to <a href="https://bugs.mojang.com/browse/MC-258939">MC-258939</a>.
15+
*/
16+
@Mixin(ItemStack.class)
17+
public class ItemStackMixin {
18+
@Shadow @Final @Deprecated private Item item;
19+
20+
/**
21+
* @author embeddedt, Mojang
22+
* @reason avoid getItem()
23+
*/
24+
@Redirect(method = "isEmpty", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;"))
25+
private Item getItemDirect(ItemStack stack) {
26+
return this.item;
27+
}
28+
29+
@Redirect(method = "*", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/world/item/ItemStack;emptyCacheFlag:Z"))
30+
private boolean checkEmptyDirect(ItemStack stack) {
31+
return stack.isEmpty();
32+
}
33+
34+
/**
35+
* @author embeddedt, Mojang
36+
* @reason flag is no longer used
37+
*/
38+
@Overwrite
39+
private void updateEmptyCacheFlag() {}
40+
}

common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ private ModernFixEarlyConfig(File file) {
213213
*/
214214

215215
/* Mod compat */
216-
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot");
217-
disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot");
216+
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot", "threadtweak");
217+
disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot", "threadtweak");
218218
disableIfModPresent("mixin.perf.async_jei", "modernui");
219219
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder");
220220
disableIfModPresent("mixin.bugfix.mc218112", "performant");
@@ -281,7 +281,10 @@ private void readProperties(Properties props) {
281281
continue;
282282
}
283283

284-
option.setEnabled(enabled, true);
284+
if(!option.isModDefined())
285+
option.setEnabled(enabled, true);
286+
else
287+
LOGGER.warn("Option '{}' already disabled by a mod. Ignoring user configuration", key);
285288
}
286289
}
287290

common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,20 @@ public OptionEntry(String optionName, Option option) {
137137
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
138138
ModernFix.LOGGER.error("Unable to save config", e);
139139
}
140+
}, (btn, gfx, x, y) -> {
141+
if(this.option.isModDefined()) {
142+
String disablingMods = String.join(", ", this.option.getDefiningMods());
143+
OptionList.this.mainScreen.renderTooltip(
144+
gfx,
145+
Component.translatable("modernfix.option." + (this.option.isEnabled() ? "enabled" : "disabled"))
146+
.append(Component.translatable("modernfix.option.mod_override", disablingMods)),
147+
x,
148+
y
149+
);
150+
}
140151
});
152+
if(this.option.isModDefined())
153+
this.toggleButton.active = false;
141154
this.helpButton = new Button(75, 0, 20, 20, Component.literal("?"), (arg) -> {
142155
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
143156
});

common/src/main/resources/assets/modernfix/lang/en_us.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"modernfix.config.done_restart": "Done (restart required)",
1010
"modernfix.option.on": "on",
1111
"modernfix.option.off": "off",
12+
"modernfix.option.disabled": "disabled",
13+
"modernfix.option.enabled": "enabled",
14+
"modernfix.option.mod_override": " by mods [%s]",
1215
"modernfix.config.not_default": " (modified)",
1316
"asynclocator.map.locating": "Map (Locating...)",
1417
"asynclocator.map.none": "Map (No nearby feature found)",

0 commit comments

Comments
 (0)