Search in sources :

Example 31 with CrashReport

use of net.minecraft.crash.CrashReport in project Realistic-Terrain-Generation by Team-RTG.

the class StructureOceanMonumentRTG method areBiomesViable.

public boolean areBiomesViable(int x, int z, int radius, List<Biome> allowed) {
    // Are we in an RTG world?
    if (!DimensionManagerRTG.isValidDimension(this.world.provider.getDimension())) {
        //Logger.debug("Could not generate ocean monument. This is not an RTG world.");
        return false;
    }
    // Do we have RTG's chunk manager?
    if (!(this.world.getBiomeProvider() instanceof BiomeProviderRTG)) {
        //Logger.debug("Could not generate ocean monument. Incompatible chunk manager detected.");
        return false;
    }
    IntCache.resetIntCache();
    int i = x - radius >> 2;
    int j = z - radius >> 2;
    int k = x + radius >> 2;
    int l = z + radius >> 2;
    int i1 = k - i + 1;
    int j1 = l - j + 1;
    BiomeProviderRTG cmr = (BiomeProviderRTG) this.world.getBiomeProvider();
    int[] aint = cmr.getBiomesGens(i, j, i1, j1);
    try {
        for (int k1 = 0; k1 < i1 * j1; ++k1) {
            Biome biome = Biome.getBiome(aint[k1]);
            if (!allowed.contains(biome)) {
                //Logger.debug("Could not generate ocean monument. Biome (%d) nearby.", BiomeUtils.getId(biome));
                return false;
            }
        }
        return true;
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer");
        crashreportcategory.addCrashSection("Layer", Arrays.toString(aint));
        crashreportcategory.addCrashSection("x", x);
        crashreportcategory.addCrashSection("z", z);
        crashreportcategory.addCrashSection("radius", radius);
        crashreportcategory.addCrashSection("allowed", allowed);
        throw new ReportedException(crashreport);
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) CrashReport(net.minecraft.crash.CrashReport) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 32 with CrashReport

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

the class PhaseTracker method notifyBlockOfStateChange.

// --------------------- DELEGATED WORLD METHODS -------------------------
/**
 * Replacement of {@link net.minecraft.world.World#neighborChanged(BlockPos, Block, BlockPos)}
 * that adds tracking into play.
 *
 * @param mixinWorld THe world
 * @param notifyPos The original notification position
 * @param sourceBlock The source block type
 * @param sourcePos The source block position
 */
public void notifyBlockOfStateChange(final IMixinWorldServer mixinWorld, final BlockPos notifyPos, final Block sourceBlock, @Nullable final BlockPos sourcePos) {
    final IBlockState iblockstate = ((WorldServer) mixinWorld).getBlockState(notifyPos);
    try {
        // Sponge start - prepare notification
        final PhaseData peek = this.stack.peek();
        final IPhaseState<?> state = peek.state;
        ((IPhaseState) state).associateNeighborStateNotifier(peek.context, sourcePos, iblockstate.getBlock(), notifyPos, ((WorldServer) mixinWorld), PlayerTracker.Type.NOTIFIER);
        // Sponge End
        iblockstate.neighborChanged(((WorldServer) mixinWorld), notifyPos, sourceBlock, sourcePos);
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while updating neighbours");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being updated");
        crashreportcategory.addDetail("Source block type", () -> {
            try {
                return String.format("ID #%d (%s // %s)", Block.getIdFromBlock(sourceBlock), sourceBlock.getUnlocalizedName(), sourceBlock.getClass().getCanonicalName());
            } catch (Throwable var2) {
                return "ID #" + Block.getIdFromBlock(sourceBlock);
            }
        });
        CrashReportCategory.addBlockInfo(crashreportcategory, notifyPos, iblockstate);
        throw new ReportedException(crashreport);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) CrashReport(net.minecraft.crash.CrashReport) EntityThrowable(net.minecraft.entity.projectile.EntityThrowable) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) WorldServer(net.minecraft.world.WorldServer) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 33 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)

Example 34 with CrashReport

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

the class EventManager method fire.

public <L extends Listener, E extends Event<L>> void fire(E event) {
    if (!WurstClient.INSTANCE.isEnabled())
        return;
    try {
        Class<L> type = event.getListenerType();
        @SuppressWarnings("unchecked") ArrayList<L> listeners = (ArrayList<L>) listenerMap.get(type);
        if (listeners == null || listeners.isEmpty())
            return;
        event.fire(new ArrayList<>(listeners));
    } catch (Throwable e) {
        e.printStackTrace();
        CrashReport report = CrashReport.makeCrashReport(e, "Firing Wurst event");
        CrashReportCategory category = report.makeCategory("Affected event");
        category.setDetail("Event class", () -> event.getClass().getName());
        throw new ReportedException(report);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) ArrayList(java.util.ArrayList) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 35 with CrashReport

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

the class CmdManager method runCommand.

public void runCommand(String input) {
    String[] parts = input.split(" ");
    Cmd cmd = getCommandByName(parts[0]);
    if (cmd == null) {
        ChatUtils.error("Unknown command: ." + parts[0]);
        if (input.startsWith("/"))
            ChatUtils.message("Use \".say " + input + "\" to send it as a chat command.");
        else
            ChatUtils.message("Type \".help\" for a list of commands or \".say ." + input + "\" to send it as a chat message.");
        return;
    }
    try {
        cmd.call(Arrays.copyOfRange(parts, 1, parts.length));
    } catch (CmdException e) {
        e.printToChat();
    } catch (Throwable e) {
        CrashReport crashReport = CrashReport.makeCrashReport(e, "Running Wurst command");
        CrashReportCategory crashReportCategory = crashReport.makeCategory("Affected command");
        crashReportCategory.setDetail("Command input", () -> input);
        throw new ReportedException(crashReport);
    }
}
Also used : CmdException(net.wurstclient.features.Cmd.CmdException) CrashReport(net.minecraft.crash.CrashReport) Cmd(net.wurstclient.features.Cmd) CrashReportCategory(net.minecraft.crash.CrashReportCategory) 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