Search in sources :

Example 41 with CrashReport

use of net.minecraft.crash.CrashReport in project Hyperium by HyperiumClient.

the class Hyperium method init.

/**
 * Initialize all local variables
 * <p>
 * Create / check for important things that need to be loaded
 * before the client officially allows the player to use it.
 *
 * @param event Fired on startup, after screen is displayed {@link InitializationEvent}
 */
@InvokeEvent(priority = Priority.HIGH)
public void init(InitializationEvent event) {
    try {
        // Create the network handler, register it in config, then check for a LoginReply
        Multithreading.runAsync(() -> {
            networkHandler = new NetworkHandler();
            CONFIG.register(networkHandler);
            this.client = new NettyClient(networkHandler);
            UniversalNetty.getInstance().getPacketManager().register(new LoginReplyHandler());
        });
        // Initialize notifications
        notification = new NotificationCenter();
        // Get the build id
        createBuildId();
        Hyperium.LOGGER.info("Hyperium Build ID: {}", BUILD_ID);
        // Check for if the user is in a developers environment
        checkForDevEnvironment();
        // Initialize cosmetics
        cosmetics = new HyperiumCosmetics();
        // If it's the users first launch, create a folder to store their lock file in
        firstLaunch = new File(folder.getAbsolutePath() + "/accounts").mkdirs();
        // Determine if the users ever charge backed, if they have, they won't be allowed to launch
        new ChargebackStopper();
        // Create a lock file if the user accepts the TOS
        this.acceptedTos = new File(folder.getAbsolutePath() + "/accounts/" + Minecraft.getMinecraft().getSession().getPlayerID() + ".lck").exists();
        SplashProgress.setProgress(5, I18n.format("splashprogress.loadinghandlers"));
        // Initialize handlers
        handlers = new HyperiumHandlers();
        handlers.postInit();
        SplashProgress.setProgress(6, I18n.format("splashprogress.registeringlisteners"));
        // Register events
        EventBus.INSTANCE.register(new ToggleSprintContainer());
        EventBus.INSTANCE.register(notification);
        EventBus.INSTANCE.register(CompactChat.getInstance());
        EventBus.INSTANCE.register(CONFIG.register(FPSLimiter.getInstance()));
        EventBus.INSTANCE.register(confirmation);
        EventBus.INSTANCE.register(statTrack);
        CONFIG.register(statTrack);
        CONFIG.register(new ToggleSprintContainer());
        SplashProgress.setProgress(7, I18n.format("splashprogress.startinghyperium"));
        LOGGER.info("[Hyperium] Started!");
        // Set the window title
        Display.setTitle("Hyperium " + Metadata.getVersion());
        SplashProgress.setProgress(8, I18n.format("splashprogress.registeringconfiguration"));
        // Register the settings
        Settings.register();
        CONFIG.register(new ColourOptions());
        SplashProgress.setProgress(9, I18n.format("splashprogress.registeringcommands"));
        // Register all the default commands
        registerCommands();
        // Initialize the Purchase API
        EventBus.INSTANCE.register(PurchaseApi.getInstance());
        SplashProgress.setProgress(10, I18n.format("splashprogress.loadingintegrations"));
        // Register mods & addons
        modIntegration = new HyperiumModIntegration();
        internalAddons = new InternalAddons();
        // Fetch Hyperium staff members
        fetchStaffMembers();
        // Add a thread for shutdowns
        Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
        // Load
        richPresenceManager.load();
        // Check if the user has accepted the TOS, if they have, check the Hyperium status
        if (acceptedTos) {
            sk1erMod = new Sk1erMod("hyperium", Metadata.getVersion(), object -> {
                if (object.has("enabled") && !object.optBoolean("enabled")) {
                    handlers.getHyperiumCommandHandler().clear();
                }
            });
            sk1erMod.checkStatus();
        }
        SplashProgress.setProgress(11, I18n.format("splashprogress.finishing"));
        // Load the previous chat session
        loadPreviousChatFile();
        // Fetch the current version
        fetchVersion();
        // Check if the user is running Optifine
        if (AddonCheckerUtil.isUsingOptifine()) {
            // 🦀
            optifineInstalled = true;
        }
        // Print every loaded addon
        collectAddons();
        LOGGER.info("Hyperium loaded in {} seconds", (System.currentTimeMillis() - launchTime) / 1000F);
    } catch (Throwable t) {
        // If an issue is caught, crash the game
        Minecraft.getMinecraft().crashed(new CrashReport("Hyperium Startup Failure", t));
    }
}
Also used : StaffUtils(cc.hyperium.utils.StaffUtils) PreInitializationEvent(cc.hyperium.event.client.PreInitializationEvent) FPSLimiter(cc.hyperium.utils.mods.FPSLimiter) InternalAddons(cc.hyperium.addons.InternalAddons) I18n(net.minecraft.client.resources.I18n) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) cc.hyperium.commands.defaults(cc.hyperium.commands.defaults) AutoGG(cc.hyperium.mods.autogg.AutoGG) Multithreading(cc.hyperium.mods.sk1ercommon.Multithreading) AddonMinecraftBootstrap(cc.hyperium.internal.addons.AddonMinecraftBootstrap) UniversalNetty(cc.hyperium.netty.UniversalNetty) HyperiumLocale(cc.hyperium.mixinsimp.client.resources.HyperiumLocale) LoginReplyHandler(cc.hyperium.network.LoginReplyHandler) InvokeEvent(cc.hyperium.event.InvokeEvent) Display(org.lwjgl.opengl.Display) HyperiumHandlers(cc.hyperium.handlers.HyperiumHandlers) HyperiumCommandHandler(cc.hyperium.commands.HyperiumCommandHandler) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ChargebackStopper(cc.hyperium.handlers.handlers.purchase.ChargebackStopper) GameShutDownEvent(cc.hyperium.event.client.GameShutDownEvent) NotificationCenter(cc.hyperium.gui.NotificationCenter) DefaultConfig(cc.hyperium.config.DefaultConfig) MixinMinecraft(cc.hyperium.mixins.client.MixinMinecraft) CustomLevelheadCommand(cc.hyperium.mods.levelhead.command.CustomLevelheadCommand) CompactChat(cc.hyperium.utils.mods.CompactChat) GeneralStatisticsTracking(cc.hyperium.mods.statistics.GeneralStatisticsTracking) NetworkHandler(cc.hyperium.network.NetworkHandler) AddonBootstrap(cc.hyperium.internal.addons.AddonBootstrap) ToggleSprintContainer(cc.hyperium.mods.common.ToggleSprintContainer) Minecraft(net.minecraft.client.Minecraft) Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) DiscordPresence(cc.hyperium.mods.discord.DiscordPresence) Settings(cc.hyperium.config.Settings) ConfirmationPopup(cc.hyperium.gui.ConfirmationPopup) EventBus(cc.hyperium.event.EventBus) HyperiumModIntegration(cc.hyperium.mods.HyperiumModIntegration) HyperiumCosmetics(cc.hyperium.cosmetics.HyperiumCosmetics) ColourOptions(cc.hyperium.gui.ColourOptions) UpdateUtils(cc.hyperium.utils.UpdateUtils) NettyClient(cc.hyperium.netty.NettyClient) InitializationEvent(cc.hyperium.event.client.InitializationEvent) CrashReport(net.minecraft.crash.CrashReport) AddonCheckerUtil(cc.hyperium.utils.mods.AddonCheckerUtil) java.io(java.io) AddonManifest(cc.hyperium.internal.addons.AddonManifest) Priority(cc.hyperium.event.Priority) PurchaseApi(cc.hyperium.purchases.PurchaseApi) LogManager(org.apache.logging.log4j.LogManager) ToggleSprintContainer(cc.hyperium.mods.common.ToggleSprintContainer) ColourOptions(cc.hyperium.gui.ColourOptions) Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) LoginReplyHandler(cc.hyperium.network.LoginReplyHandler) CrashReport(net.minecraft.crash.CrashReport) NotificationCenter(cc.hyperium.gui.NotificationCenter) ChargebackStopper(cc.hyperium.handlers.handlers.purchase.ChargebackStopper) HyperiumModIntegration(cc.hyperium.mods.HyperiumModIntegration) NettyClient(cc.hyperium.netty.NettyClient) HyperiumHandlers(cc.hyperium.handlers.HyperiumHandlers) NetworkHandler(cc.hyperium.network.NetworkHandler) HyperiumCosmetics(cc.hyperium.cosmetics.HyperiumCosmetics) InternalAddons(cc.hyperium.addons.InternalAddons) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 42 with CrashReport

