fix reloadable server resources

This commit is contained in:
yrsegal@gmail.com 2022-05-26 13:17:27 -04:00
parent 0858c7664f
commit 7eea96ec60

View file

@ -12,12 +12,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
@Mixin(ReloadableServerResources.class)
public class MixinReloadableServerResources {
@Inject(method = "lambda$loadResources$0", at = @At("RETURN"))
private static void onLoadResources(ReloadableServerResources rsr, Object whoKnows,
CallbackInfoReturnable<ReloadableServerResources> cir) {
@Inject(method = "loadResources", at = @At("RETURN"), cancellable = true)
private static void onLoadResources(CallbackInfoReturnable<CompletableFuture<ReloadableServerResources>> cir) {
cir.setReturnValue(cir.getReturnValue().thenApply((rsr) -> {
var amethystTable = rsr.getLootTables().get(Blocks.AMETHYST_CLUSTER.getLootTable());
var theCoolerAmethystTable = (AccessorLootTable) amethystTable;
var oldFuncs = theCoolerAmethystTable.hex$getFunctions();
@ -30,5 +31,7 @@ public class MixinReloadableServerResources {
} else {
HexAPI.LOGGER.warn("{} was not found?", HexLootHandler.FUNC_AMETHYST_SHARD_REDUCER);
}
return rsr;
}));
}
}