diff --git a/src/main/java/net/frozenblock/lib/menu/mixin/SplashManagerMixin.java b/src/main/java/net/frozenblock/lib/menu/mixin/SplashManagerMixin.java index 0b21a44d3..c81fe52e5 100644 --- a/src/main/java/net/frozenblock/lib/menu/mixin/SplashManagerMixin.java +++ b/src/main/java/net/frozenblock/lib/menu/mixin/SplashManagerMixin.java @@ -18,10 +18,10 @@ package net.frozenblock.lib.menu.mixin; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import java.io.BufferedReader; import java.io.IOException; import java.util.List; -import java.util.stream.Collectors; import net.frozenblock.lib.menu.api.SplashTextAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.SplashManager; @@ -34,7 +34,6 @@ 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; @Mixin(SplashManager.class) public class SplashManagerMixin { @@ -52,34 +51,33 @@ private void apply(List object, ResourceManager resourceManager, Profile } } - @Inject(method = "prepare(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)Ljava/util/List;", at = @At("RETURN")) - public void addSplashFiles(ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfoReturnable> info) { + @ModifyReturnValue(method = "prepare(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)Ljava/util/List;", at = @At("RETURN")) + public List addSplashFiles(List original, ResourceManager resourceManager, ProfilerFiller profiler) { for (ResourceLocation splashLocation : SplashTextAPI.getSplashFiles()) { try { BufferedReader bufferedReader = Minecraft.getInstance().getResourceManager().openAsReader(splashLocation); List var4; try { - var4 = bufferedReader.lines().map(String::trim).filter((splashText) -> splashText.hashCode() != 125780783).collect(Collectors.toList()); + var4 = bufferedReader.lines().map(String::trim).filter(splashText -> splashText.hashCode() != 125780783).toList(); } catch (Throwable var7) { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (Throwable var6) { - var7.addSuppressed(var6); - } - } + try { + bufferedReader.close(); + } catch (Throwable var6) { + var7.addSuppressed(var6); + } - throw var7; + throw var7; } bufferedReader.close(); - info.getReturnValue().addAll(var4); + original.addAll(var4); } catch (IOException ignored) { } } + return original; } } diff --git a/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/MinecraftServerMixin.java b/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/MinecraftServerMixin.java index 3d4178e17..6d5238f52 100644 --- a/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/MinecraftServerMixin.java +++ b/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/MinecraftServerMixin.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.concurrent.CompletableFuture; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.resources.ResourceManager; import org.quiltmc.qsl.frozenblock.resource.loader.api.ResourceLoaderEvents; @@ -43,12 +44,13 @@ private void onReloadResourcesStart(Collection collection, CallbackInfoR this.getResourceManager()); } - @Inject(method = "reloadResources", at = @At("TAIL")) - private void onReloadResourcesEnd(Collection collection, CallbackInfoReturnable> cir) { - cir.getReturnValue().handleAsync((value, throwable) -> { + @ModifyReturnValue(method = "reloadResources", at = @At("RETURN")) + private CompletableFuture onReloadResourcesEnd(CompletableFuture original) { + original.handleAsync((value, throwable) -> { ResourceLoaderEvents.END_DATA_PACK_RELOAD.invoker().onEndDataPackReload((MinecraftServer) (Object) this, this.getResourceManager(), throwable); return value; }, (MinecraftServer) (Object) this); - } + return original; + } } diff --git a/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/client/IntegratedServerLoaderMixin.java b/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/client/IntegratedServerLoaderMixin.java index 915cce398..aeb5bdedb 100644 --- a/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/client/IntegratedServerLoaderMixin.java +++ b/src/main/java/org/quiltmc/qsl/frozenblock/resource/loader/mixin/client/IntegratedServerLoaderMixin.java @@ -18,14 +18,12 @@ package org.quiltmc.qsl.frozenblock.resource.loader.mixin.client; -import net.minecraft.client.gui.screens.Screen; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows; import net.minecraft.server.WorldLoader; import net.minecraft.server.WorldStem; -import net.minecraft.world.level.storage.LevelStorageSource; import org.quiltmc.qsl.frozenblock.resource.loader.api.ResourceLoaderEvents; import org.spongepowered.asm.mixin.Mixin; -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.ModifyArg; @@ -36,13 +34,6 @@ */ @Mixin(WorldOpenFlows.class) public abstract class IntegratedServerLoaderMixin { - @Shadow - private static void safeCloseAccess(LevelStorageSource.LevelStorageAccess storageSession, String worldName) { - throw new IllegalStateException("Mixin injection failed."); - } - - @Shadow - protected abstract void doLoadLevel(Screen parentScreen, String worldName, boolean safeMode, boolean requireBackup); @Inject( method = "loadWorldDataBlocking", @@ -54,16 +45,16 @@ private void onStartDataPackLoad(WorldLoader.PackConfig dataPackConfig, W ResourceLoaderEvents.START_DATA_PACK_RELOAD.invoker().onStartDataPackReload(null, null); } - @Inject( + @ModifyReturnValue( method = "loadWorldDataBlocking", at = @At("RETURN") ) - private void onEndDataPackLoad(WorldLoader.PackConfig dataPackConfig, WorldLoader.WorldDataSupplier savePropertiesSupplier, - WorldLoader.ResultFactory resultFactory, - CallbackInfoReturnable cir) { - if (cir.getReturnValue() instanceof WorldStem worldStem) { + private R onEndDataPackLoad(R original, WorldLoader.PackConfig dataPackConfig, WorldLoader.WorldDataSupplier savePropertiesSupplier, + WorldLoader.ResultFactory resultFactory) { + if (original instanceof WorldStem worldStem) { ResourceLoaderEvents.END_DATA_PACK_RELOAD.invoker().onEndDataPackReload(null, worldStem.resourceManager(), null); } + return original; } @ModifyArg( diff --git a/src/testmod/generated/data/frozenlib/tags/blocks/dripstone_can_drip.json b/src/testmod/generated/data/frozenlib/tags/blocks/dripstone_can_drip.json index 34d42073b..bc1977755 100644 --- a/src/testmod/generated/data/frozenlib/tags/blocks/dripstone_can_drip.json +++ b/src/testmod/generated/data/frozenlib/tags/blocks/dripstone_can_drip.json @@ -3,4 +3,4 @@ "values": [ "minecraft:diamond_block" ] -} +} \ No newline at end of file diff --git a/src/testmod/generated/data/frozenlib_testmod/loot_tables/test_loottable.json b/src/testmod/generated/data/frozenlib_testmod/loot_tables/test_loottable.json index 27be809a2..afcf630f8 100644 --- a/src/testmod/generated/data/frozenlib_testmod/loot_tables/test_loottable.json +++ b/src/testmod/generated/data/frozenlib_testmod/loot_tables/test_loottable.json @@ -12,4 +12,4 @@ "rolls": 1.0 } ] -} +} \ No newline at end of file diff --git a/src/testmod/generated/data/minecraft/tags/worldgen/biome/has_structure/ancient_city.json b/src/testmod/generated/data/minecraft/tags/worldgen/biome/has_structure/ancient_city.json index ae9de4604..4219c7532 100644 --- a/src/testmod/generated/data/minecraft/tags/worldgen/biome/has_structure/ancient_city.json +++ b/src/testmod/generated/data/minecraft/tags/worldgen/biome/has_structure/ancient_city.json @@ -3,4 +3,4 @@ "values": [ "minecraft:dark_forest" ] -} +} \ No newline at end of file