Search in sources :

Example 21 with CrashReport

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

the class Blueprint method saveContents.

@Override
public void saveContents(NBTTagCompound nbt) {
    NBTTagCompound nbtContents = new NBTTagCompound();
    for (BlockPos pos : BlockPos.getAllInBox(BlockPos.ORIGIN, size.subtract(Utils.POS_ONE))) {
        SchematicBlockBase schematic = null;
        NBTTagCompound cpt = new NBTTagCompound();
        try {
            schematic = get(pos);
            if (schematic != null) {
                schematic.idsToBlueprint(mapping);
                schematic.writeSchematicToNBT(cpt, mapping);
                /* We don't use the index of the current for loop because we shouldn't rely on the behaviour of
                     * BlockPos.getAllInBox */
                nbtContents.setTag(StringUtilBC.blockPosToShortString(pos), cpt);
            }
        } catch (Throwable t) {
            CrashReport crash;
            if (t instanceof ReportedException) {
                crash = ((ReportedException) t).getCrashReport();
            } else {
                crash = new CrashReport("Failed to save the contents of a blueprint!", t);
            }
            CrashReportCategory cat = crash.makeCategory("Block Being Saved");
            cat.addCrashSection("Block Position (In schematic)", pos);
            cat.addCrashSection("Schematic type", schematic == null ? "~~NULL~~" : schematic.getClass());
            mapping.addToCrashReport(crash.makeCategory("Mapping Registry"));
            throw new ReportedException(crash);
        }
    }
    nbt.setTag("contents", nbtContents);
    NBTTagList entitiesNBT = new NBTTagList();
    for (SchematicEntity s : entities) {
        NBTTagCompound subNBT = new NBTTagCompound();
        s.idsToBlueprint(mapping);
        s.writeSchematicToNBT(subNBT, mapping);
        entitiesNBT.appendTag(subNBT);
    }
    nbt.setTag("entities", entitiesNBT);
    NBTTagCompound contextNBT = new NBTTagCompound();
    mapping.write(contextNBT);
    nbt.setTag("idMapping", contextNBT);
}
Also used : SchematicBlockBase(buildcraft.api.blueprints.SchematicBlockBase) NBTTagList(net.minecraft.nbt.NBTTagList) CrashReport(net.minecraft.crash.CrashReport) SchematicEntity(buildcraft.api.blueprints.SchematicEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 22 with CrashReport

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

the class ItemHandlerSimple method insertItem.

@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
    if (badSlotIndex(slot)) {
        return stack;
    }
    if (canSet(slot, stack)) {
        ItemStack current = stacks.get(slot);
        if (!canSet(slot, current)) {
            // A bit odd, but can happen if the filter changed
            return stack;
        }
        InsertionResult result = inserter.modifyForInsertion(slot, asValid(current.copy()), asValid(stack.copy()));
        if (!canSet(slot, result.toSet)) {
            // We have a bad inserter or checker, as they should not be conflicting
            CrashReport report = new CrashReport("Inserting an item (buildcraft:ItemHandlerSimple)", new IllegalStateException("Conflicting Insertion!"));
            CrashReportCategory cat = report.makeCategory("Inventory details");
            cat.addCrashSection("Existing Item", current);
            cat.addCrashSection("Inserting Item", stack);
            cat.addCrashSection("To Set", result.toSet);
            cat.addCrashSection("To Return", result.toReturn);
            cat.addCrashSection("Slot", slot);
            cat.addCrashSection("Checker", checker.getClass());
            cat.addCrashSection("Inserter", inserter.getClass());
            throw new ReportedException(report);
        } else if (!simulate) {
            setStackInternal(slot, result.toSet);
            if (callback != null) {
                callback.onStackChange(this, slot, current, result.toSet);
            }
        }
        return asValid(result.toReturn);
    } else {
        return stack;
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) ItemStack(net.minecraft.item.ItemStack) CrashReportCategory(net.minecraft.crash.CrashReportCategory) InsertionResult(buildcraft.lib.tile.item.StackInsertionFunction.InsertionResult) ReportedException(net.minecraft.util.ReportedException) Nonnull(javax.annotation.Nonnull)

Example 23 with CrashReport

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

the class RailcraftModuleManager method processStage.

private static void processStage(Stage s) {
    setStage(s);
    Game.log().msg(Level.TRACE, "Performing {0} on Modules.", stage.name());
    for (Class<? extends IRailcraftModule> moduleClass : loadOrder) {
        IRailcraftModule module = classToInstanceMapping.get(moduleClass);
        boolean enabled = enabledModules.contains(moduleClass);
        try {
            if (Game.DEVELOPMENT_VERSION)
                Game.log().msg(Level.INFO, "Module performing stage {0}: {1} {2}", stage.name(), getModuleName(module), enabled ? "+" : "-");
            stage.passToModule(module.getModuleEventHandler(enabled));
        } catch (Throwable th) {
            String stageName = stage.name();
            String moduleName = getModuleName(module);
            String enable = enabled ? "+" : "-";
            Game.log().throwable(Level.FATAL, 10, th, "Module failed during {0}: {1} {2}", stageName, moduleName, enable);
            CrashReport crashreport = CrashReport.makeCrashReport(th, "Loading Railcraft Module");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Module being loaded");
            crashreportcategory.addDetail("Name", () -> moduleName);
            crashreportcategory.addDetail("Stage", () -> stageName);
            crashreportcategory.addDetail("Enabled", () -> enable);
            throw new ReportedException(crashreport);
        }
    }
}
Also used : IRailcraftModule(mods.railcraft.api.core.IRailcraftModule) CrashReport(net.minecraft.crash.CrashReport) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 24 with CrashReport

use of net.minecraft.crash.CrashReport in project BiomesOPlenty by Glitchfiend.

the class BiomeProviderBOPHell method getBiomesForGeneration.

@Override
public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height) {
    IntCache.resetIntCache();
    if (biomes == null || biomes.length < width * height) {
        biomes = new Biome[width * height];
    }
    int[] aint = this.genBiomes.getInts(x, z, width, height);
    try {
        for (int i = 0; i < width * height; ++i) {
            biomes[i] = Biome.getBiome(aint[i], Biomes.HELL);
        }
        return biomes;
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock");
        crashreportcategory.addCrashSection("biomes[] size", biomes.length);
        crashreportcategory.addCrashSection("x", x);
        crashreportcategory.addCrashSection("z", z);
        crashreportcategory.addCrashSection("w", width);
        crashreportcategory.addCrashSection("h", height);
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 25 with CrashReport

use of net.minecraft.crash.CrashReport in project Engine by VoltzEngine-Project.

the class FXSmoke method moveEntity.

@Override
public void moveEntity(double xx, double yy, double zz) {
    if (this.noClip) {
        this.boundingBox.offset(xx, yy, zz);
        this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
        this.posY = this.boundingBox.minY + (double) this.yOffset - (double) this.ySize;
        this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
    } else {
        this.worldObj.theProfiler.startSection("move");
        this.ySize *= 0.4F;
        if (this.isInWeb) {
            this.isInWeb = false;
            xx *= 0.25D;
            yy *= 0.05000000074505806D;
            zz *= 0.25D;
            this.motionX = 0.0D;
            this.motionY = 0.0D;
            this.motionZ = 0.0D;
        }
        double d6 = xx;
        double d7 = yy;
        double d8 = zz;
        List list = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(xx, yy, zz));
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); ++i) {
                if (list.get(i) != null) {
                    yy = ((AxisAlignedBB) list.get(i)).calculateYOffset(this.boundingBox, yy);
                }
            }
        }
        this.boundingBox.offset(0.0D, yy, 0.0D);
        if (!this.field_70135_K && d7 != yy) {
            zz = 0.0D;
            yy = 0.0D;
            xx = 0.0D;
        }
        if (list != null && list.size() > 0) {
            for (int j = 0; j < list.size(); ++j) {
                if (list.get(j) != null) {
                    xx = ((AxisAlignedBB) list.get(j)).calculateXOffset(this.boundingBox, xx);
                }
            }
        }
        this.boundingBox.offset(xx, 0.0D, 0.0D);
        if (!this.field_70135_K && d6 != xx) {
            zz = 0.0D;
            yy = 0.0D;
            xx = 0.0D;
        }
        if (list != null && list.size() > 0) {
            for (int j = 0; j < list.size(); ++j) {
                if (list.get(j) != null) {
                    zz = ((AxisAlignedBB) list.get(j)).calculateZOffset(this.boundingBox, zz);
                }
            }
        }
        this.boundingBox.offset(0.0D, 0.0D, zz);
        if (!this.field_70135_K && d8 != zz) {
            zz = 0.0D;
            yy = 0.0D;
            xx = 0.0D;
        }
        this.worldObj.theProfiler.endSection();
        this.worldObj.theProfiler.startSection("rest");
        this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
        this.posY = this.boundingBox.minY + (double) this.yOffset - (double) this.ySize;
        this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
        this.isCollidedHorizontally = d6 != xx || d8 != zz;
        this.isCollidedVertically = d7 != yy;
        this.onGround = d7 != yy && d7 < 0.0D;
        this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically;
        this.updateFallState(yy, this.onGround);
        if (d6 != xx) {
            this.motionX = 0.0D;
        }
        if (d7 != yy) {
            this.motionY = 0.0D;
        }
        if (d8 != zz) {
            this.motionZ = 0.0D;
        }
        try {
            this.func_145775_I();
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
            this.addEntityCrashInfo(crashreportcategory);
            throw new ReportedException(crashreport);
        }
        this.worldObj.theProfiler.endSection();
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) List(java.util.List) 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