Search in sources :

Example 36 with CrashReport

use of net.minecraft.crash.CrashReport in project Wurst-MC-1.12 by Wurst-Imperium.

the class Mod method setBlocked.

public void setBlocked(boolean blocked) {
    this.blocked = blocked;
    active = enabled && !blocked;
    if (!(this instanceof NavigatorMod))
        UIRenderer.modList.updateState(this);
    if (enabled)
        try {
            onToggle();
            if (blocked)
                onDisable();
            else
                onEnable();
        } catch (Throwable e) {
            CrashReport report = CrashReport.makeCrashReport(e, "Toggling Wurst mod");
            CrashReportCategory category = report.makeCategory("Affected mod");
            category.setDetail("Mod name", () -> name);
            category.setDetail("Attempted action", () -> blocked ? "Block" : "Unblock");
            throw new ReportedException(report);
        }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) NavigatorMod(net.wurstclient.features.mods.other.NavigatorMod) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 37 with CrashReport

use of net.minecraft.crash.CrashReport in project Wurst-MC-1.12 by Wurst-Imperium.

the class Mod method setEnabled.

public final void setEnabled(boolean enabled) {
    if (this.enabled == enabled)
        return;
    this.enabled = enabled;
    active = enabled && !blocked;
    if (!(this instanceof NavigatorMod))
        UIRenderer.modList.updateState(this);
    if (blocked && enabled)
        return;
    try {
        onToggle();
        if (enabled)
            onEnable();
        else
            onDisable();
    } catch (Throwable e) {
        CrashReport report = CrashReport.makeCrashReport(e, "Toggling Wurst mod");
        CrashReportCategory category = report.makeCategory("Affected mod");
        category.setDetail("Mod name", () -> name);
        category.setDetail("Attempted action", () -> enabled ? "Enable" : "Disable");
        throw new ReportedException(report);
    }
    if (stateSaved)
        ConfigFiles.MODS.save();
}
Also used : CrashReport(net.minecraft.crash.CrashReport) NavigatorMod(net.wurstclient.features.mods.other.NavigatorMod) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 38 with CrashReport

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

the class CommonProxy method dumpMaterials.