use of net.minecraft.crash.CrashReport in project Hyperium by HyperiumClient.

the class MixinTextureManager method loadTexture.

/**
 * @author asbyth
 * @reason fix missing textures
 */
@Overwrite
public boolean loadTexture(ResourceLocation textureLocation, ITextureObject textureObject) {
    boolean loaded = true;
    ITextureObject textureCopy = textures.get(textureLocation.toString());
    if (textureCopy != null)
        textureObject = textureCopy;
    try {
        textureObject.loadTexture(Minecraft.getMinecraft().getResourceManager());
    } catch (IOException e) {
        logger.warn("Failed to load texture {}", textureLocation, e);
        textureObject = TextureUtil.missingTexture;
        mapTextureObjects.put(textureLocation, textureObject);
        loaded = false;
    } catch (Throwable e) {
        ITextureObject object = textureObject;
        CrashReport report = CrashReport.makeCrashReport(e, "Registering texture");
        CrashReportCategory category = report.makeCategory("Resource location being registered");
        category.addCrashSection("Resource location", textureLocation);
        category.addCrashSectionCallable("Texture object class", () -> object.getClass().getName());
        throw new ReportedException(report);
    }
    mapTextureObjects.put(textureLocation, textureObject);
    return loaded;
}
Also used : CrashReport(net.minecraft.crash.CrashReport) IOException(java.io.IOException) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 43 with CrashReport

