Reaches main menu on 1.19.2
This commit is contained in:
parent
bad48db4d5
commit
f36074376b
|
|
@ -83,7 +83,6 @@ dependencies {
|
|||
|
||||
// your forge dependency, this is **required** when using Forge Loom in forge mode!
|
||||
forge "net.minecraftforge:forge:${project.forge_version}"
|
||||
modRuntimeOnly "curse.maven:lazydfu-460819:${lazydfu_version}"
|
||||
|
||||
modCompileOnly("curse.maven:refinedstorage-243076:${refined_storage_version}")
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ org.gradle.jvmargs=-Xmx1G
|
|||
loom.platform=forge
|
||||
|
||||
mod_id=modernfix
|
||||
minecraft_version=1.18.2
|
||||
forge_version=1.18.2-40.2.1
|
||||
lazydfu_version=3544496
|
||||
parchment_version=2022.11.06
|
||||
refined_storage_version=4392829
|
||||
jei_version=10.2.1.283
|
||||
minecraft_version=1.19.2
|
||||
forge_version=1.19.2-43.2.0
|
||||
parchment_version=2022.11.27
|
||||
refined_storage_version=4392788
|
||||
jei_version=11.6.0.1011
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package org.embeddedt.modernfix;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ConnectScreen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraftforge.client.event.ScreenOpenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
|
|
@ -43,10 +43,10 @@ public class ModernFixClient {
|
|||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onMultiplayerConnect(ScreenOpenEvent event) {
|
||||
if(event.getScreen() instanceof ConnectScreen && !event.isCanceled()) {
|
||||
public void onMultiplayerConnect(ScreenEvent.Opening event) {
|
||||
if(event.getNewScreen() instanceof ConnectScreen && !event.isCanceled()) {
|
||||
worldLoadStartTime = System.nanoTime();
|
||||
} else if (event.getScreen() instanceof TitleScreen && gameStartTimeSeconds < 0) {
|
||||
} else if (event.getNewScreen() instanceof TitleScreen && gameStartTimeSeconds < 0) {
|
||||
gameStartTimeSeconds = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start");
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public class ModernFixClient {
|
|||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
|
||||
public void onRenderOverlay(CustomizeGuiOverlayEvent.DebugText event) {
|
||||
if(brandingString != null && Minecraft.getInstance().options.renderDebug) {
|
||||
event.getLeft().add("");
|
||||
event.getLeft().add(brandingString);
|
||||
|
|
|
|||
|
|
@ -66,4 +66,8 @@ public class ModernFixConfig {
|
|||
jeiPluginBlacklist = BLACKLIST_ASYNC_JEI_PLUGINS.get().stream().map(ResourceLocation::new).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return COMMON_CONFIG.isLoaded();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class ModernFixEarlyConfig {
|
|||
// Defines the default rules which can be configured by the user or other mods.
|
||||
// You must manually add a rule for any new mixins not covered by an existing package rule.
|
||||
this.addMixinRule("core", true); // TODO: Don't actually allow the user to disable this
|
||||
this.addMixinRule("perf.modern_resourcepacks", true);
|
||||
this.addMixinRule("perf.modern_resourcepacks", false);
|
||||
this.addMixinRule("feature.branding", true);
|
||||
this.addMixinRule("feature.measure_time", true);
|
||||
this.addMixinRule("feature.reduce_loading_screen_freezes", false);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.screens.LevelLoadingScreen;
|
||||
import net.minecraft.client.gui.screens.ProgressScreen;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
|
@ -15,7 +15,7 @@ import net.minecraft.server.level.progress.ChunkProgressListener;
|
|||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.ForcedChunksSavedData;
|
||||
import net.minecraftforge.client.event.ScreenOpenEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.common.world.ForgeChunkManager;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.server.ServerAboutToStartEvent;
|
||||
|
|
@ -56,20 +56,20 @@ public class LoadEvents {
|
|||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onWorldShow(ScreenOpenEvent event) {
|
||||
public void onWorldShow(ScreenEvent.Opening event) {
|
||||
if(ServerLifecycleHooks.getCurrentServer() instanceof IntegratedServer) {
|
||||
if(event.getScreen() == null && Minecraft.getInstance().level != null && integratedWorldLoadListener != null) {
|
||||
if(event.getNewScreen() == null && Minecraft.getInstance().level != null && integratedWorldLoadListener != null) {
|
||||
/* this means the world is about to be displayed, check if 441 initialized */
|
||||
ServerChunkCache provider = ServerLifecycleHooks.getCurrentServer().overworld().getChunkSource();
|
||||
BooleanSupplier worldLoadDone = () -> provider.getTickingGenerated() >= 441;
|
||||
if(!worldLoadDone.getAsBoolean()) {
|
||||
DeferredLevelLoadingScreen newScreen = new DeferredLevelLoadingScreen(Minecraft.getInstance().progressListener.get(), worldLoadDone);
|
||||
event.setScreen(newScreen);
|
||||
event.setNewScreen(newScreen);
|
||||
}
|
||||
} else if(event.getScreen() instanceof LevelLoadingScreen && Minecraft.getInstance().level == null && ModernFixMixinPlugin.instance.isOptionEnabled("perf.faster_singleplayer_load.ClientEvents")) {
|
||||
} else if(event.getNewScreen() instanceof LevelLoadingScreen && Minecraft.getInstance().level == null && ModernFixMixinPlugin.instance.isOptionEnabled("perf.faster_singleplayer_load.ClientEvents")) {
|
||||
ProgressScreen loadscreen = new ProgressScreen(false);
|
||||
loadscreen.progressStartNoAbort(new TranslatableComponent("connect.joining"));
|
||||
event.setScreen(loadscreen);
|
||||
loadscreen.progressStartNoAbort(Component.translatable("connect.joining"));
|
||||
event.setNewScreen(loadscreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.embeddedt.modernfix.mixin.core;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
@ -14,8 +15,8 @@ import java.util.function.Function;
|
|||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
@Inject(method = "doLoadLevel", at = @At("HEAD"), remap = false)
|
||||
private void setLatch(String string, Function<LevelStorageSource.LevelStorageAccess, WorldStem.DataPackConfigSupplier> function, Function<LevelStorageSource.LevelStorageAccess, WorldStem.WorldDataSupplier> function2, boolean bl, Minecraft.ExperimentalDialogType arg, boolean creating, CallbackInfo ci) {
|
||||
@Inject(method = "doWorldLoad", at = @At("HEAD"), remap = false)
|
||||
private void setLatch(String string, LevelStorageSource.LevelStorageAccess arg, PackRepository arg2, WorldStem arg3, CallbackInfo ci) {
|
||||
ModernFix.worldLoadSemaphore = new CountDownLatch(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.function.Function;
|
|||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
/* not supported in 1.19
|
||||
private long datapackReloadStartTime;
|
||||
|
||||
@Inject(method = "makeWorldStem(Lnet/minecraft/server/packs/repository/PackRepository;ZLnet/minecraft/server/WorldStem$DataPackConfigSupplier;Lnet/minecraft/server/WorldStem$WorldDataSupplier;)Lnet/minecraft/server/WorldStem;", at = @At(value = "HEAD"))
|
||||
|
|
@ -37,4 +38,5 @@ public class MinecraftMixin {
|
|||
private void recordWorldLoadStart(CallbackInfo ci) {
|
||||
ModernFixClient.worldLoadStartTime = System.nanoTime();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ public class SimpleReloadableResourceManagerMixin {
|
|||
*/
|
||||
@ModifyArg(method = "createReload", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/SimpleReloadInstance;create(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/List;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;Z)Lnet/minecraft/server/packs/resources/ReloadInstance;"), index = 5)
|
||||
private boolean enableDebugReloader(boolean bl) {
|
||||
return bl || ModernFixConfig.ENABLE_DEBUG_RELOADER.get();
|
||||
return bl || (ModernFixConfig.isLoaded() && ModernFixConfig.ENABLE_DEBUG_RELOADER.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.blast_search_trees;
|
||||
|
||||
import mezz.jei.api.ingredients.ITypedIngredient;
|
||||
import mezz.jei.common.ingredients.IngredientFilter;
|
||||
import mezz.jei.gui.ingredients.IngredientFilter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ public class MinecraftMixin {
|
|||
private void replaceSearchTrees(CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
if(ModList.get().getModFileById("jei") != null) {
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, new JEIBackedSearchTree(false));
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, new JEIBackedSearchTree(true));
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new JEIBackedSearchTree(false));
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new JEIBackedSearchTree(true));
|
||||
} else {
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, new DummySearchTree<>());
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, new DummySearchTree<>());
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_NAMES, list -> new DummySearchTree<>());
|
||||
this.searchRegistry.register(SearchRegistry.CREATIVE_TAGS, list -> new DummySearchTree<>());
|
||||
}
|
||||
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, new DummySearchTree<>());
|
||||
this.searchRegistry.register(SearchRegistry.RECIPE_COLLECTIONS, list -> new DummySearchTree<>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
|
|
@ -32,7 +33,7 @@ public class ChunkGeneratorMixin implements IChunkGenerator {
|
|||
}
|
||||
|
||||
@Inject(method = "generateRingPositions", at = @At("HEAD"), cancellable = true)
|
||||
private void useCachedDataIfAvailable(Holder<StructureSet> setHolder, ConcentricRingsStructurePlacement placement, CallbackInfoReturnable<CompletableFuture<List<ChunkPos>>> cir) {
|
||||
private void useCachedDataIfAvailable(Holder<StructureSet> structureSet, RandomState random, ConcentricRingsStructurePlacement placement, CallbackInfoReturnable<CompletableFuture<List<ChunkPos>>> cir) {
|
||||
if(placement.count() == 0)
|
||||
return;
|
||||
ServerLevel level = searchLevel();
|
||||
|
|
@ -51,7 +52,7 @@ public class ChunkGeneratorMixin implements IChunkGenerator {
|
|||
}
|
||||
|
||||
@Inject(method = "generateRingPositions", at = @At("RETURN"), cancellable = true)
|
||||
private void saveCachedData(Holder<StructureSet> setHolder, ConcentricRingsStructurePlacement placement, CallbackInfoReturnable<CompletableFuture<List<ChunkPos>>> cir) {
|
||||
private void saveCachedData(Holder<StructureSet> structureSet, RandomState random, ConcentricRingsStructurePlacement placement, CallbackInfoReturnable<CompletableFuture<List<ChunkPos>>> cir) {
|
||||
cir.setReturnValue(cir.getReturnValue().thenApplyAsync(list -> {
|
||||
if(list.size() == 0)
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.embeddedt.modernfix.mixin.perf.cache_strongholds;
|
|||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
|
|
@ -10,6 +11,8 @@ import net.minecraft.world.level.CustomSpawner;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
|
|
@ -17,6 +20,7 @@ import net.minecraft.world.level.storage.WritableLevelData;
|
|||
import org.embeddedt.modernfix.duck.IChunkGenerator;
|
||||
import org.embeddedt.modernfix.duck.IServerLevel;
|
||||
import org.embeddedt.modernfix.world.StrongholdLocationCache;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
|
@ -30,19 +34,20 @@ import java.util.function.Supplier;
|
|||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevelMixin extends Level implements IServerLevel {
|
||||
protected ServerLevelMixin(WritableLevelData arg, ResourceKey<Level> arg2, Holder<DimensionType> arg3, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) {
|
||||
super(arg, arg2, arg3, supplier, bl, bl2, l);
|
||||
protected ServerLevelMixin(WritableLevelData arg, ResourceKey<Level> arg2, Holder<DimensionType> arg3, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l, int i) {
|
||||
super(arg, arg2, arg3, supplier, bl, bl2, l, i);
|
||||
}
|
||||
|
||||
@Shadow public abstract DimensionDataStorage getDataStorage();
|
||||
|
||||
@Shadow @Final private ServerChunkCache chunkSource;
|
||||
private StrongholdLocationCache mfix$strongholdCache;
|
||||
|
||||
/**
|
||||
* Initialize the stronghold cache but don't force any structure generation yet.
|
||||
*/
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkGenerator;ensureStructuresGenerated()V"))
|
||||
private void hookStrongholdCache(ChunkGenerator generator) {
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkGenerator;ensureStructuresGenerated(Lnet/minecraft/world/level/levelgen/RandomState;)V"))
|
||||
private void hookStrongholdCache(ChunkGenerator generator, RandomState state) {
|
||||
((IChunkGenerator)generator).mfix$setAssociatedServerLevel((ServerLevel)(Object)this);
|
||||
}
|
||||
|
||||
|
|
@ -50,11 +55,11 @@ public abstract class ServerLevelMixin extends Level implements IServerLevel {
|
|||
* Now start the stronghold generation process.
|
||||
*/
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void ensureGeneration(MinecraftServer minecraftServer, Executor executor, LevelStorageSource.LevelStorageAccess arg, ServerLevelData arg2, ResourceKey<Level> arg3, Holder<DimensionType> arg4, ChunkProgressListener arg5, ChunkGenerator arg6, boolean bl, long l, List<CustomSpawner> list, boolean bl2, CallbackInfo ci) {
|
||||
private void ensureGeneration(MinecraftServer minecraftServer, Executor executor, LevelStorageSource.LevelStorageAccess arg, ServerLevelData arg2, ResourceKey<Level> arg3, LevelStem arg4, ChunkProgressListener arg5, boolean bl, long l, List<CustomSpawner> list, boolean bl2, CallbackInfo ci) {
|
||||
mfix$strongholdCache = this.getDataStorage().computeIfAbsent(StrongholdLocationCache::load,
|
||||
StrongholdLocationCache::new,
|
||||
StrongholdLocationCache.getFileId(this.dimensionTypeRegistration()));
|
||||
arg6.ensureStructuresGenerated();
|
||||
this.chunkSource.getGenerator().ensureStructuresGenerated(this.chunkSource.randomState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,24 +2,38 @@ package org.embeddedt.modernfix.mixin.perf.cache_upgraded_structures;
|
|||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.structure.CachingStructureManager;
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(StructureManager.class)
|
||||
@Mixin(StructureTemplateManager.class)
|
||||
public class StructureManagerMixin {
|
||||
@Shadow @Final private DataFixer fixerUpper;
|
||||
|
||||
@Redirect(method = "loadFromResource", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureManager;readStructure(Ljava/io/InputStream;)Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;"))
|
||||
private StructureTemplate readViaCache(StructureManager manager, InputStream stream, ResourceLocation arg) throws IOException {
|
||||
return CachingStructureManager.readStructure(arg, this.fixerUpper, stream);
|
||||
@Shadow private ResourceManager resourceManager;
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason use our own manager to avoid needless DFU updates
|
||||
*/
|
||||
@Overwrite
|
||||
private Optional<StructureTemplate> loadFromResource(ResourceLocation id) {
|
||||
ResourceLocation arg = new ResourceLocation(id.getNamespace(), "structures/" + id.getPath() + ".nbt");
|
||||
try {
|
||||
return Optional.of(CachingStructureManager.readStructure(id, this.fixerUpper, this.resourceManager.open(arg)));
|
||||
} catch(IOException e) {
|
||||
ModernFix.LOGGER.error("Can't read structure", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,18 @@ package org.embeddedt.modernfix.mixin.perf.faster_baking;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.AtlasSet;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.embeddedt.modernfix.core.config.ModernFixConfig;
|
||||
|
|
@ -80,9 +82,9 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V"))
|
||||
private void bakeModels(ProfilerFiller pProfiler, int p_i226056_4_, CallbackInfo ci) {
|
||||
pProfiler.popPush("atlas");
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void bakeModels(ResourceManager arg, BlockColors arg2, ProfilerFiller pProfiler, int i, CallbackInfo ci) {
|
||||
pProfiler.push("atlas");
|
||||
Minecraft.getInstance().executeBlocking(() -> {
|
||||
for(Pair<TextureAtlas, TextureAtlas.Preparations> pair : this.atlasPreparations.values()) {
|
||||
TextureAtlas atlastexture = pair.getFirst();
|
||||
|
|
@ -95,7 +97,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
this.atlasSet = new AtlasSet(this.atlasPreparations.values().stream().map(Pair::getFirst).collect(Collectors.toList()));
|
||||
BakedModel missingModel = this.bake(MISSING_MODEL_LOCATION, BlockModelRotation.X0_Y0);
|
||||
this.bakedTopLevelModels.put(MISSING_MODEL_LOCATION, missingModel);
|
||||
Collection<String> modsListening = ModUtil.findAllModsListeningToEvent(ModelBakeEvent.class);
|
||||
Collection<String> modsListening = ModUtil.findAllModsListeningToEvent(ModelEvent.BakingCompleted.class);
|
||||
LOGGER.debug("Found ModelBakeEvent listeners: [" + String.join(", ", modsListening) + "]");
|
||||
Set<String> incompatibleLazyBakedModels = ImmutableSet.<String>builder()
|
||||
.addAll(ModernFixConfig.MODELS_TO_BAKE.get())
|
||||
|
|
@ -133,6 +135,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
|||
if (model != null)
|
||||
this.bakedTopLevelModels.put(location, model);
|
||||
});
|
||||
pProfiler.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import net.minecraft.client.renderer.texture.TextureManager;
|
|||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||
import org.embeddedt.modernfix.duck.IExtendedModelBakery;
|
||||
import org.embeddedt.modernfix.models.LazyBakedModel;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
|
@ -42,7 +41,7 @@ public class ModelManagerMixin {
|
|||
@Shadow @Final private BlockModelShaper blockModelShaper;
|
||||
|
||||
@Inject(method = "prepare(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)Lnet/minecraft/client/resources/model/ModelBakery;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;endTick()V"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void fireModelBakeEvent(ResourceManager pResourceManager, ProfilerFiller pProfiler, CallbackInfoReturnable<ModelBakery> cir, ForgeModelBakery pObject) {
|
||||
private void fireModelBakeEvent(ResourceManager pResourceManager, ProfilerFiller pProfiler, CallbackInfoReturnable<ModelBakery> cir, ModelBakery pObject) {
|
||||
pProfiler.push("modelevent");
|
||||
if (this.atlases != null) {
|
||||
Minecraft.getInstance().executeBlocking(() -> {
|
||||
|
|
|
|||
|
|
@ -1,146 +0,0 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.modern_resourcepacks;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.resource.PathResourcePack;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Mixin(PathResourcePack.class)
|
||||
public abstract class PathResourcePackMixin {
|
||||
@Shadow public abstract Set<String> getNamespaces(PackType type);
|
||||
|
||||
@Shadow protected abstract Path resolve(String... paths);
|
||||
|
||||
@Shadow @Final private String packName;
|
||||
@Shadow @Final private Path source;
|
||||
private EnumMap<PackType, Set<String>> namespacesByType;
|
||||
private EnumMap<PackType, HashMap<String, List<Pair<Path, String>>>> rootListingByNamespaceAndType;
|
||||
private boolean hasGeneratedListings;
|
||||
private Set<String> containedPaths;
|
||||
|
||||
private FileSystem resourcePackFS;
|
||||
|
||||
private static Joiner slashJoiner = Joiner.on('/');
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void cacheResources(String packName, Path source, CallbackInfo ci) {
|
||||
this.resourcePackFS = source.getFileSystem();
|
||||
this.namespacesByType = new EnumMap<>(PackType.class);
|
||||
this.hasGeneratedListings = false;
|
||||
}
|
||||
|
||||
private void generateResourceCache() {
|
||||
synchronized (this) {
|
||||
if(hasGeneratedListings)
|
||||
return;
|
||||
EnumMap<PackType, HashMap<String, List<Pair<Path, String>>>> rootListingByNamespaceAndType = new EnumMap<>(PackType.class);
|
||||
HashSet<String> containedPaths = new HashSet<>();
|
||||
for(PackType type : PackType.values()) {
|
||||
Set<String> namespaces = this.getNamespaces(type);
|
||||
HashMap<String, List<Pair<Path, String>>> rootListingForNamespaces = new HashMap<>();
|
||||
for(String namespace : namespaces) {
|
||||
try {
|
||||
Path root = this.resolve(type.getDirectory(), namespace).toAbsolutePath();
|
||||
try (Stream<Path> stream = Files.walk(root)) {
|
||||
ArrayList<Pair<Path, String>> rootListingPaths = new ArrayList<>();
|
||||
stream
|
||||
.map(path -> root.relativize(path.toAbsolutePath()))
|
||||
.filter(this::isValidCachedResourcePath)
|
||||
.forEach(path -> {
|
||||
if(!path.toString().endsWith(".mcmeta"))
|
||||
rootListingPaths.add(Pair.of(path, slashJoiner.join(path)));
|
||||
String mergedPath = slashJoiner.join(type.getDirectory(), namespace, path);
|
||||
containedPaths.add(mergedPath);
|
||||
});
|
||||
rootListingPaths.trimToSize();
|
||||
rootListingForNamespaces.put(namespace, rootListingPaths);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
rootListingForNamespaces.put(namespace, Collections.emptyList());
|
||||
}
|
||||
}
|
||||
rootListingByNamespaceAndType.put(type, rootListingForNamespaces);
|
||||
}
|
||||
this.rootListingByNamespaceAndType = rootListingByNamespaceAndType;
|
||||
this.containedPaths = containedPaths;
|
||||
this.hasGeneratedListings = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidCachedResourcePath(Path path) {
|
||||
String str = path.toString();
|
||||
for(int i = 0; i < str.length(); i++) {
|
||||
if(!ResourceLocation.validPathChar(str.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Inject(method = "getNamespaces", at = @At("HEAD"), cancellable = true)
|
||||
private void useCacheForNamespaces(PackType type, CallbackInfoReturnable<Set<String>> cir) {
|
||||
Set<String> cachedNamespaces;
|
||||
synchronized (this.namespacesByType) {
|
||||
cachedNamespaces = this.namespacesByType.get(type);
|
||||
}
|
||||
if(cachedNamespaces != null) {
|
||||
cir.setReturnValue(cachedNamespaces);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getNamespaces", at = @At("TAIL"))
|
||||
private void storeCacheForNamespaces(PackType type, CallbackInfoReturnable<Set<String>> cir) {
|
||||
synchronized (this.namespacesByType) {
|
||||
this.namespacesByType.put(type, cir.getReturnValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "hasResource(Ljava/lang/String;)Z", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void useCacheForExistence(String path, CallbackInfoReturnable<Boolean> cir) {
|
||||
this.generateResourceCache();
|
||||
cir.setReturnValue(this.containedPaths.contains(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason Use cached listing of mod resources
|
||||
*/
|
||||
@Inject(method = "getResources", at = @At("HEAD"), cancellable = true)
|
||||
public void getResources(PackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> filter, CallbackInfoReturnable<Collection<ResourceLocation>> cir)
|
||||
{
|
||||
this.generateResourceCache();
|
||||
if(!pathIn.endsWith("/"))
|
||||
pathIn = pathIn + "/";
|
||||
final String testPath = pathIn;
|
||||
Collection<ResourceLocation> cachedListing = this.rootListingByNamespaceAndType.get(type).getOrDefault(resourceNamespace, Collections.emptyList()).stream().
|
||||
filter(path -> path.getFirst().getNameCount() <= maxDepth). // Make sure the depth is within bounds
|
||||
filter(path -> path.getSecond().startsWith(testPath)). // Make sure the target path is inside this one
|
||||
filter(path -> filter.test(path.getFirst().getFileName().toString())). // Test the file name against the predicate
|
||||
// Finally we need to form the RL, so use the first name as the domain, and the rest as the path
|
||||
// It is VERY IMPORTANT that we do not rely on Path.toString as this is inconsistent between operating systems
|
||||
// Join the path names ourselves to force forward slashes
|
||||
map(path -> new ResourceLocation(resourceNamespace, path.getSecond())).
|
||||
collect(Collectors.toList());
|
||||
cir.setReturnValue(cachedListing);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.modern_resourcepacks;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.VanillaPackResources;
|
||||
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.embeddedt.modernfix.FileWalker;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Mixin(VanillaPackResources.class)
|
||||
public class VanillaPackResourcesMixin {
|
||||
@Shadow @Final private static Map<PackType, Path> ROOT_DIR_BY_TYPE;
|
||||
private static LoadingCache<Pair<Path, Integer>, List<Path>> pathStreamLoadingCache = CacheBuilder.newBuilder()
|
||||
.build(FileWalker.INSTANCE);
|
||||
|
||||
private static Set<String> containedPaths = null;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void cacheContainedPaths(PackMetadataSection arg, String[] p_i47912_1_, CallbackInfo ci) {
|
||||
if(containedPaths != null)
|
||||
return;
|
||||
containedPaths = new HashSet<>();
|
||||
Joiner slashJoiner = Joiner.on('/');
|
||||
for(PackType type : PackType.values()) {
|
||||
Path root = ROOT_DIR_BY_TYPE.get(type);
|
||||
if(root == null)
|
||||
throw new IllegalStateException("No filesystem for vanilla " + type.name() + " assets");
|
||||
try {
|
||||
try(Stream<Path> stream = Files.walk(root)) {
|
||||
stream
|
||||
.map(path -> root.relativize(path.toAbsolutePath()))
|
||||
.forEach(path -> containedPaths.add(slashJoiner.join(type.getDirectory(), path)));
|
||||
}
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "getResources(Ljava/util/Collection;ILjava/lang/String;Ljava/nio/file/Path;Ljava/lang/String;Ljava/util/function/Predicate;)V", at = @At(value = "INVOKE", target = "Ljava/nio/file/Files;walk(Ljava/nio/file/Path;I[Ljava/nio/file/FileVisitOption;)Ljava/util/stream/Stream;"))
|
||||
private static Stream<Path> useCacheForLoading(Path path, int maxDepth, FileVisitOption[] fileVisitOptions) throws IOException {
|
||||
try {
|
||||
return pathStreamLoadingCache.get(Pair.of(path, maxDepth)).stream();
|
||||
} catch (ExecutionException e) {
|
||||
if(e.getCause() instanceof IOException) /* generally always should be */
|
||||
throw (IOException)e.getCause();
|
||||
else
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "hasResource", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResource(Ljava/lang/String;)Ljava/net/URL;"), cancellable = true)
|
||||
private void useCacheForExistence(PackType type, ResourceLocation location, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(containedPaths.contains(type.getDirectory() + "/" + location.getNamespace() + "/" + location.getPath()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason avoid going through the module class loader when we know exactly what path this resource should come
|
||||
* from
|
||||
*/
|
||||
@Overwrite
|
||||
protected InputStream getResourceAsStream(PackType type, ResourceLocation location) {
|
||||
Path rootPath = ROOT_DIR_BY_TYPE.get(type);
|
||||
Path targetPath = rootPath.resolve(location.getNamespace() + "/" + location.getPath());
|
||||
try {
|
||||
return Files.newInputStream(targetPath);
|
||||
} catch(IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.parallelize_model_loading;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
|
|
@ -40,8 +41,8 @@ public abstract class ModelBakeryMixin {
|
|||
|
||||
private Map<ResourceLocation, List<Pair<String, BlockModelDefinition>>> deserializedBlockstateCache = null;
|
||||
|
||||
@Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", ordinal = 0))
|
||||
private void preloadJsonModels(ProfilerFiller profilerIn, int maxMipmapLevel, CallbackInfo ci) {
|
||||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", ordinal = 0))
|
||||
private void preloadJsonModels(ProfilerFiller profilerIn, String str) {
|
||||
StartupMessageManager.mcLoaderConsumer().ifPresent(c -> c.accept("Loading models"));
|
||||
profilerIn.popPush("loadblockstates");
|
||||
AsyncStopwatch.measureAndLogSerialRunningTime("Parallel blockstate loading", () -> {
|
||||
|
|
@ -53,25 +54,20 @@ public abstract class ModelBakeryMixin {
|
|||
futures.add(CompletableFuture.runAsync(() -> {
|
||||
ResourceLocation blockStateJSON = new ResourceLocation(blockLocation.getNamespace(), "blockstates/" + blockLocation.getPath() + ".json");
|
||||
List<Resource> blockStates;
|
||||
try {
|
||||
/* Some mods' custom resource pack implementations don't seem to like concurrency here */
|
||||
synchronized(this.resourceManager) {
|
||||
blockStates = this.resourceManager.getResources(blockStateJSON);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
ModernFix.LOGGER.warn("Exception loading blockstate definition: {}: {}", blockLocation, e);
|
||||
return;
|
||||
/* Some mods' custom resource pack implementations don't seem to like concurrency here */
|
||||
synchronized(this.resourceManager) {
|
||||
blockStates = this.resourceManager.getResourceStack(blockStateJSON);
|
||||
}
|
||||
List<Pair<String, BlockModelDefinition>> definitions = new ArrayList<>();
|
||||
StateDefinition<Block, BlockState> stateContainer = block.getStateDefinition();
|
||||
BlockModelDefinition.Context context = containerHolder.get();
|
||||
context.setDefinition(stateContainer);
|
||||
for(Resource resource : blockStates) {
|
||||
try (InputStream inputstream = resource.getInputStream()) {
|
||||
try (InputStream inputstream = resource.open()) {
|
||||
BlockModelDefinition definition = BlockModelDefinition.fromStream(context, new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
||||
definitions.add(Pair.of(resource.getSourceName(), definition));
|
||||
definitions.add(Pair.of(resource.sourcePackId(), definition));
|
||||
} catch (Exception exception1) {
|
||||
ModernFix.LOGGER.warn(String.format("Exception loading blockstate definition: '%s' in resourcepack: '%s': %s", resource.getLocation(), resource.getSourceName(), exception1.getMessage()));
|
||||
ModernFix.LOGGER.warn(String.format("Exception loading blockstate definition: '%s' in resourcepack: '%s': %s", blockStateJSON, resource.sourcePackId(), exception1.getMessage()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -80,16 +76,17 @@ public abstract class ModelBakeryMixin {
|
|||
}
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
});
|
||||
profilerIn.popPush(str);
|
||||
}
|
||||
|
||||
@Inject(method = "processLoading", at = @At("RETURN"), remap = false)
|
||||
private void clearModelCache(ProfilerFiller profilerIn, int maxMipmapLevel, CallbackInfo ci) {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void clearModelCache(ResourceManager arg, BlockColors arg2, ProfilerFiller arg3, int i, CallbackInfo ci) {
|
||||
deserializedBlockstateCache.clear();
|
||||
}
|
||||
|
||||
private List<?> replacementList = null;
|
||||
|
||||
@Redirect(method = "loadModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ResourceManager;getResources(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;", ordinal = 0))
|
||||
@Redirect(method = "loadModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ResourceManager;getResourceStack(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;", ordinal = 0))
|
||||
private List<?> getResourceList(ResourceManager instance, ResourceLocation jsonLocation, ResourceLocation originalBlockLocation) throws IOException {
|
||||
replacementList = null;
|
||||
if(this.deserializedBlockstateCache != null) {
|
||||
|
|
@ -104,7 +101,7 @@ public abstract class ModelBakeryMixin {
|
|||
return theList;
|
||||
}
|
||||
}
|
||||
return instance.getResources(jsonLocation);
|
||||
return instance.getResourceStack(jsonLocation);
|
||||
}
|
||||
|
||||
@Redirect(method = "loadModel", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;map(Ljava/util/function/Function;)Ljava/util/stream/Stream;", ordinal = 0))
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.parallelize_model_loading;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.obj.MaterialLibrary;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.obj.ObjLoader;
|
||||
import net.minecraftforge.client.model.obj.ObjMaterialLibrary;
|
||||
import net.minecraftforge.client.model.obj.ObjModel;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
@ -15,23 +15,23 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Mixin(OBJLoader.class)
|
||||
@Mixin(ObjLoader.class)
|
||||
public class OBJLoaderMixin {
|
||||
@Final
|
||||
@Mutable
|
||||
@Shadow(remap = false) private Map<ResourceLocation, MaterialLibrary> materialCache;
|
||||
@Shadow(remap = false) private Map<ResourceLocation, ObjMaterialLibrary> materialCache;
|
||||
|
||||
@Final
|
||||
@Mutable
|
||||
@Shadow(remap = false) private Map<OBJModel.ModelSettings, OBJModel> modelCache;
|
||||
@Shadow(remap = false) private Map<ObjModel.ModelSettings, ObjModel> modelCache;
|
||||
|
||||
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/OBJLoader;materialCache:Ljava/util/Map;", remap = false))
|
||||
private void useConcMap1(OBJLoader instance, Map<ResourceLocation, MaterialLibrary> value) {
|
||||
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/ObjLoader;materialCache:Ljava/util/Map;", remap = false))
|
||||
private void useConcMap1(ObjLoader instance, Map<ResourceLocation, ObjMaterialLibrary> value) {
|
||||
this.materialCache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/OBJLoader;modelCache:Ljava/util/Map;", remap = false))
|
||||
private void useConcMap2(OBJLoader instance, Map<ResourceLocation, MaterialLibrary> value) {
|
||||
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/ObjLoader;modelCache:Ljava/util/Map;", remap = false))
|
||||
private void useConcMap2(ObjLoader instance, Map<ResourceLocation, ObjMaterialLibrary> value) {
|
||||
this.modelCache = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.thread_priorities;
|
||||
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.Services;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.core.config.ModernFixConfig;
|
||||
|
|
@ -21,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(IntegratedServer.class)
|
||||
public class IntegratedServerMixin {
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void adjustServerPriority(Thread thread, Minecraft arg, LevelStorageSource.LevelStorageAccess arg2, PackRepository arg3, WorldStem arg4, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache arg5, ChunkProgressListenerFactory arg6, CallbackInfo ci) {
|
||||
private void adjustServerPriority(Thread thread, Minecraft arg, LevelStorageSource.LevelStorageAccess arg2, PackRepository arg3, WorldStem arg4, Services arg5, ChunkProgressListenerFactory arg6, CallbackInfo ci) {
|
||||
int pri = ModernFixConfig.INTEGRATED_SERVER_PRIORITY.get();
|
||||
ModernFix.LOGGER.info("Changing server thread priority to " + pri);
|
||||
thread.setPriority(pri);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.embeddedt.modernfix.models;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
|
@ -13,9 +14,10 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.ChunkRenderTypeSet;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
|
@ -46,7 +48,7 @@ public class LazyBakedModel implements BakedModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState pState, @Nullable Direction pSide, Random pRand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState pState, @Nullable Direction pSide, RandomSource pRand) {
|
||||
return computeDelegate().getQuads(pState, pSide, pRand);
|
||||
}
|
||||
|
||||
|
|
@ -91,8 +93,8 @@ public class LazyBakedModel implements BakedModel {
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
return computeDelegate().getQuads(state, side, rand, extraData);
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull RandomSource rand, @Nonnull ModelData extraData, @org.jetbrains.annotations.Nullable RenderType renderType) {
|
||||
return computeDelegate().getQuads(state, side, rand, extraData, renderType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -101,33 +103,38 @@ public class LazyBakedModel implements BakedModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean doesHandlePerspectives() {
|
||||
return computeDelegate().doesHandlePerspectives();
|
||||
public boolean useAmbientOcclusion(BlockState state, RenderType renderType) {
|
||||
return computeDelegate().useAmbientOcclusion(state, renderType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack mat) {
|
||||
return computeDelegate().handlePerspective(cameraTransformType, mat);
|
||||
public BakedModel applyTransform(ItemTransforms.TransformType transformType, PoseStack poseStack, boolean applyLeftHandTransform) {
|
||||
return computeDelegate().applyTransform(transformType, poseStack, applyLeftHandTransform);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) {
|
||||
public ModelData getModelData(@Nonnull BlockAndTintGetter world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull ModelData tileData) {
|
||||
return computeDelegate().getModelData(world, pos, state, tileData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleIcon(@Nonnull IModelData data) {
|
||||
public TextureAtlasSprite getParticleIcon(@Nonnull ModelData data) {
|
||||
return computeDelegate().getParticleIcon(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayered() {
|
||||
return computeDelegate().isLayered();
|
||||
public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) {
|
||||
return computeDelegate().getRenderTypes(state, rand, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<BakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous) {
|
||||
return computeDelegate().getLayerModels(itemStack, fabulous);
|
||||
public List<BakedModel> getRenderPasses(ItemStack itemStack, boolean fabulous) {
|
||||
return computeDelegate().getRenderPasses(itemStack, fabulous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> getRenderTypes(ItemStack itemStack, boolean fabulous) {
|
||||
return computeDelegate().getRenderTypes(itemStack, fabulous);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.embeddedt.modernfix.searchtree;
|
||||
|
||||
import net.minecraft.client.searchtree.MutableSearchTree;
|
||||
import net.minecraft.client.searchtree.ReloadableIdSearchTree;
|
||||
import net.minecraft.client.searchtree.RefreshableSearchTree;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -10,19 +9,9 @@ import java.util.stream.Stream;
|
|||
/**
|
||||
* Dummy search tree that stores nothing and returns nothing on searches.
|
||||
*/
|
||||
public class DummySearchTree<T> extends ReloadableIdSearchTree<T> implements MutableSearchTree<T> {
|
||||
public class DummySearchTree<T> implements RefreshableSearchTree<T> {
|
||||
public DummySearchTree() {
|
||||
super(t -> Stream.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(T pObj) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package org.embeddedt.modernfix.searchtree;
|
|||
|
||||
import mezz.jei.api.ingredients.ITypedIngredient;
|
||||
import mezz.jei.common.Internal;
|
||||
import mezz.jei.common.ingredients.IngredientFilter;
|
||||
import mezz.jei.common.ingredients.IngredientFilterApi;
|
||||
import mezz.jei.common.runtime.JeiRuntime;
|
||||
import mezz.jei.gui.ingredients.IngredientFilter;
|
||||
import mezz.jei.gui.ingredients.IngredientFilterApi;
|
||||
import mezz.jei.library.runtime.JeiRuntime;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.mixin.perf.blast_search_trees.IngredientFilterInvoker;
|
||||
|
|
@ -30,7 +30,7 @@ public class JEIBackedSearchTree extends DummySearchTree<ItemStack> {
|
|||
}
|
||||
@Override
|
||||
public List<ItemStack> search(String pSearchText) {
|
||||
Optional<JeiRuntime> runtime = Internal.getRuntime();
|
||||
Optional<JeiRuntime> runtime = JEIRuntimeCapturer.runtime();
|
||||
if(runtime.isPresent()) {
|
||||
IngredientFilterApi iFilterApi = (IngredientFilterApi)runtime.get().getIngredientFilter();
|
||||
IngredientFilter filter;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package org.embeddedt.modernfix.searchtree;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
import mezz.jei.library.runtime.JeiRuntime;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Optional;
|
||||
|
||||
@JeiPlugin
|
||||
public class JEIRuntimeCapturer implements IModPlugin {
|
||||
private static WeakReference<JeiRuntime> runtimeHandle = new WeakReference<>(null);
|
||||
|
||||
public static Optional<JeiRuntime> runtime() {
|
||||
return Optional.ofNullable(runtimeHandle.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
runtimeHandle = new WeakReference<>((JeiRuntime)jeiRuntime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeUnavailable() {
|
||||
runtimeHandle = new WeakReference<>(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader = "javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion = "[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
loaderVersion = "[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license = "GNU LGPL 3.0"
|
||||
|
|
@ -43,7 +43,7 @@ modId = "forge" #mandatory
|
|||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory = true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange = "[40,)" #mandatory
|
||||
versionRange = "[43,)" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering = "NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
|
@ -53,7 +53,7 @@ side = "BOTH"
|
|||
modId = "minecraft"
|
||||
mandatory = true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange = "[1.18.2,1.19)"
|
||||
versionRange = "[1.19.1, 1.19.2]"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
[[dependencies.modernfix]]
|
||||
|
|
@ -62,4 +62,4 @@ mandatory = false
|
|||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange = "[9.9999,)"
|
||||
ordering = "BEFORE"
|
||||
side = "CLIENT"
|
||||
side = "CLIENT"
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
"refmap": "modernfix.refmap.json",
|
||||
"mixins": [
|
||||
"bugfix.edge_chunk_not_saved.ChunkManagerMixin",
|
||||
"perf.modern_resourcepacks.PathResourcePackMixin",
|
||||
"perf.modern_resourcepacks.VanillaPackResourcesMixin",
|
||||
"perf.remove_biome_temperature_cache.BiomeMixin",
|
||||
"perf.reduce_blockstate_cache_rebuilds.GameDataMixin",
|
||||
"perf.reduce_blockstate_cache_rebuilds.BlockCallbacksMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user