Search in sources :

Example 1 with ReportedException

use of net.minecraft.util.ReportedException in project minecolonies by Minecolonies.

the class InventoryCitizen method addItemStackToInventory.

/**
     * Adds the item stack to the inventory, returns false if it is impossible.
     *
     * @param itemStackIn stack to add.
     * @return true if possible.
     */
public boolean addItemStackToInventory(final ItemStack itemStackIn) {
    if (itemStackIn.isEmpty()) {
        return false;
    } else {
        try {
            if (itemStackIn.isItemDamaged()) {
                final int j = this.getFirstEmptyStack();
                if (j >= 0) {
                    this.mainInventory.set(j, itemStackIn.copy());
                    (this.mainInventory.get(j)).setAnimationsToGo(5);
                    itemStackIn.setCount(0);
                    return true;
                } else {
                    return false;
                }
            } else {
                int i;
                while (true) {
                    i = itemStackIn.getCount();
                    itemStackIn.setCount(this.storePartialItemStack(itemStackIn));
                    if (itemStackIn.isEmpty() || itemStackIn.getCount() >= i) {
                        break;
                    }
                }
                return itemStackIn.getCount() < i;
            }
        } catch (final RuntimeException exception) {
            final CrashReport crashreport = CrashReport.makeCrashReport(exception, "Adding item to inventory");
            final CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
            crashreportcategory.addCrashSection("Item ID", Item.getIdFromItem(itemStackIn.getItem()));
            crashreportcategory.addCrashSection("Item data", itemStackIn.getMetadata());
            crashreportcategory.setDetail("Item name", itemStackIn::getDisplayName);
            throw new ReportedException(crashreport);
        }
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Example 2 with ReportedException

use of net.minecraft.util.ReportedException 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)

Example 3 with ReportedException

use of net.minecraft.util.ReportedException in project Overloaded by CJ-MC-Mods.

the class CompressedBlockHandler method initFromConfig.

public static void initFromConfig() {
    IForgeRegistry<Block> registry = GameRegistry.findRegistry(Block.class);
    for (String setting : OverloadedConfig.compressedConfig.compressedBlocks) {
        if (setting.isEmpty())
            continue;
        String[] split = setting.split(":");
        if (split.length < 4) {
            if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
                throwClientSideError(setting);
            } else {
                throw new ReportedException(CrashReport.makeCrashReport(new RuntimeException("Compressed Blocks Config is invalid. Looking at compressed block: " + setting), "Invalid Compressed Block Config"));
            }
        }
        String domain = split[0];
        String blockName = split[1];
        int depth = Integer.parseInt(split[2]);
        boolean recipeEnabled = Boolean.parseBoolean(split[3]);
        Block block = registry.getValue(new ResourceLocation(domain, blockName));
        if (block == Blocks.AIR)
            continue;
        CompressedBlockHandler.CreateCompressedBlocks(block, depth, recipeEnabled);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ReportedException(net.minecraft.util.ReportedException)

Example 4 with ReportedException

use of net.minecraft.util.ReportedException 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)

Aggregations

ReportedException (net.minecraft.util.ReportedException)4 CrashReport (net.minecraft.crash.CrashReport)3 CrashReportCategory (net.minecraft.crash.CrashReportCategory)3 List (java.util.List)1 Block (net.minecraft.block.Block)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 Biome (net.minecraft.world.biome.Biome)1 BiomeProviderRTG (rtg.world.biome.BiomeProviderRTG)1