This commit is contained in:
embeddedt 2023-01-03 16:14:42 -05:00
parent 3534aa9fbc
commit 3d80d5a90e
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
11 changed files with 82 additions and 87 deletions

View File

@ -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')

View File

@ -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);
}
}

View File

@ -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();
}
}
}

View File

@ -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);

View File

@ -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<SaveFormat.LevelSave, DatapackCodec> worldStorageToDatapackFunction, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> quadFunction, boolean vanillaOnly, SaveFormat.LevelSave worldStorage) throws InterruptedException, ExecutionException;
@Shadow public abstract Minecraft.PackManager makeServerStem(DynamicRegistries.Impl dynamicRegistries, Function<SaveFormat.LevelSave, DatapackCodec> worldStorageToDatapackFunction, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> 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<SaveFormat.LevelSave, DatapackCodec> p_238189_2_, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> p_238189_3_, boolean p_238189_4_, SaveFormat.LevelSave p_238189_5_, CallbackInfoReturnable<Minecraft.PackManager> 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<SaveFormat.LevelSave, DatapackCodec> p_238189_2_, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> p_238189_3_, boolean p_238189_4_, SaveFormat.LevelSave p_238189_5_, CallbackInfoReturnable<Minecraft.PackManager> 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<SaveFormat.LevelSave, DatapackCodec> worldStorageToDatapackFunction, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> quadFunction, boolean vanillaOnly, SaveFormat.LevelSave levelSave, String worldName, DynamicRegistries.Impl originalRegistries, Function<SaveFormat.LevelSave, DatapackCodec> levelSaveToDatapackFunction, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> 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);
}
}
}

View File

@ -27,7 +27,7 @@ import java.util.stream.Stream;
@Mixin(ModFileResourcePack.class)
public abstract class ModFileResourcePackMixin {
@Shadow public abstract Set<String> getResourceNamespaces(ResourcePackType type);
@Shadow public abstract Set<String> getNamespaces(ResourcePackType type);
@Shadow(remap = false) @Final private ModFile modFile;
private EnumMap<ResourcePackType, Set<String>> 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<String, List<Path>> 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<Path> 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<Set<String>> 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<ResourceLocation> getAllResourceLocations(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> filter)
public Collection<ResourceLocation> getResources(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> 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

View File

@ -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<ResourceLocation, IUnbakedModel> unbakedModels;
@Shadow @Final public static ModelResourceLocation MODEL_MISSING;
@Shadow @Final private Map<ResourceLocation, IUnbakedModel> 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<Triple<ResourceLocation, TransformationMatrix, Boolean>, IBakedModel> bakedModels;
@Shadow @Final private Map<ResourceLocation, IBakedModel> topBakedModels;
@Shadow @Final private Map<ResourceLocation, IUnbakedModel> topUnbakedModels;
@Shadow @Nullable private SpriteMap atlasSet;
@Shadow @Final private Map<Triple<ResourceLocation, TransformationMatrix, Boolean>, IBakedModel> bakedCache;
@Shadow @Final private Map<ResourceLocation, IBakedModel> bakedTopLevelModels;
@Shadow @Final private Map<ResourceLocation, IUnbakedModel> topLevelModels;
private Map<ResourceLocation, BlockModel> 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<BlockModel> 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<ResourceLocation> 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<Pair<ResourceLocation, IBakedModel>> 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<ResourceLocation, TransformationMatrix, Boolean> triple = Triple.of(pair.getKey(), transform.getRotation(), transform.isUvLock());
this.bakedModels.put(triple, pair.getValue());
Triple<ResourceLocation, TransformationMatrix, Boolean> 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<ResourceLocation, IUnbakedModel> threadedUnbakedModels = new ConcurrentHashMap<>(this.unbakedModels);
ConcurrentHashMap<ResourceLocation, IUnbakedModel> threadedunbakedCache = new ConcurrentHashMap<>(this.unbakedCache);
Function<ResourceLocation, IUnbakedModel> 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<com.mojang.datafixers.util.Pair<String, String>> set = Collections.synchronizedSet(Sets.newLinkedHashSet());
String modelMissingString = MODEL_MISSING.toString();
Set<RenderMaterial> materials = this.topUnbakedModels.values().parallelStream().flatMap((unbaked) -> {
return unbaked.getTextures(safeUnbakedGetter, set).stream();
String modelMissingString = MISSING_MODEL_LOCATION.toString();
Set<RenderMaterial> 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);

View File

@ -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<RenderType.Type> TYPES;
@Shadow @Final private static ObjectOpenCustomHashSet<RenderType.Type> 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));
}
}
}

View File

@ -11,5 +11,5 @@ import java.util.function.BiFunction;
@Mixin(SaveFormat.class)
public interface SaveFormatAccessor {
@Invoker
<T> T invokeReadFromLevelData(File saveDir, BiFunction<File, DataFixer, T> levelDatReader);
<T> T invokeReadLevelData(File saveDir, BiFunction<File, DataFixer, T> levelDatReader);
}

View File

@ -29,11 +29,11 @@ import java.util.stream.Stream;
@Mixin(VanillaPack.class)
public class VanillaPackMixin {
@Shadow @Final private static Map<ResourcePackType, FileSystem> FILE_SYSTEMS_BY_PACK_TYPE;
@Shadow @Final private static Map<ResourcePackType, FileSystem> JAR_FILESYSTEM_BY_TYPE;
private static LoadingCache<Pair<Path, Integer>, List<Path>> 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<Path> 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<Boolean> 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)));
}
}

View File

@ -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<String> getServerBranding() {
public Set<String> 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();
}
}