Merge 1.20.2 into 1.20.3
This commit is contained in:
commit
0e9142e68f
|
|
@ -1,4 +1,4 @@
|
||||||
package org.embeddedt.modernfix.fabric.mixin.perf.dynamic_resources;
|
package org.embeddedt.modernfix.common.mixin.perf.dynamic_resources;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
|
@ -20,6 +20,7 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
@ -156,7 +157,6 @@ public class ModernFixEarlyConfig {
|
||||||
|
|
||||||
private static final ImmutableMap<String, Boolean> DEFAULT_SETTING_OVERRIDES = new DefaultSettingMapBuilder()
|
private static final ImmutableMap<String, Boolean> DEFAULT_SETTING_OVERRIDES = new DefaultSettingMapBuilder()
|
||||||
.put("mixin.perf.dynamic_resources", false)
|
.put("mixin.perf.dynamic_resources", false)
|
||||||
.putConditionally(() -> !isFabric, "mixin.perf.async_jei", false)
|
|
||||||
.put("mixin.perf.dynamic_sounds", false)
|
.put("mixin.perf.dynamic_sounds", false)
|
||||||
.put("mixin.perf.dynamic_block_codecs", false)
|
.put("mixin.perf.dynamic_block_codecs", false)
|
||||||
.put("mixin.feature.direct_stack_trace", false)
|
.put("mixin.feature.direct_stack_trace", false)
|
||||||
|
|
@ -237,7 +237,10 @@ public class ModernFixEarlyConfig {
|
||||||
if(!ModernFixPlatformHooks.INSTANCE.isDevEnv())
|
if(!ModernFixPlatformHooks.INSTANCE.isDevEnv())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
if(ModernFixEarlyConfig.class.getClassLoader().getResource("/net/minecraft/world/level/Level.class") == null) {
|
URL deobfClass = isFabric ?
|
||||||
|
ModernFixEarlyConfig.class.getResource("/net/minecraft/world/level/Level.class") :
|
||||||
|
ModernFixEarlyConfig.class.getClassLoader().getResource("/net/minecraft/world/level/Level.class");
|
||||||
|
if(deobfClass == null) {
|
||||||
LOGGER.warn("We are in a non-Mojmap dev environment. Disabling blockstate cache patch");
|
LOGGER.warn("We are in a non-Mojmap dev environment. Disabling blockstate cache patch");
|
||||||
this.options.get("mixin.perf.reduce_blockstate_cache_rebuilds").addModOverride(false, "[not mojmap]");
|
this.options.get("mixin.perf.reduce_blockstate_cache_rebuilds").addModOverride(false, "[not mojmap]");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ public class ModernFixConfigScreen extends Screen {
|
||||||
|
|
||||||
public boolean madeChanges = false;
|
public boolean madeChanges = false;
|
||||||
private Button doneButton, wikiButton;
|
private Button doneButton, wikiButton;
|
||||||
|
private double lastScrollAmount = 0;
|
||||||
|
|
||||||
public ModernFixConfigScreen(Screen lastScreen) {
|
public ModernFixConfigScreen(Screen lastScreen) {
|
||||||
super(Component.translatable("modernfix.config"));
|
super(Component.translatable("modernfix.config"));
|
||||||
this.lastScreen = lastScreen;
|
this.lastScreen = lastScreen;
|
||||||
|
|
@ -21,6 +23,7 @@ public class ModernFixConfigScreen extends Screen {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
this.optionList = new OptionList(this, this.minecraft);
|
this.optionList = new OptionList(this, this.minecraft);
|
||||||
|
this.optionList.setScrollAmount(lastScrollAmount);
|
||||||
this.addWidget(this.optionList);
|
this.addWidget(this.optionList);
|
||||||
this.wikiButton = new Button.Builder(Component.translatable("modernfix.config.wiki"), (arg) -> {
|
this.wikiButton = new Button.Builder(Component.translatable("modernfix.config.wiki"), (arg) -> {
|
||||||
Util.getPlatform().openUri("https://github.com/embeddedt/ModernFix/wiki/Summary-of-Patches");
|
Util.getPlatform().openUri("https://github.com/embeddedt/ModernFix/wiki/Summary-of-Patches");
|
||||||
|
|
@ -45,4 +48,8 @@ public class ModernFixConfigScreen extends Screen {
|
||||||
this.doneButton.setMessage(madeChanges ? Component.translatable("modernfix.config.done_restart") : CommonComponents.GUI_DONE);
|
this.doneButton.setMessage(madeChanges ? Component.translatable("modernfix.config.done_restart") : CommonComponents.GUI_DONE);
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLastScrollAmount(double d) {
|
||||||
|
this.lastScrollAmount = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ public class OptionList extends ContainerObjectSelectionList<OptionList.Entry> {
|
||||||
}).tooltip(toggleTooltip).pos(0, 0).size(55, 20).build();
|
}).tooltip(toggleTooltip).pos(0, 0).size(55, 20).build();
|
||||||
updateStatus();
|
updateStatus();
|
||||||
this.helpButton = new Button.Builder(Component.literal("?"), (arg) -> {
|
this.helpButton = new Button.Builder(Component.literal("?"), (arg) -> {
|
||||||
|
mainScreen.setLastScrollAmount(getScrollAmount());
|
||||||
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
|
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
|
||||||
}).pos(75, 0).size(20, 20).build();
|
}).pos(75, 0).size(20, 20).build();
|
||||||
if(!I18n.exists("modernfix.option." + optionName)) {
|
if(!I18n.exists("modernfix.option." + optionName)) {
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
package org.embeddedt.modernfix.forge.mixin.perf.dynamic_resources;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
|
||||||
import net.minecraft.client.resources.model.ModelManager;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
|
||||||
import net.minecraft.util.GsonHelper;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.block.state.StateDefinition;
|
|
||||||
import org.embeddedt.modernfix.ModernFix;
|
|
||||||
import org.embeddedt.modernfix.util.LambdaMap;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Mixin(ModelManager.class)
|
|
||||||
public class ModelManagerMixin {
|
|
||||||
@Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/ModelManager;loadBlockModels(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
|
||||||
private CompletableFuture<Map<ResourceLocation, BlockModel>> deferBlockModelLoad(ResourceManager manager, Executor executor) {
|
|
||||||
return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockModel(manager, location)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/ModelManager;loadBlockStates(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
|
||||||
private CompletableFuture<Map<ResourceLocation, List<ModelBakery.LoadedJson>>> deferBlockStateLoad(ResourceManager manager, Executor executor) {
|
|
||||||
return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockState(manager, location)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "loadModels", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/StateDefinition;getPossibleStates()Lcom/google/common/collect/ImmutableList;"))
|
|
||||||
private ImmutableList<BlockState> skipCollection(StateDefinition<Block, BlockState> definition) {
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BlockModel loadSingleBlockModel(ResourceManager manager, ResourceLocation location) {
|
|
||||||
return manager.getResource(location).map(resource -> {
|
|
||||||
try (BufferedReader reader = resource.openAsReader()) {
|
|
||||||
return BlockModel.fromStream(reader);
|
|
||||||
} catch(IOException e) {
|
|
||||||
ModernFix.LOGGER.error("Couldn't load model", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ModelBakery.LoadedJson> loadSingleBlockState(ResourceManager manager, ResourceLocation location) {
|
|
||||||
return manager.getResourceStack(location).stream().map(resource -> {
|
|
||||||
try (BufferedReader reader = resource.openAsReader()) {
|
|
||||||
return new ModelBakery.LoadedJson(resource.sourcePackId(), GsonHelper.parse(reader));
|
|
||||||
} catch(IOException e) {
|
|
||||||
ModernFix.LOGGER.error("Couldn't load blockstate", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user