Skip to content

Commit

Permalink
Merge branch 'master' into 1.20.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/net/frozenblock/lib/advancement/mixin/ClientAdvancementsMixin.java
  • Loading branch information
Treetrain1 committed Dec 15, 2023
2 parents 5902a69 + 7995e4f commit a63eded
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -52,34 +51,33 @@ private void apply(List<String> 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<List<String>> info) {
@ModifyReturnValue(method = "prepare(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)Ljava/util/List;", at = @At("RETURN"))
public List<String> addSplashFiles(List<String> original, ResourceManager resourceManager, ProfilerFiller profiler) {
for (ResourceLocation splashLocation : SplashTextAPI.getSplashFiles()) {
try {
BufferedReader bufferedReader = Minecraft.getInstance().getResourceManager().openAsReader(splashLocation);

List<String> 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,12 +44,13 @@ private void onReloadResourcesStart(Collection<String> collection, CallbackInfoR
this.getResourceManager());
}

@Inject(method = "reloadResources", at = @At("TAIL"))
private void onReloadResourcesEnd(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
cir.getReturnValue().handleAsync((value, throwable) -> {
@ModifyReturnValue(method = "reloadResources", at = @At("RETURN"))
private CompletableFuture<Void> onReloadResourcesEnd(CompletableFuture<Void> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand All @@ -54,16 +45,16 @@ private <D, R> void onStartDataPackLoad(WorldLoader.PackConfig dataPackConfig, W
ResourceLoaderEvents.START_DATA_PACK_RELOAD.invoker().onStartDataPackReload(null, null);
}

@Inject(
@ModifyReturnValue(
method = "loadWorldDataBlocking",
at = @At("RETURN")
)
private <D, R> void onEndDataPackLoad(WorldLoader.PackConfig dataPackConfig, WorldLoader.WorldDataSupplier<D> savePropertiesSupplier,
WorldLoader.ResultFactory<D, R> resultFactory,
CallbackInfoReturnable<R> cir) {
if (cir.getReturnValue() instanceof WorldStem worldStem) {
private <D, R> R onEndDataPackLoad(R original, WorldLoader.PackConfig dataPackConfig, WorldLoader.WorldDataSupplier<D> savePropertiesSupplier,
WorldLoader.ResultFactory<D, R> resultFactory) {
if (original instanceof WorldStem worldStem) {
ResourceLoaderEvents.END_DATA_PACK_RELOAD.invoker().onEndDataPackReload(null, worldStem.resourceManager(), null);
}
return original;
}

@ModifyArg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"values": [
"minecraft:diamond_block"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"rolls": 1.0
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"values": [
"minecraft:dark_forest"
]
}
}

0 comments on commit a63eded

Please sign in to comment.