use of net.minecraft.crash.CrashReport in project OreSpawn by MinecraftModDevelopmentMods.

the class PresetsStorage method load.

public void load(Path inputFile) {
    JsonParser p = new JsonParser();
    JsonElement parsed = null;
    try (BufferedReader r = Files.newBufferedReader(inputFile)) {
        parsed = p.parse(r);
    } catch (IOException e) {
        CrashReport report = CrashReport.makeCrashReport(e, "Failed reading presets from" + inputFile.toString());
        report.getCategory().addCrashSection(ORE_SPAWN_VERSION, Constants.VERSION);
        OreSpawn.LOGGER.info(report.getCompleteReport());
    } catch (JsonIOException | JsonSyntaxException e) {
        CrashReport report = CrashReport.makeCrashReport(e, "JSON Parsing Error in " + inputFile.toString());
        report.getCategory().addCrashSection(ORE_SPAWN_VERSION, Constants.VERSION);
        OreSpawn.LOGGER.info(report.getCompleteReport());
    }
    if (parsed != null) {
        parsed.getAsJsonObject().entrySet().stream().forEach(entry -> {
            String section = entry.getKey();
            entry.getValue().getAsJsonObject().entrySet().stream().forEach(sect -> this.setSymbolSection(section, sect.getKey(), sect.getValue()));
        });
    }
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) JsonIOException(com.google.gson.JsonIOException) JsonElement(com.google.gson.JsonElement) CrashReport(net.minecraft.crash.CrashReport) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) JsonIOException(com.google.gson.JsonIOException) JsonParser(com.google.gson.JsonParser)

Example 44 with CrashReport

use of net.minecraft.crash.CrashReport in project OreSpawn by MinecraftModDevelopmentMods.

the class ReplacementsRegistry method saveFile.

public void saveFile(String modName) {
    JsonObject outs = new JsonObject();
    registry.getEntries().stream().filter(ent -> ent.getKey().getResourceDomain().equals(modName)).forEach(ent -> {
        JsonArray entry = new JsonArray();
        IReplacementEntry workVal = ent.getValue();
        workVal.getEntries().stream().forEach(bs -> {
            JsonObject block = new JsonObject();
            block.addProperty(Constants.ConfigNames.BLOCK, bs.getBlock().getRegistryName().toString());
            if (!bs.toString().matches("\\[normal\\]")) {
                block.addProperty(Constants.ConfigNames.STATE, bs.toString().replaceAll("[\\[\\]]", ""));
            }
            entry.add(block);
        });
        outs.add(ent.getKey().toString(), entry);
    });
    Path p = Paths.get("config", "orespawn3", "sysconfig", String.format("replacements-%s.json", modName));
    try (BufferedWriter w = Files.newBufferedWriter(p)) {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        String ov = gson.toJson(outs);
        w.write(ov);
    } catch (IOException e) {
        CrashReport report = CrashReport.makeCrashReport(e, String.format("Failed writing replacements file  %s", p.toAbsolutePath().toString()));
        report.getCategory().addCrashSection("OreSpawn Version", Constants.VERSION);
        OreSpawn.LOGGER.info(report.getCompleteReport());
    }
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) StateUtil(com.mcmoddev.orespawn.util.StateUtil) JsonParser(com.google.gson.JsonParser) GsonBuilder(com.google.gson.GsonBuilder) IReplacementEntry(com.mcmoddev.orespawn.api.os3.IReplacementEntry) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) Charset(java.nio.charset.Charset) OreDictionary(net.minecraftforge.oredict.OreDictionary) Gson(com.google.gson.Gson) RegistryBuilder(net.minecraftforge.registries.RegistryBuilder) Map(java.util.Map) IForgeRegistryModifiable(net.minecraftforge.registries.IForgeRegistryModifiable) LinkedList(java.util.LinkedList) Path(java.nio.file.Path) ImmutableMap(com.google.common.collect.ImmutableMap) Files(java.nio.file.Files) OreSpawn(com.mcmoddev.orespawn.OreSpawn) BufferedWriter(java.io.BufferedWriter) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) ReplacementEntry(com.mcmoddev.orespawn.impl.os3.ReplacementEntry) Collectors(java.util.stream.Collectors) IBlockState(net.minecraft.block.state.IBlockState) CrashReport(net.minecraft.crash.CrashReport) JsonArray(com.google.gson.JsonArray) List(java.util.List) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) Collections(java.util.Collections) JsonArray(com.google.gson.JsonArray) Path(java.nio.file.Path) IReplacementEntry(com.mcmoddev.orespawn.api.os3.IReplacementEntry) GsonBuilder(com.google.gson.GsonBuilder) CrashReport(net.minecraft.crash.CrashReport) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 45 with CrashReport

