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);
}
}
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();
}
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());
}
}
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);
}
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);
}
Aggregations