mirror of
https://github.com/GeyserMC/Rainbow.git
synced 2025-12-19 14:59:16 +00:00
Display toast upon IO exception on client
This commit is contained in:
@@ -6,6 +6,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry;
|
||||
import net.minecraft.commands.synchronization.SingletonArgumentInfo;
|
||||
import org.geysermc.rainbow.Rainbow;
|
||||
import org.geysermc.rainbow.RainbowIO;
|
||||
import org.geysermc.rainbow.client.command.CommandSuggestionsArgumentType;
|
||||
import org.geysermc.rainbow.client.command.PackGeneratorCommand;
|
||||
import org.geysermc.rainbow.client.mapper.PackMapper;
|
||||
@@ -23,5 +24,7 @@ public class RainbowClient implements ClientModInitializer {
|
||||
|
||||
ArgumentTypeRegistry.registerArgumentType(Rainbow.getModdedLocation("command_suggestions"),
|
||||
CommandSuggestionsArgumentType.class, SingletonArgumentInfo.contextFree(CommandSuggestionsArgumentType::new));
|
||||
|
||||
RainbowIO.registerExceptionListener(new RainbowClientIOHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.geysermc.rainbow.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.toasts.SystemToast;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.geysermc.rainbow.RainbowIO;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RainbowClientIOHandler implements RainbowIO.IOExceptionListener {
|
||||
private static final SystemToast.SystemToastId TOAST_ID = new SystemToast.SystemToastId();
|
||||
|
||||
@Override
|
||||
public void error(IOException exception) {
|
||||
Minecraft.getInstance().getToastManager().addToast(new SystemToast(TOAST_ID,
|
||||
Component.translatable("toast.rainbow.io_exception.title"), Component.translatable("toast.rainbow.io_exception.description")));
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,7 @@
|
||||
"commands.rainbow.pack_created": "Created pack with name %s",
|
||||
"commands.rainbow.pack_finished_error": "Errors occurred whilst writing the pack to disk!",
|
||||
"commands.rainbow.pack_finished_successfully": "Wrote pack to disk",
|
||||
"commands.rainbow.stopped_automatic_mapping": "Stopped automatic mapping of custom items"
|
||||
"commands.rainbow.stopped_automatic_mapping": "Stopped automatic mapping of custom items",
|
||||
"toast.rainbow.io_exception.description": "Please check your game logs for more information",
|
||||
"toast.rainbow.io_exception.title": "A filesystem error occurred in Rainbow!"
|
||||
}
|
||||
Reference in New Issue
Block a user