use of net.minecraft.crash.CrashReport in project OreSpawn by MinecraftModDevelopmentMods.

the class ReplacementsRegistry method loadFile.

@SuppressWarnings("deprecation")
public void loadFile(Path file) {
    JsonParser parser = new JsonParser();
    JsonObject elements;
    String rawJson;
    try {
        rawJson = FileUtils.readFileToString(file.toFile(), Charset.defaultCharset());
    } catch (IOException e) {
        CrashReport report = CrashReport.makeCrashReport(e, "Failed reading config " + file.getFileName());
        report.getCategory().addCrashSection(ORE_SPAWN_VERSION, Constants.VERSION);
        OreSpawn.LOGGER.info(report.getCompleteReport());
        return;
    }
    elements = parser.parse(rawJson).getAsJsonObject();
    elements.entrySet().stream().forEach(elem -> {
        String entName = elem.getKey();
        JsonArray entries = elem.getValue().getAsJsonArray();
        List<IBlockState> blocks = new LinkedList<>();
        for (JsonElement e : entries) {
            JsonObject asObj = e.getAsJsonObject();
            String blockName = asObj.get(Constants.ConfigNames.NAME).getAsString().toLowerCase();
            // is this an OreDictionary entry ?
            if (blockName.startsWith("ore:")) {
                // yes, it is
                String oreDictName = blockName.split(":")[1];
                OreDictionary.getOres(oreDictName).forEach(iS -> {
                    if (iS.getMetadata() != 0) {
                        blocks.add(Block.getBlockFromItem(iS.getItem()).getStateFromMeta(iS.getMetadata()));
                    } else {
                        blocks.add(Block.getBlockFromItem(iS.getItem()).getDefaultState());
                    }
                });
            } else {
                String state = null;
                ResourceLocation blockRL = new ResourceLocation(blockName);
                Block theBlock = ForgeRegistries.BLOCKS.getValue(blockRL);
                if (asObj.has(Constants.ConfigNames.METADATA)) {
                    // has metadata
                    int meta = asObj.get(Constants.ConfigNames.METADATA).getAsInt();
                    blocks.add(theBlock.getStateFromMeta(meta));
                } else if (asObj.has(Constants.ConfigNames.STATE)) {
                    // has a state
                    state = asObj.get(Constants.ConfigNames.STATE).getAsString();
                    blocks.add(StateUtil.deserializeState(theBlock, state));
                } else {
                    // use the default state
                    blocks.add(theBlock.getDefaultState());
                }
            }
        }
        IReplacementEntry replacer = new ReplacementEntry("orespawn:" + entName, blocks);
        registry.register(replacer);
    });
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) CrashReport(net.minecraft.crash.CrashReport) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException) IReplacementEntry(com.mcmoddev.orespawn.api.os3.IReplacementEntry) ReplacementEntry(com.mcmoddev.orespawn.impl.os3.ReplacementEntry) LinkedList(java.util.LinkedList) JsonArray(com.google.gson.JsonArray) IReplacementEntry(com.mcmoddev.orespawn.api.os3.IReplacementEntry) JsonElement(com.google.gson.JsonElement) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) JsonParser(com.google.gson.JsonParser)

Aggregations

CrashReport (net.minecraft.crash.CrashReport)54 CrashReportCategory (net.minecraft.crash.CrashReportCategory)37 ReportedException (net.minecraft.util.ReportedException)36 IOException (java.io.IOException)15 BlockPos (net.minecraft.util.math.BlockPos)11 IBlockState (net.minecraft.block.state.IBlockState)7 Chunk (net.minecraft.world.chunk.Chunk)7 JsonArray (com.google.gson.JsonArray)6 JsonElement (com.google.gson.JsonElement)6 JsonObject (com.google.gson.JsonObject)6 JsonParser (com.google.gson.JsonParser)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 World (net.minecraft.world.World)5 Gson (com.google.gson.Gson)4 GsonBuilder (com.google.gson.GsonBuilder)4 Path (java.nio.file.Path)4 Block (net.minecraft.block.Block)4 BufferedWriter (java.io.BufferedWriter)3 JsonIOException (com.google.gson.JsonIOException)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2