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