Search in sources :

Example 51 with CrashReport

use of net.minecraft.crash.CrashReport in project Galacticraft by micdoodle8.

the class BlockVec3Dim method getBlockState_noChunkLoad.

/**
 * Get block ID at the BlockVec3 coordinates without forcing a chunk load.
 *
 * @return the block ID, or null if the y-coordinate is less than 0 or
 * greater than 256 or the x or z is outside the Minecraft worldmap.
 * Returns Blocks.BEDROCK if the coordinates being checked are in an
 * unloaded chunk
 */
public IBlockState getBlockState_noChunkLoad() {
    if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) {
        return null;
    }
    World world = getWorldForId(this.dim);
    if (world == null)
        return null;
    int chunkx = this.x >> 4;
    int chunkz = this.z >> 4;
    try {
        if (world.getChunkProvider().getLoadedChunk(chunkx, chunkz) != null) {
            // this will be within the same chunk
            if (BlockVec3Dim.chunkCacheX == chunkx && BlockVec3Dim.chunkCacheZ == chunkz && BlockVec3Dim.chunkCacheDim == world.provider.getDimension() && BlockVec3Dim.chunkCached.isLoaded()) {
                return BlockVec3Dim.chunkCached.getBlockState(this.x & 15, this.y, this.z & 15);
            } else {
                Chunk chunk = null;
                chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
                BlockVec3Dim.chunkCached = chunk;
                BlockVec3Dim.chunkCacheDim = world.provider.getDimension();
                BlockVec3Dim.chunkCacheX = chunkx;
                BlockVec3Dim.chunkCacheZ = chunkz;
                return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
            }
        }
        // Chunk doesn't exist - meaning, it is not loaded
        return Blocks.BEDROCK.getDefaultState();
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Oxygen Sealer thread: Exception getting block type in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates");
        crashreportcategory.addCrashSection("Location", CrashReportCategory.getCoordinateInfo(new BlockPos(this.x, this.y, this.z)));
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 52 with CrashReport

use of net.minecraft.crash.CrashReport in project Galacticraft by micdoodle8.

the class BlockVec3 method getBlockState.

/**
 * Get block ID at the BlockVec3 coordinates, with a forced chunk load if
 * the coordinates are unloaded.
 *
 * @param world
 * @return the block ID, or null if the y-coordinate is less than 0 or
 * greater than 256 or the x or z is outside the Minecraft worldmap.
 */
public IBlockState getBlockState(World world) {
    if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) {
        return null;
    }
    int chunkx = this.x >> 4;
    int chunkz = this.z >> 4;
    try {
        if (world.isRemote) {
            if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.provider.getDimension() && BlockVec3.chunkCached_Client.isLoaded()) {
                return BlockVec3.chunkCached_Client.getBlockState(this.x & 15, this.y, this.z & 15);
            } else {
                final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
                BlockVec3.chunkCached_Client = chunk;
                BlockVec3.chunkCacheDim_Client = world.provider.getDimension();
                BlockVec3.chunkCacheX_Client = chunkx;
                BlockVec3.chunkCacheZ_Client = chunkz;
                return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
            }
        } else {
            // this will be within the same chunk
            if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.provider.getDimension() && BlockVec3.chunkCached.isLoaded()) {
                return BlockVec3.chunkCached.getBlockState(this.x & 15, this.y, this.z & 15);
            } else {
                final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
                BlockVec3.chunkCached = chunk;
                BlockVec3.chunkCacheDim = world.provider.getDimension();
                BlockVec3.chunkCacheX = chunkx;
                BlockVec3.chunkCacheZ = chunkz;
                return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
            }
        }
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Oxygen Sealer thread: Exception getting block type in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates");
        crashreportcategory.addCrashSection("Location", CrashReportCategory.getCoordinateInfo(new BlockPos(this.x, this.y, this.z)));
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) BlockPos(net.minecraft.util.math.BlockPos) Chunk(net.minecraft.world.chunk.Chunk) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 53 with CrashReport

use of net.minecraft.crash.CrashReport in project Galacticraft by micdoodle8.

the class BlockVec3 method getBlockState_noChunkLoad.

/**
 * Get block ID at the BlockVec3 coordinates without forcing a chunk load.
 *
 * @param world
 * @return the block ID, or null if the y-coordinate is less than 0 or
 * greater than 256 or the x or z is outside the Minecraft worldmap.
 * Returns Blocks.BEDROCK if the coordinates being checked are in an
 * unloaded chunk
 */
