diff --git a/build.gradle b/build.gradle index d058e0d3..951edc37 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20210309-1.16.5' + mappings channel: 'official', version: '1.16.5' accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') diff --git a/src/main/java/org/embeddedt/modernfix/mixin/BiomeMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/BiomeMixin.java index cd5a5c46..74012c44 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/BiomeMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/BiomeMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.Shadow; /* Idea from Lithium for 1.19.3 */ @Mixin(Biome.class) public abstract class BiomeMixin { - @Shadow protected abstract float getTemperatureAtPosition(BlockPos pos); + @Shadow protected abstract float getHeightAdjustedTemperature(BlockPos pos); /** * @author 2No2Name @@ -19,6 +19,6 @@ public abstract class BiomeMixin { */ @Overwrite public final float getTemperature(BlockPos pos) { - return this.getTemperatureAtPosition(pos); + return this.getHeightAdjustedTemperature(pos); } } diff --git a/src/main/java/org/embeddedt/modernfix/mixin/BlockCallbacksMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/BlockCallbacksMixin.java index 182b4230..f7495442 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/BlockCallbacksMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/BlockCallbacksMixin.java @@ -10,14 +10,14 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(targets = { "net/minecraftforge/registries/GameData$BlockCallbacks" }) public class BlockCallbacksMixin { - @Redirect(method = "onBake", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;cacheState()V")) + @Redirect(method = "onBake", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;initCache()V")) private void skipCacheIfAllowed(BlockState state) { if(BakeReason.currentBakeReason == BakeReason.FREEZE || BakeReason.currentBakeReason == BakeReason.REMOTE_SNAPSHOT_INJECT || (BakeReason.currentBakeReason == BakeReason.LOCAL_SNAPSHOT_INJECT && ModernFix.runningFirstInjection)) { ((IBlockState)state).clearCache(); } else { - state.cacheState(); + state.initCache(); } } } diff --git a/src/main/java/org/embeddedt/modernfix/mixin/LevelSaveMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/LevelSaveMixin.java index 3c882046..f82cc7d8 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/LevelSaveMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/LevelSaveMixin.java @@ -16,11 +16,11 @@ import java.nio.file.Path; @Mixin(SaveFormat.LevelSave.class) public class LevelSaveMixin implements ILevelSave { - @Shadow @Final private Path saveDir; + @Shadow @Final private Path levelPath; public void runWorldPersistenceHooks() { - SaveFormat saveFormat = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getInstance(), "field_71469_aa"); - ((SaveFormatAccessor)saveFormat).invokeReadFromLevelData(this.saveDir.toFile(), (file, dataFixer) -> { + SaveFormat saveFormat = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getInstance(), "levelSource"); + ((SaveFormatAccessor)saveFormat).invokeReadLevelData(this.levelPath.toFile(), (file, dataFixer) -> { try { CompoundNBT compoundTag = CompressedStreamTools.readCompressed(file); net.minecraftforge.fml.WorldPersistenceHooks.handleWorldDataLoad((SaveFormat.LevelSave)(Object)this, new DummyServerConfiguration(), compoundTag); diff --git a/src/main/java/org/embeddedt/modernfix/mixin/MinecraftMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/MinecraftMixin.java index 35f68d41..31208e3c 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/MinecraftMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/MinecraftMixin.java @@ -23,16 +23,16 @@ import java.util.function.Function; @Mixin(Minecraft.class) public abstract class MinecraftMixin { - @Shadow public abstract Minecraft.PackManager reloadDatapacks(DynamicRegistries.Impl dynamicRegistries, Function worldStorageToDatapackFunction, Function4 quadFunction, boolean vanillaOnly, SaveFormat.LevelSave worldStorage) throws InterruptedException, ExecutionException; + @Shadow public abstract Minecraft.PackManager makeServerStem(DynamicRegistries.Impl dynamicRegistries, Function worldStorageToDatapackFunction, Function4 quadFunction, boolean vanillaOnly, SaveFormat.LevelSave worldStorage) throws InterruptedException, ExecutionException; private long datapackReloadStartTime; private int registryHash; - @Inject(method = "reloadDatapacks", at = @At(value = "HEAD")) + @Inject(method = "makeServerStem", at = @At(value = "HEAD")) private void recordReloadStart(DynamicRegistries.Impl p_238189_1_, Function p_238189_2_, Function4 p_238189_3_, boolean p_238189_4_, SaveFormat.LevelSave p_238189_5_, CallbackInfoReturnable cir) { datapackReloadStartTime = System.nanoTime(); } - @Inject(method = "reloadDatapacks", at = @At(value = "RETURN")) + @Inject(method = "makeServerStem", at = @At(value = "RETURN")) private void recordReloadEnd(DynamicRegistries.Impl p_238189_1_, Function p_238189_2_, Function4 p_238189_3_, boolean p_238189_4_, SaveFormat.LevelSave p_238189_5_, CallbackInfoReturnable cir) { float timeSpentReloading = ((float)(System.nanoTime() - datapackReloadStartTime) / 1000000000f); ModernFix.LOGGER.warn("Datapack reload took " + timeSpentReloading + " seconds."); @@ -43,12 +43,12 @@ public abstract class MinecraftMixin { ModernFixClient.worldLoadStartTime = System.nanoTime(); } - @Redirect(method = "loadWorld(Ljava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DynamicRegistries;func_239770_b_()Lnet/minecraft/util/registry/DynamicRegistries$Impl;")) + @Redirect(method = "loadLevel(Ljava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DynamicRegistries;builtin()Lnet/minecraft/util/registry/DynamicRegistries$Impl;")) private DynamicRegistries.Impl useNullRegistry() { return null; } - @Redirect(method = "loadWorld(Ljava/lang/String;Lnet/minecraft/util/registry/DynamicRegistries$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/Minecraft$WorldSelectionType;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;reloadDatapacks(Lnet/minecraft/util/registry/DynamicRegistries$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/world/storage/SaveFormat$LevelSave;)Lnet/minecraft/client/Minecraft$PackManager;", ordinal = 0)) + @Redirect(method = "loadWorld(Ljava/lang/String;Lnet/minecraft/util/registry/DynamicRegistries$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/Minecraft$WorldSelectionType;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;makeServerStem(Lnet/minecraft/util/registry/DynamicRegistries$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/world/storage/SaveFormat$LevelSave;)Lnet/minecraft/client/Minecraft$PackManager;", ordinal = 0)) private Minecraft.PackManager skipFirstReload(Minecraft client, DynamicRegistries.Impl dynamicRegistries, Function worldStorageToDatapackFunction, Function4 quadFunction, boolean vanillaOnly, SaveFormat.LevelSave levelSave, String worldName, DynamicRegistries.Impl originalRegistries, Function levelSaveToDatapackFunction, Function4 quadFunction2, boolean vanillaOnly2, Minecraft.WorldSelectionType selectionType, boolean creating) throws InterruptedException, ExecutionException { if(!creating) { ModernFix.LOGGER.warn("Skipping first reload, this is still experimental"); @@ -58,7 +58,7 @@ public abstract class MinecraftMixin { return null; } else { /* allow reload */ - return reloadDatapacks(dynamicRegistries, worldStorageToDatapackFunction, quadFunction, vanillaOnly, levelSave); + return makeServerStem(dynamicRegistries, worldStorageToDatapackFunction, quadFunction, vanillaOnly, levelSave); } } } diff --git a/src/main/java/org/embeddedt/modernfix/mixin/ModFileResourcePackMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/ModFileResourcePackMixin.java index 5dfb3449..167a0243 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/ModFileResourcePackMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/ModFileResourcePackMixin.java @@ -27,7 +27,7 @@ import java.util.stream.Stream; @Mixin(ModFileResourcePack.class) public abstract class ModFileResourcePackMixin { - @Shadow public abstract Set getResourceNamespaces(ResourcePackType type); + @Shadow public abstract Set getNamespaces(ResourcePackType type); @Shadow(remap = false) @Final private ModFile modFile; private EnumMap> namespacesByType; @@ -39,7 +39,7 @@ public abstract class ModFileResourcePackMixin { this.useNamespaceCaches = false; this.namespacesByType = new EnumMap<>(ResourcePackType.class); for(ResourcePackType type : ResourcePackType.values()) { - this.namespacesByType.put(type, this.getResourceNamespaces(type)); + this.namespacesByType.put(type, this.getNamespaces(type)); } this.useNamespaceCaches = true; this.rootListingByNamespaceAndType = new EnumMap<>(ResourcePackType.class); @@ -48,7 +48,7 @@ public abstract class ModFileResourcePackMixin { HashMap> rootListingForNamespaces = new HashMap<>(); for(String namespace : namespaces) { try { - Path root = modFile.getLocator().findPath(modFile, type.getDirectoryName(), namespace).toAbsolutePath(); + Path root = modFile.getLocator().findPath(modFile, type.getDirectory(), namespace).toAbsolutePath(); try (Stream stream = Files.walk(root)) { rootListingForNamespaces.put(namespace, stream .map(path -> root.relativize(path.toAbsolutePath())) @@ -63,7 +63,7 @@ public abstract class ModFileResourcePackMixin { } } - @Inject(method = "getResourceNamespaces", at = @At("HEAD"), cancellable = true) + @Inject(method = "getNamespaces", at = @At("HEAD"), cancellable = true) private void useCacheForNamespaces(ResourcePackType type, CallbackInfoReturnable> cir) { if(useNamespaceCaches) { cir.setReturnValue(this.namespacesByType.get(type)); @@ -75,9 +75,9 @@ public abstract class ModFileResourcePackMixin { * @reason Use cached listing of mod resources */ @Overwrite - public Collection getAllResourceLocations(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate filter) + public Collection getResources(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate filter) { - Path root = modFile.getLocator().findPath(modFile, type.getDirectoryName(), resourceNamespace).toAbsolutePath(); + Path root = modFile.getLocator().findPath(modFile, type.getDirectory(), resourceNamespace).toAbsolutePath(); Path inputPath = root.getFileSystem().getPath(pathIn); return this.rootListingByNamespaceAndType.get(type).getOrDefault(resourceNamespace, Collections.emptyList()).stream(). filter(path -> path.getNameCount() <= maxDepth). // Make sure the depth is within bounds diff --git a/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java index 0d557314..01c2a429 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/ModelBakeryMixin.java @@ -1,10 +1,8 @@ package org.embeddedt.modernfix.mixin; import com.google.common.base.Stopwatch; -import com.google.common.cache.LoadingCache; import com.google.common.collect.Sets; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.SpriteMap; import net.minecraft.profiler.IProfiler; @@ -38,23 +36,23 @@ import java.util.stream.Stream; @Mixin(ModelBakery.class) public abstract class ModelBakeryMixin { - @Shadow protected abstract BlockModel loadModel(ResourceLocation location) throws IOException; + @Shadow protected abstract BlockModel loadBlockModel(ResourceLocation location) throws IOException; - @Shadow @Final private Map unbakedModels; - @Shadow @Final public static ModelResourceLocation MODEL_MISSING; + @Shadow @Final private Map unbakedCache; + @Shadow @Final public static ModelResourceLocation MISSING_MODEL_LOCATION; - @Shadow public abstract IUnbakedModel getUnbakedModel(ResourceLocation modelLocation); + @Shadow public abstract IUnbakedModel getModel(ResourceLocation modelLocation); - @Shadow @Final public static BlockModel MODEL_GENERATED; + @Shadow @Final public static BlockModel GENERATION_MARKER; @Shadow @Final private static ItemModelGenerator ITEM_MODEL_GENERATOR; - @Shadow @Nullable private SpriteMap spriteMap; - @Shadow @Final private Map, IBakedModel> bakedModels; - @Shadow @Final private Map topBakedModels; - @Shadow @Final private Map topUnbakedModels; + @Shadow @Nullable private SpriteMap atlasSet; + @Shadow @Final private Map, IBakedModel> bakedCache; + @Shadow @Final private Map bakedTopLevelModels; + @Shadow @Final private Map topLevelModels; private Map deserializedModelCache = null; private boolean useModelCache = false; - @Inject(method = "loadModel", at = @At("HEAD"), cancellable = true) + @Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true) private void useCachedModel(ResourceLocation location, CallbackInfoReturnable cir) { if(useModelCache && deserializedModelCache != null) { BlockModel model = deserializedModelCache.get(location); @@ -65,24 +63,24 @@ public abstract class ModelBakeryMixin { private BlockModel loadModelSafely(ResourceLocation location) { try { - return this.loadModel(location); + return this.loadBlockModel(location); } catch(Throwable e) { ModernFix.LOGGER.warn("Model " + location + " will not be preloaded", e); return null; } } - @Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V", ordinal = 1)) + @Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/IProfiler;popPush(Ljava/lang/String;)V", ordinal = 1)) private void preloadJsonModels(IProfiler profilerIn, int maxMipmapLevel, CallbackInfo ci) { - profilerIn.endStartSection("loadjsons"); + profilerIn.popPush("loadjsons"); ModernFix.LOGGER.warn("Preloading JSONs in parallel..."); Stopwatch stopwatch = Stopwatch.createStarted(); useModelCache = false; - deserializedModelCache = Minecraft.getInstance().getResourceManager().getAllResourceLocations("models", p -> { + deserializedModelCache = Minecraft.getInstance().getResourceManager().listResources("models", p -> { if(!p.endsWith(".json")) return false; for(int i = 0; i < p.length(); i++) { - if(!ResourceLocation.validatePathChar(p.charAt(i))) + if(!ResourceLocation.validPathChar(p.charAt(i))) return false; } return true; @@ -106,30 +104,30 @@ public abstract class ModelBakeryMixin { @Redirect(method = "uploadTextures", at = @At(value = "INVOKE", target = "Ljava/util/Set;forEach(Ljava/util/function/Consumer;)V", ordinal = 0)) private void parallelBake(Set locationSet, Consumer consumer) { final IModelTransform transform = ModelRotation.X0_Y0; - if(this.spriteMap == null) + if(this.atlasSet == null) throw new IllegalStateException("no sprite map"); ModernFix.LOGGER.warn("Baking models in parallel..."); Stopwatch stopwatch = Stopwatch.createStarted(); - locationSet.forEach(this::getUnbakedModel); /* make sure every unbaked model is loaded, should be fast */ + locationSet.forEach(this::getModel); /* make sure every unbaked model is loaded, should be fast */ List> models = CompletableFuture.supplyAsync(() -> { return locationSet.parallelStream().map(location -> { - IUnbakedModel iunbakedmodel = this.unbakedModels.get(location); + IUnbakedModel iunbakedmodel = this.unbakedCache.get(location); if (iunbakedmodel instanceof BlockModel) { BlockModel blockmodel = (BlockModel)iunbakedmodel; - if (blockmodel.getRootModel() == MODEL_GENERATED) { - return Pair.of(location, ITEM_MODEL_GENERATOR.makeItemModel(this.spriteMap::getSprite, blockmodel).bakeModel((ModelBakery)(Object)this, blockmodel, this.spriteMap::getSprite, transform, location, false)); + if (blockmodel.getRootModel() == GENERATION_MARKER) { + return Pair.of(location, ITEM_MODEL_GENERATOR.generateBlockModel(this.atlasSet::getSprite, blockmodel).bake((ModelBakery)(Object)this, blockmodel, this.atlasSet::getSprite, transform, location, false)); } } - IBakedModel ibakedmodel = iunbakedmodel.bakeModel((ModelBakery)(Object)this, this.spriteMap::getSprite, transform, location); + IBakedModel ibakedmodel = iunbakedmodel.bake((ModelBakery)(Object)this, this.atlasSet::getSprite, transform, location); return Pair.of(location, ibakedmodel); }).collect(Collectors.toList()); - }, Util.getServerExecutor()).join(); + }, Util.backgroundExecutor()).join(); models.forEach(pair -> { - Triple triple = Triple.of(pair.getKey(), transform.getRotation(), transform.isUvLock()); - this.bakedModels.put(triple, pair.getValue()); + Triple triple = Triple.of(pair.getKey(), transform.getRotation(), transform.isUvLocked()); + this.bakedCache.put(triple, pair.getValue()); if(pair.getValue() != null) - this.topBakedModels.put(pair.getKey(), pair.getValue()); + this.bakedTopLevelModels.put(pair.getKey(), pair.getValue()); }); ModernFix.LOGGER.warn("Baking in parallel took " + stopwatch.elapsed(TimeUnit.SECONDS) + " seconds"); stopwatch.stop(); @@ -139,21 +137,21 @@ public abstract class ModelBakeryMixin { private Object collectTexturesParallel(Stream instance, Collector arCollector) { ModernFix.LOGGER.warn("Collecting textures in parallel..."); Stopwatch stopwatch = Stopwatch.createStarted(); - ConcurrentHashMap threadedUnbakedModels = new ConcurrentHashMap<>(this.unbakedModels); + ConcurrentHashMap threadedunbakedCache = new ConcurrentHashMap<>(this.unbakedCache); Function safeUnbakedGetter = (location) -> { - IUnbakedModel candidate = threadedUnbakedModels.get(location); + IUnbakedModel candidate = threadedunbakedCache.get(location); if(candidate == null) { - synchronized (this.unbakedModels) { - candidate = this.getUnbakedModel(location); - threadedUnbakedModels.put(location, candidate); + synchronized (this.unbakedCache) { + candidate = this.getModel(location); + threadedunbakedCache.put(location, candidate); } } return candidate; }; Set> set = Collections.synchronizedSet(Sets.newLinkedHashSet()); - String modelMissingString = MODEL_MISSING.toString(); - Set materials = this.topUnbakedModels.values().parallelStream().flatMap((unbaked) -> { - return unbaked.getTextures(safeUnbakedGetter, set).stream(); + String modelMissingString = MISSING_MODEL_LOCATION.toString(); + Set materials = this.topLevelModels.values().parallelStream().flatMap((unbaked) -> { + return unbaked.getMaterials(safeUnbakedGetter, set).stream(); }).collect(Collectors.toSet()); set.stream().filter((stringPair) -> { return !stringPair.getSecond().equals(modelMissingString); diff --git a/src/main/java/org/embeddedt/modernfix/mixin/RenderTypeMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/RenderTypeMixin.java index 42254d06..7d25d2b2 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/RenderTypeMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/RenderTypeMixin.java @@ -1,6 +1,5 @@ package org.embeddedt.modernfix.mixin; -import com.google.common.base.Preconditions; import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.vertex.VertexFormat; @@ -9,20 +8,18 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import java.util.Collections; - @Mixin(targets = {"net/minecraft/client/renderer/RenderType$Type"}) public class RenderTypeMixin { - @Shadow @Final private static ObjectOpenCustomHashSet TYPES; + @Shadow @Final private static ObjectOpenCustomHashSet INSTANCES; /** * @author embeddedt * @reason synchronize, can be accessed by multiple mods during modloading */ @Overwrite - private static RenderType.Type getOrCreate(String name, VertexFormat format, int drawMode, int bufferSize, boolean useDelegate, boolean needsSorting, RenderType.State renderState) { - synchronized (TYPES){ - return TYPES.addOrGet(new RenderType.Type(name, format, drawMode, bufferSize, useDelegate, needsSorting, renderState)); + private static RenderType.Type memoize(String name, VertexFormat format, int drawMode, int bufferSize, boolean useDelegate, boolean needsSorting, RenderType.State renderState) { + synchronized (INSTANCES){ + return INSTANCES.addOrGet(new RenderType.Type(name, format, drawMode, bufferSize, useDelegate, needsSorting, renderState)); } } } diff --git a/src/main/java/org/embeddedt/modernfix/mixin/SaveFormatAccessor.java b/src/main/java/org/embeddedt/modernfix/mixin/SaveFormatAccessor.java index cb855d06..bef9b5c8 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/SaveFormatAccessor.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/SaveFormatAccessor.java @@ -11,5 +11,5 @@ import java.util.function.BiFunction; @Mixin(SaveFormat.class) public interface SaveFormatAccessor { @Invoker - T invokeReadFromLevelData(File saveDir, BiFunction levelDatReader); + T invokeReadLevelData(File saveDir, BiFunction levelDatReader); } diff --git a/src/main/java/org/embeddedt/modernfix/mixin/VanillaPackMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/VanillaPackMixin.java index d0bcc22b..ad3b5e7b 100644 --- a/src/main/java/org/embeddedt/modernfix/mixin/VanillaPackMixin.java +++ b/src/main/java/org/embeddedt/modernfix/mixin/VanillaPackMixin.java @@ -29,11 +29,11 @@ import java.util.stream.Stream; @Mixin(VanillaPack.class) public class VanillaPackMixin { - @Shadow @Final private static Map FILE_SYSTEMS_BY_PACK_TYPE; + @Shadow @Final private static Map JAR_FILESYSTEM_BY_TYPE; private static LoadingCache, List> pathStreamLoadingCache = CacheBuilder.newBuilder() .build(FileWalker.INSTANCE); - @Redirect(method = "collectResources", at = @At(value = "INVOKE", target = "Ljava/nio/file/Files;walk(Ljava/nio/file/Path;I[Ljava/nio/file/FileVisitOption;)Ljava/util/stream/Stream;")) + @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 useCacheForLoading(Path path, int maxDepth, FileVisitOption[] fileVisitOptions) throws IOException { try { return pathStreamLoadingCache.get(Pair.of(path, maxDepth)).stream(); @@ -45,9 +45,9 @@ public class VanillaPackMixin { } } - @Inject(method = "resourceExists", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResource(Ljava/lang/String;)Ljava/net/URL;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + @Inject(method = "hasResource", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResource(Ljava/lang/String;)Ljava/net/URL;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) private void useCacheForExistence(ResourcePackType type, ResourceLocation location, CallbackInfoReturnable cir, String path) { - FileSystem fs = FILE_SYSTEMS_BY_PACK_TYPE.get(type); + FileSystem fs = JAR_FILESYSTEM_BY_TYPE.get(type); cir.setReturnValue(Files.exists(fs.getPath(path))); } } diff --git a/src/main/java/org/embeddedt/modernfix/util/DummyServerConfiguration.java b/src/main/java/org/embeddedt/modernfix/util/DummyServerConfiguration.java index dd64704c..77bef0f8 100644 --- a/src/main/java/org/embeddedt/modernfix/util/DummyServerConfiguration.java +++ b/src/main/java/org/embeddedt/modernfix/util/DummyServerConfiguration.java @@ -18,53 +18,53 @@ import java.util.Set; public class DummyServerConfiguration implements IServerConfiguration { @Override - public DatapackCodec getDatapackCodec() { - return DatapackCodec.VANILLA_CODEC; + public DatapackCodec getDataPackConfig() { + return DatapackCodec.DEFAULT; } @Override - public void setDatapackCodec(DatapackCodec codec) { + public void setDataPackConfig(DatapackCodec codec) { } @Override - public boolean isModded() { + public boolean wasModded() { return true; } @Override - public Set getServerBranding() { + public Set getKnownServerBrands() { return ImmutableSet.of("forge"); } @Override - public void addServerBranding(String name, boolean isModded) { + public void setModdedInfo(String name, boolean isModded) { } @Nullable @Override - public CompoundNBT getCustomBossEventData() { + public CompoundNBT getCustomBossEvents() { return null; } @Override - public void setCustomBossEventData(@Nullable CompoundNBT nbt) { + public void setCustomBossEvents(@Nullable CompoundNBT nbt) { } @Override - public IServerWorldInfo getServerWorldInfo() { + public IServerWorldInfo overworldData() { return null; } @Override - public WorldSettings getWorldSettings() { + public WorldSettings getLevelSettings() { return null; } @Override - public CompoundNBT serialize(DynamicRegistries registries, @Nullable CompoundNBT hostPlayerNBT) { + public CompoundNBT createTag(DynamicRegistries registries, @Nullable CompoundNBT hostPlayerNBT) { return null; } @@ -74,12 +74,12 @@ public class DummyServerConfiguration implements IServerConfiguration { } @Override - public int getStorageVersionId() { + public int getVersion() { return 0; } @Override - public String getWorldName() { + public String getLevelName() { return null; } @@ -94,7 +94,7 @@ public class DummyServerConfiguration implements IServerConfiguration { } @Override - public boolean areCommandsAllowed() { + public boolean getAllowCommands() { return false; } @@ -119,32 +119,32 @@ public class DummyServerConfiguration implements IServerConfiguration { } @Override - public GameRules getGameRulesInstance() { + public GameRules getGameRules() { return null; } @Override - public CompoundNBT getHostPlayerNBT() { + public CompoundNBT getLoadedPlayerTag() { return null; } @Override - public CompoundNBT getDragonFightData() { + public CompoundNBT endDragonFightData() { return null; } @Override - public void setDragonFightData(CompoundNBT nbt) { + public void setEndDragonFightData(CompoundNBT nbt) { } @Override - public DimensionGeneratorSettings getDimensionGeneratorSettings() { + public DimensionGeneratorSettings worldGenSettings() { return null; } @Override - public Lifecycle getLifecycle() { + public Lifecycle worldGenSettingsLifecycle() { return Lifecycle.stable(); } }