Merge remote-tracking branch 'origin/1.19.4' into 1.20

This commit is contained in:
embeddedt 2023-07-11 21:33:07 -04:00
commit b409db3e29
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
4 changed files with 68 additions and 4 deletions

View File

@ -0,0 +1,49 @@
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 <a href="https://bugs.mojang.com/browse/MC-258939">MC-258939</a>.
*/
@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;
}
/**
* @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();
}
/**
* @author embeddedt, Mojang
* @reason flag is no longer used
*/
@Overwrite
private void updateEmptyCacheFlag() {}
}

View File

@ -214,8 +214,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");
@ -282,7 +282,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);
}
}

View File

@ -8,6 +8,7 @@ import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.resources.language.I18n;
@ -128,6 +129,12 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
public OptionEntry(String optionName, Option option) {
this.name = optionName;
this.option = option;
Tooltip toggleTooltip = null;
if(this.option.isModDefined()) {
String disablingMods = String.join(", ", this.option.getDefiningMods());
toggleTooltip = Tooltip.create(Component.translatable("modernfix.option." + (this.option.isEnabled() ? "enabled" : "disabled"))
.append(Component.translatable("modernfix.option.mod_override", disablingMods)));
}
this.toggleButton = new Button.Builder(Component.literal(""), (arg) -> {
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
try {
@ -140,7 +147,9 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
ModernFix.LOGGER.error("Unable to save config", e);
}
}).pos(0, 0).size(55, 20).build();
}).tooltip(toggleTooltip).pos(0, 0).size(55, 20).build();
if(this.option.isModDefined())
this.toggleButton.active = false;
this.helpButton = new Button.Builder(Component.literal("?"), (arg) -> {
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
}).pos(75, 0).size(20, 20).build();

View File

@ -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)",