public IBlockState getBlockState_noChunkLoad(World world) {
    if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) {
        return null;
    }
    int chunkx = this.x >> 4;
    int chunkz = this.z >> 4;
    try {
        if (world.getChunkProvider().getLoadedChunk(chunkx, chunkz) != null) {
            if (world.isRemote) {
                if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.provider.getDimension() && BlockVec3.chunkCached_Client.isLoaded()) {
                    return BlockVec3.chunkCached_Client.getBlockState(this.x & 15, this.y, this.z & 15);
                } else {
                    final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
                    BlockVec3.chunkCached_Client = chunk;
                    BlockVec3.chunkCacheDim_Client = world.provider.getDimension();
                    BlockVec3.chunkCacheX_Client = chunkx;
                    BlockVec3.chunkCacheZ_Client = chunkz;
                    return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
                }
            } else {
                // this will be within the same chunk
                if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.provider.getDimension() && BlockVec3.chunkCached.isLoaded()) {
                    return BlockVec3.chunkCached.getBlockState(this.x & 15, this.y, this.z & 15);
                } else {
                    final Chunk chunk = world.getChunkFromChunkCoords(chunkx, chunkz);
                    BlockVec3.chunkCached = chunk;
                    BlockVec3.chunkCacheDim = world.provider.getDimension();
                    BlockVec3.chunkCacheX = chunkx;
                    BlockVec3.chunkCacheZ = chunkz;
                    return chunk.getBlockState(this.x & 15, this.y, this.z & 15);
                }
            }
        }
        // Chunk doesn't exist - meaning, it is not loaded
        return Blocks.BEDROCK.getDefaultState();
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Oxygen Sealer thread: Exception getting block type in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates");
        crashreportcategory.addCrashSection("Location", CrashReportCategory.getCoordinateInfo(new BlockPos(this.x, this.y, this.z)));
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) BlockPos(net.minecraft.util.math.BlockPos) Chunk(net.minecraft.world.chunk.Chunk) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 54 with CrashReport

use of net.minecraft.crash.CrashReport in project SpongeVanilla by SpongePowered.

the class MinecraftServerMixin_Vanilla 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
    chunkIO$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 MinecraftServerMixin_Vanilla
            WorldServerBridge spongeWorld = (WorldServerBridge) worldServer;
            if (spongeWorld.bridge$getChunkGCTickInterval() > 0) {
                spongeWorld.bridge$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")), ((WorldServerBridge) worldServer).bridge$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 MinecraftServerMixin_Vanilla
            if (spongeWorld.bridge$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.vanilla$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();
}
Also used : SPacketTimeUpdate(net.minecraft.network.play.server.SPacketTimeUpdate) CrashReport(net.minecraft.crash.CrashReport) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) WorldServer(net.minecraft.world.WorldServer) WorldServerBridge(org.spongepowered.common.bridge.world.WorldServerBridge) ReportedException(net.minecraft.util.ReportedException) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 55 with CrashReport

use of net.minecraft.crash.CrashReport in project SpongeVanilla by SpongePowered.

the class PluginReporter method crash.

static RuntimeException crash(Throwable e, Collection<PluginCandidate> candidates) {
    CrashReport crash = CrashReport.makeCrashReport(e, "Loading Sponge plugins");
    CrashReportCategory category = crash.makeCategory("Plugins being loaded");
    StringBuilder pluginsBuilder = new StringBuilder();
    StringBuilder requirementsBuilder = new StringBuilder();
    StringBuilder dependenciesBuilder = new StringBuilder();
    for (PluginCandidate candidate : candidates) {
        pluginsBuilder.append(NEW_DETAILS_LINE).append(candidate);
        if (candidate.dependenciesCollected()) {
            Set<PluginCandidate> requirements = candidate.getRequirements();
            Map<String, String> missingRequirements = candidate.getMissingRequirements();
            if (!requirements.isEmpty() || !missingRequirements.isEmpty()) {
                requirementsBuilder.append(NEW_DETAILS_LINE).append(candidate.getId()).append(SEPARATOR);
                if (!requirements.isEmpty()) {
                    Map<String, String> versioned = new HashMap<>();
                    for (PluginCandidate requirement : requirements) {
                        versioned.put(requirement.getId(), candidate.getVersion(requirement.getId()));
                    }
                    formatRequirements(requirementsBuilder, versioned);
                    if (!missingRequirements.isEmpty()) {
                        requirementsBuilder.append(", ");
                    }
                }
                if (!missingRequirements.isEmpty()) {
                    requirementsBuilder.append("missing: ");
                    formatRequirements(requirementsBuilder, missingRequirements);
                }
            }
            if (!candidate.getDependencies().isEmpty()) {
                dependenciesBuilder.append(NEW_DETAILS_LINE).append(candidate.getId()).append(SEPARATOR).append(candidate.getDependencies());
            }
        }
    }
    category.addCrashSection("Plugins", pluginsBuilder);
    if (requirementsBuilder.length() > 0) {
        category.addCrashSection("Requirements", requirementsBuilder);
    }
    if (dependenciesBuilder.length() > 0) {
        category.addCrashSection("Dependencies", dependenciesBuilder);
    }
    throw new ReportedException(crash);
}
Also used : HashMap(java.util.HashMap) CrashReport(net.minecraft.crash.CrashReport) PluginCandidate(org.spongepowered.server.launch.plugin.PluginCandidate) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Aggregations

CrashReport (net.minecraft.crash.CrashReport)55 CrashReportCategory (net.minecraft.crash.CrashReportCategory)37 ReportedException (net.minecraft.util.ReportedException)37 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 Overwrite (org.spongepowered.asm.mixin.Overwrite)4 BufferedWriter (java.io.BufferedWriter)3 JsonIOException (com.google.gson.JsonIOException)2