use of net.minecraft.crash.CrashReport in project OreSpawn by MinecraftModDevelopmentMods.
the class FeatureRegistry method writeFeatures.
public void writeFeatures(File file) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonArray root = new JsonArray();
registry.getEntries().stream().map(ent -> {
JsonObject e = new JsonObject();
e.addProperty("name", ent.getKey().getResourcePath());
e.addProperty("class", ent.getValue().getClass().getName());
return e;
}).forEach(root::add);
String json = gson.toJson(root);
try {
FileUtils.writeStringToFile(file, StringEscapeUtils.unescapeJson(json), CharEncoding.UTF_8);
} catch (IOException e) {
CrashReport report = CrashReport.makeCrashReport(e, "Failed writing config " + file.getName());
report.getCategory().addCrashSection(ORE_SPAWN_VERSION, Constants.VERSION);
OreSpawn.LOGGER.info(report.getCompleteReport());
}
}
use of net.minecraft.crash.CrashReport in project OreSpawn by MinecraftModDevelopmentMods.
the class OreSpawnWriter method saveSingle.
private static void saveSingle(Path filePath, Gson gson) {
JsonObject root = new JsonObject();
root.addProperty(ConfigNames.FILE_VERSION, "2.0");
JsonObject spawns = new JsonObject();
String k = filePath.getFileName().toString();
Path saveDir = Constants.CONFDIR.resolve("forced-saves");
Path conf = saveDir.resolve(k);
if (!saveDir.toFile().exists()) {
saveDir.toFile().mkdirs();
}
try (BufferedWriter p = Files.newBufferedWriter(conf, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) {
OreSpawn.API.getSpawnsForFile(k).stream().forEach(spawnName -> {
JsonObject thisSpawn = new JsonObject();
ISpawnEntry spawnEntry = OreSpawn.API.getSpawn(spawnName);
thisSpawn.addProperty(ConfigNames.ENABLED, spawnEntry.isEnabled());
thisSpawn.addProperty(ConfigNames.RETROGEN, spawnEntry.isRetrogen());
thisSpawn.addProperty(ConfigNames.FEATURE, spawnEntry.getFeature().getFeatureName());
thisSpawn.add(ConfigNames.DIMENSIONS, spawnEntry.getDimensions().serialize());
thisSpawn.add(ConfigNames.BIOMES, spawnEntry.getBiomes().serialize());
thisSpawn.add(ConfigNames.REPLACEMENT, spawnEntry.getMatcher().serialize());
thisSpawn.add(ConfigNames.PARAMETERS, spawnEntry.getFeature().getFeatureParameters());
spawns.add(spawnName, thisSpawn);
});
root.add(ConfigNames.SPAWNS, spawns);
p.write(gson.toJson(root));
} catch (IOException e) {
CrashReport report = CrashReport.makeCrashReport(e, "Failed writing config data " + conf.toString());
report.getCategory().addCrashSection("OreSpawn Version", Constants.VERSION);
OreSpawn.LOGGER.info(report.getCompleteReport());
}
}
use of net.minecraft.crash.CrashReport in project RFTools by McJty.
the class ElevatorTESR method renderBlock.
private static boolean renderBlock(BlockRendererDispatcher dispatcher, IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder worldRendererIn) {
try {
EnumBlockRenderType enumblockrendertype = state.getRenderType();
if (enumblockrendertype == EnumBlockRenderType.INVISIBLE) {
return false;
} else {
if (blockAccess.getWorldType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
try {
state = state.getActualState(blockAccess, pos);
} catch (Exception var8) {
}
}
switch(enumblockrendertype) {
case MODEL:
IBakedModel model = dispatcher.getModelForState(state);
state = state.getBlock().getExtendedState(state, blockAccess, pos);
return dispatcher.getBlockModelRenderer().renderModel(blockAccess, model, state, pos, worldRendererIn, false);
case ENTITYBLOCK_ANIMATED:
return false;
default:
return false;
}
}
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block in world");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being tesselated");
CrashReportCategory.addBlockInfo(crashreportcategory, pos, state.getBlock(), state.getBlock().getMetaFromState(state));
throw new ReportedException(crashreport);
}
}
use of net.minecraft.crash.CrashReport in project SpongeVanilla by SpongePowered.
the class MixinMinecraftServer method updateTimeLightAndEntities.
/**
* @author Zidane
* @reason Handles ticking the additional worlds loaded by Sponge.
*/
@Overwrite
public void updateTimeLightAndEntities() {
this.profiler.startSection("jobs");
synchronized (this.futureTaskQueue) {
while (!this.futureTaskQueue.isEmpty()) {
Util.runTask(this.futureTaskQueue.poll(), LOGGER);
}
}
this.profiler.endStartSection("levels");
// Sponge: Tick chunk loader
tickChunkLoader();
// Sponge start - Iterate over all our dimensions
for (final ObjectIterator<Int2ObjectMap.Entry<WorldServer>> it = WorldManager.worldsIterator(); it.hasNext(); ) {
Int2ObjectMap.Entry<WorldServer> entry = it.next();
final WorldServer worldServer = entry.getValue();
// Sponge end
long i = System.nanoTime();
if (entry.getIntKey() == 0 || this.getAllowNether()) {
// Sponge start - copy from SpongeCommon MixinMinecraftServer
IMixinWorldServer spongeWorld = (IMixinWorldServer) worldServer;
if (spongeWorld.getChunkGCTickInterval() > 0) {
spongeWorld.doChunkGC();
}
// Sponge end
this.profiler.startSection(worldServer.getWorldInfo().getWorldName());
if (this.tickCounter % 20 == 0) {
this.profiler.startSection("timeSync");
this.playerList.sendPacketToAllPlayersInDimension(new SPacketTimeUpdate(worldServer.getTotalWorldTime(), worldServer.getWorldTime(), worldServer.getGameRules().getBoolean("doDaylightCycle")), ((IMixinWorldServer) worldServer).getDimensionId());
this.profiler.endSection();
}
this.profiler.startSection("tick");
try {
worldServer.tick();
} catch (Throwable throwable1) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world");
worldServer.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
try {
worldServer.updateEntities();
} catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Exception ticking world entities");
worldServer.addWorldInfoToCrashReport(crashreport1);
throw new ReportedException(crashreport1);
}
this.profiler.endSection();
this.profiler.startSection("tracker");
// Sponge start - copy from SpongeCommon MixinMinecraftServer
if (spongeWorld.getChunkGCTickInterval() > 0) {
worldServer.getChunkProvider().tick();
}
// Sponge end
worldServer.getEntityTracker().tick();
this.profiler.endSection();
this.profiler.endSection();
}
// Sponge start - Write tick times to our custom map
this.worldTickTimes.get(entry.getIntKey())[this.tickCounter % 100] = System.nanoTime() - i;
// Sponge end
}
// Sponge start - Unload requested worlds
this.profiler.endStartSection("dim_unloading");
WorldManager.unloadQueuedWorlds();
// Sponge end
this.profiler.endStartSection("connection");
this.getNetworkSystem().networkTick();
this.profiler.endStartSection("players");
this.playerList.onTick();
this.profiler.endStartSection("tickables");
for (int k = 0; k < this.tickables.size(); ++k) {
this.tickables.get(k).update();
}
this.profiler.endSection();
}
use of net.minecraft.crash.CrashReport in project Wurst-MC-1.12 by Wurst-Imperium.
the class Mod method enableOnStartup.
public final void enableOnStartup() {
enabled = true;
active = enabled && !blocked;
try {
onToggle();
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", () -> "Enable on startup");
throw new ReportedException(report);
}
}
Aggregations