@SuppressWarnings("unused")
private void dumpMaterials() {
    final Gson gson = new GsonBuilder().setPrettyPrinting().create();
    final JsonObject materials = new JsonObject();
    Materials.getAllMaterials().forEach(material -> {
        JsonObject currentMaterial = new JsonObject();
        JsonArray blocks = new JsonArray();
        JsonArray items = new JsonArray();
        material.getBlockRegistry().entrySet().stream().forEach(ent -> {
            JsonObject entry = new JsonObject();
            entry.addProperty("name", ent.getKey());
            entry.addProperty("ref", ent.getValue().toString());
            blocks.add(entry);
        });
        material.getItemRegistry().entrySet().stream().forEach(ent -> {
            JsonObject entry = new JsonObject();
            entry.addProperty("name", ent.getKey());
            entry.addProperty("ref", ent.getValue().toString());
            items.add(entry);
        });
        currentMaterial.add("blocks", blocks);
        currentMaterial.add("items", items);
        materials.add(material.getName(), currentMaterial);
    });
    final String out = gson.toJson(materials);
    Path p = Paths.get("logs", "mmd_materials_dump.json");
    try (BufferedWriter bw = Files.newBufferedWriter(p, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
        bw.write(out);
    } catch (IOException e) {
        CrashReport report = CrashReport.makeCrashReport(e, String.format("Unable to write dump of MMDMaterial registry to %s", p.toFile().getAbsolutePath()));
        report.getCategory().addCrashSection("BaseMetals Version", "2.5.0-beta4");
        BaseMetals.logger.fatal(report.getCompleteReport());
    }
}
Also used : JsonArray(com.google.gson.JsonArray) Path(java.nio.file.Path) GsonBuilder(com.google.gson.GsonBuilder) CrashReport(net.minecraft.crash.CrashReport) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 39 with CrashReport

use of net.minecraft.crash.CrashReport in project ForestryMC by ForestryMC.

the class TextureMapForestry method loadTextureAtlas.

@Override
public void loadTextureAtlas(IResourceManager resourceManager) {
    int i = Minecraft.getGLMaximumTextureSize();
    Stitcher stitcher = new Stitcher(i, i, 0, 0);
    this.mapUploadedSprites.clear();
    this.listAnimatedSprites.clear();
    ProgressManager.ProgressBar bar = ProgressManager.push("Texture stitching", this.mapRegisteredSprites.size());
    for (Map.Entry<String, TextureAtlasSprite> entry : this.mapRegisteredSprites.entrySet()) {
        TextureAtlasSprite textureatlassprite = entry.getValue();
        ResourceLocation resourcelocation = this.getResourceLocation(textureatlassprite);
        bar.step(resourcelocation.getResourcePath());
        IResource iresource = null;
        if (textureatlassprite.hasCustomLoader(resourceManager, resourcelocation)) {
            if (textureatlassprite.load(resourceManager, resourcelocation, l -> mapRegisteredSprites.get(l.toString()))) {
                continue;
            }
        } else
            try {
                PngSizeInfo pngsizeinfo = PngSizeInfo.makeFromResource(resourceManager.getResource(resourcelocation));
                iresource = resourceManager.getResource(resourcelocation);
                boolean flag = iresource.getMetadata("animation") != null;
                textureatlassprite.loadSprite(pngsizeinfo, flag);
            } catch (RuntimeException runtimeexception) {
                FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage());
                continue;
            } catch (IOException ioexception) {
                FMLClientHandler.instance().trackMissingTexture(resourcelocation);
                continue;
            } finally {
                IOUtils.closeQuietly(iresource);
            }
        stitcher.addSprite(textureatlassprite);
    }
    ProgressManager.pop(bar);
    this.missingImage.generateMipmaps(0);
    stitcher.addSprite(this.missingImage);
    bar = ProgressManager.push("Texture creation", 2);
    bar.step("Stitching");
    stitcher.doStitch();
    Log.info("Created: {}x{} {}-atlas", stitcher.getCurrentWidth(), stitcher.getCurrentHeight(), this.basePath);
    bar.step("Allocating GL texture");
    TextureUtil.allocateTextureImpl(this.getGlTextureId(), 0, stitcher.getCurrentWidth(), stitcher.getCurrentHeight());
    Map<String, TextureAtlasSprite> map = Maps.newHashMap(this.mapRegisteredSprites);
    ProgressManager.pop(bar);
    bar = ProgressManager.push("Texture mipmap and upload", stitcher.getStichSlots().size());
    for (TextureAtlasSprite textureatlassprite1 : stitcher.getStichSlots()) {
        bar.step(textureatlassprite1.getIconName());
        if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) {
            String s = textureatlassprite1.getIconName();
            map.remove(s);
            this.mapUploadedSprites.put(s, textureatlassprite1);
            try {
                TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false);
            } catch (Throwable throwable) {
                CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
                CrashReportCategory crashreportcategory = crashreport.makeCategory("Texture being stitched together");
                crashreportcategory.addCrashSection("Atlas path", this.basePath);
                crashreportcategory.addCrashSection("Sprite", textureatlassprite1);
                throw new ReportedException(crashreport);
            }
            if (textureatlassprite1.hasAnimationMetadata()) {
                this.listAnimatedSprites.add(textureatlassprite1);
            }
        }
    }
    for (TextureAtlasSprite textureatlassprite2 : map.values()) {
        textureatlassprite2.copyFrom(this.missingImage);
    }
    ProgressManager.pop(bar);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) CrashReport(net.minecraft.crash.CrashReport) IOException(java.io.IOException) Stitcher(net.minecraft.client.renderer.texture.Stitcher) ProgressManager(net.minecraftforge.fml.common.ProgressManager) ResourceLocation(net.minecraft.util.ResourceLocation) PngSizeInfo(net.minecraft.client.renderer.texture.PngSizeInfo) TextureMap(net.minecraft.client.renderer.texture.TextureMap) Map(java.util.Map) IResource(net.minecraft.client.resources.IResource) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 40 with CrashReport

use of net.minecraft.crash.CrashReport in project ForestryMC by ForestryMC.

the class ChunkThread method run.

@Override
public void run() {
    Log.info("Starting greenhouse thread");
    while (!this.stop) {
        try {
            long startTime = System.currentTimeMillis();
            if (isClient) {
                handleClientWorld();
            } else {
                for (World world : DimensionManager.getWorlds()) {
                    handleDirtyChunks(world);
                }
            }
            long executionTime = System.currentTimeMillis() - startTime;
            try {
                if (executionTime > INTERVAL) {
                    Log.warning("GREENHOUSE TAKING " + (executionTime - INTERVAL) + " ms LONGER THAN NORMAL");
                }
                Thread.sleep(Math.max(1L, INTERVAL - executionTime));
            } catch (InterruptedException e) {
            }
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Update Greenhouse change");
            throw new ReportedException(crashreport);
        }
    }
    Log.info("Stopping climate thread");
    GreenhouseBlockManager.setThread(null, isClient);
}
Also used : CrashReport(net.minecraft.crash.CrashReport) World(net.minecraft.world.World) ReportedException(net.minecraft.util.ReportedException)

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