Merge branch 'embeddedt:1.16' into 1.16-1

This commit is contained in:
I_am_Vietnam 2023-08-21 16:14:51 +07:00 committed by GitHub
commit b25495f35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 12 deletions

View File

@ -16,7 +16,7 @@ import org.embeddedt.modernfix.render.SimpleItemModelView;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = ItemRenderer.class, priority = 600) @Mixin(value = ItemRenderer.class, priority = 600)
@ -37,8 +37,8 @@ public abstract class ItemRendererMixin {
* we do not need to go through the process of rendering every quad. Just render the south ones (the ones facing the * we do not need to go through the process of rendering every quad. Just render the south ones (the ones facing the
* camera). * camera).
*/ */
@ModifyVariable(method = "renderModelLists", at = @At("HEAD"), index = 1, argsOnly = true) @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/ItemRenderer;renderModelLists(Lnet/minecraft/client/resources/model/BakedModel;Lnet/minecraft/world/item/ItemStack;IILcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V"), index = 0)
private BakedModel useSimpleWrappedItemModel(BakedModel model, BakedModel arg, ItemStack stack, int combinedLight, int combinedOverlay, PoseStack matrixStack, VertexConsumer buffer) { private BakedModel useSimpleWrappedItemModel(BakedModel model, ItemStack stack, int combinedLight, int combinedOverlay, PoseStack matrixStack, VertexConsumer buffer) {
if(!RenderState.IS_RENDERING_LEVEL && !stack.isEmpty() && model.getClass() == SimpleBakedModel.class && transformType == ItemTransforms.TransformType.GUI) { if(!RenderState.IS_RENDERING_LEVEL && !stack.isEmpty() && model.getClass() == SimpleBakedModel.class && transformType == ItemTransforms.TransformType.GUI) {
FastItemRenderType type; FastItemRenderType type;
ItemTransform transform = model.getTransforms().gui; ItemTransform transform = model.getTransforms().gui;

View File

@ -166,11 +166,13 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
"getFluidState", "method_26227", "m_60819_", "func_204520_s" "getFluidState", "method_26227", "m_60819_", "func_204520_s"
); );
Map<String, MethodNode> injectorMethodNames = new HashMap<>(); Map<String, MethodNode> injectorMethodNames = new HashMap<>();
Map<String, MethodNode> allMethods = new HashMap<>();
Map<String, String> injectorMixinSource = new HashMap<>(); Map<String, String> injectorMixinSource = new HashMap<>();
String descriptor = Type.getDescriptor(MixinMerged.class); String descriptor = Type.getDescriptor(MixinMerged.class);
for(MethodNode m : targetClass.methods) { for(MethodNode m : targetClass.methods) {
if((m.access & Opcodes.ACC_STATIC) != 0) if((m.access & Opcodes.ACC_STATIC) != 0)
continue; continue;
allMethods.put(m.name, m);
Set<AnnotationNode> seenNodes = new HashSet<>(); Set<AnnotationNode> seenNodes = new HashSet<>();
if(m.invisibleAnnotations != null) { if(m.invisibleAnnotations != null) {
for(AnnotationNode ann : m.invisibleAnnotations) { for(AnnotationNode ann : m.invisibleAnnotations) {
@ -217,18 +219,43 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
} }
} }
Set<String> accessedFieldNames = new HashSet<>(); Set<String> accessedFieldNames = new HashSet<>();
// We now know all methods that have been injected into initCache. See what fields they write to
injectorMethodNames.forEach((name, method) -> { // Make a map of all injected methods called by initCache
if(cacheCalledInjectors.contains(name)) { Map<String, MethodNode> writingMethods = new HashMap<>(injectorMethodNames);
for(AbstractInsnNode n : method.instructions) { writingMethods.keySet().retainAll(cacheCalledInjectors);
if(n instanceof FieldInsnNode) {
FieldInsnNode fieldAcc = (FieldInsnNode)n; // Recursively check the injected methods for any methods they may call
if(fieldAcc.getOpcode() == Opcodes.PUTFIELD && fieldAcc.owner.equals(targetClass.name)) { int previousSize = 0;
accessedFieldNames.add(fieldAcc.name); Set<String> checkedCalls = new HashSet<>();
while(writingMethods.size() > previousSize) {
previousSize = writingMethods.size();
List<String> keysToCheck = new ArrayList<>(writingMethods.keySet());
for(String name : keysToCheck) {
if(!checkedCalls.add(name))
continue;
for(AbstractInsnNode n : writingMethods.get(name).instructions) {
if(n instanceof MethodInsnNode) {
MethodInsnNode invokeNode = (MethodInsnNode)n;
if(invokeNode.owner.equals(targetClass.name)) {
MethodNode theMethod = allMethods.get(invokeNode.name);
if(theMethod != null)
writingMethods.put(invokeNode.name, theMethod);
} }
} }
} }
} }
}
// We now know all methods that have been injected into initCache, and their callers. See what fields they write to
writingMethods.forEach((name, method) -> {
for(AbstractInsnNode n : method.instructions) {
if(n instanceof FieldInsnNode) {
FieldInsnNode fieldAcc = (FieldInsnNode)n;
if(fieldAcc.getOpcode() == Opcodes.PUTFIELD && fieldAcc.owner.equals(targetClass.name)) {
accessedFieldNames.add(fieldAcc.name);
}
}
}
}); });
// Lastly, scan all injected methods and see if they retrieve from the field. If so, inject a generateCache // Lastly, scan all injected methods and see if they retrieve from the field. If so, inject a generateCache
// call at the start. // call at the start.

View File

@ -210,7 +210,7 @@ public class ModernFixEarlyConfig {
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot", "threadtweak"); disableIfModPresent("mixin.perf.thread_priorities", "smoothboot", "threadtweak");
disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot", "threadtweak"); disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot", "threadtweak");
disableIfModPresent("mixin.perf.async_jei", "modernui"); disableIfModPresent("mixin.perf.async_jei", "modernui");
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder"); disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge" ,"skyblockbuilder", "modern_beta");
disableIfModPresent("mixin.bugfix.mc218112", "performant"); disableIfModPresent("mixin.bugfix.mc218112", "performant");
disableIfModPresent("mixin.bugfix.remove_block_chunkloading", "performant"); disableIfModPresent("mixin.bugfix.remove_block_chunkloading", "performant");
disableIfModPresent("mixin.bugfix.paper_chunk_patches", "c2me"); disableIfModPresent("mixin.bugfix.paper_chunk_patches", "c2me");

View File

@ -8,6 +8,7 @@
"modernfix.perf_mod_warning": "推荐安装这些模组,但你也可以在现代化修复的配置中禁用此警告。", "modernfix.perf_mod_warning": "推荐安装这些模组,但你也可以在现代化修复的配置中禁用此警告。",
"modernfix.config": "现代化修复Mixin配置", "modernfix.config": "现代化修复Mixin配置",
"modernfix.config.done_restart": "完成(生效需重启)", "modernfix.config.done_restart": "完成(生效需重启)",
"modernfix.config.wiki": "打开英文wiki",
"modernfix.message.reload_config": "检测到模组配置文件的更改。为了避免加载尚未保存完毕的文件重载过程必须通过使用§b/mfrc§r命令来触发。", "modernfix.message.reload_config": "检测到模组配置文件的更改。为了避免加载尚未保存完毕的文件重载过程必须通过使用§b/mfrc§r命令来触发。",
"modernfix.option.on": "开启", "modernfix.option.on": "开启",
"modernfix.option.off": "关闭", "modernfix.option.off": "关闭",