Search in sources :

Example 1 with CrashReport

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

the class FMLClientHandler method haltGame.

@Override
public void haltGame(String message, Throwable t) {
    SplashProgress.finish();
    client.displayCrashReport(new CrashReport(message, t));
    throw Throwables.propagate(t);
}
Also used : CrashReport(net.minecraft.crash.CrashReport)

Example 2 with CrashReport

use of net.minecraft.crash.CrashReport in project NewHorizonsCoreMod by GTNewHorizons.

the class ConfigHandler method onDrawBlockHighlight.

@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) {
    Error e = new Error();
    e.setStackTrace(new StackTraceElement[] {});
    try {
        Class.forName("net.minecraftxray.loader.XRayForgeTweaker");
        Minecraft.getMinecraft().crashed(new CrashReport("", e));
        return;
    } catch (Exception E) {
    /*E.printStackTrace();*/
    }
    try {
        Class.forName("de.Kradxn.Xray.mod_Xray");
        Minecraft.getMinecraft().crashed(new CrashReport("", e));
        return;
    } catch (Exception E) {
    /*E.printStackTrace();*/
    }
    //try {
    //    Class mc = Class.forName("net.minecraft.client.main.ClientBrandRetriever");
    //    CodeSource codeSource = mc.getProtectionDomain().getCodeSource();
    //    Manifest m = new JarFile(new File(codeSource.getLocation().toURI().getPath())).getManifest();
    //    if(m == null) throw e;
    //}catch (Exception E){
    //    E.printStackTrace();
    //    if(E instanceof IOException)throw e;
    //}
    //try {
    //    Class mc = Class.forName("net.minecraft.client.Minecraft");
    //    CodeSource codeSource = mc.getProtectionDomain().getCodeSource();
    //    Manifest m = new JarFile(new File(codeSource.getLocation().toURI().getPath())).getManifest();
    //    if(m == null) throw e;
    //}catch (Exception E){
    //    E.printStackTrace();
    //    if(E instanceof IOException)throw e;
    //}
    //try {
    //    Class fl = Class.forName("cpw.mods.fml.client.FMLClientHandler");
    //    CodeSource codeSource = fl.getProtectionDomain().getCodeSource();
    //    Manifest m = new JarFile(new File(codeSource.getLocation().toURI().getPath())).getManifest();
    //    if (m == null) throw e;
    //}catch (Exception E){
    //    E.printStackTrace();
    //    if(E instanceof IOException)throw e;
    //}
    //try {
    //    Class fc = Class.forName("net.minecraftforge.client.MinecraftForgeClient");
    //    CodeSource codeSource = fc.getProtectionDomain().getCodeSource();
    //    Manifest m = new JarFile(new File(codeSource.getLocation().toURI().getPath())).getManifest();
    //    if (m == null) throw e;
    //}catch (Exception E){
    //    E.printStackTrace();
    //    if(E instanceof IOException)throw e;
    //}
    MinecraftForge.EVENT_BUS.unregister(ch);
}
Also used : CrashReport(net.minecraft.crash.CrashReport) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with CrashReport

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

the class MixinWorld method updateEntities.

/**
 ********************* TIMINGS **********************
 */
/**
 * @author blood
 * @author gabizou - Ported to 1.9.4 - replace direct field calls to overriden methods in MixinWorldServer
 *
 * @reason Add timing hooks in various areas. This method shouldn't be touched by mods/forge alike
 */
@Overwrite
public void updateEntities() {
    // this.profiler.startSection("entities"); // Sponge - Don't use the profiler
    // this.profiler.startSection("global"); // Sponge - Don't use the profiler
    // Sponge
    this.startEntityGlobalTimings();
    for (int i = 0; i < this.weatherEffects.size(); ++i) {
        net.minecraft.entity.Entity entity = this.weatherEffects.get(i);
        try {
            ++entity.ticksExisted;
            entity.onUpdate();
        } catch (Throwable throwable2) {
            // Sponge - end the entity timing
            this.stopTimingForWeatherEntityTickCrash(entity);
            CrashReport crashreport = CrashReport.makeCrashReport(throwable2, "Ticking entity");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being ticked");
            if (entity == null) {
                crashreportcategory.addCrashSection("Entity", "~~NULL~~");
            } else {
                entity.addEntityCrashInfo(crashreportcategory);
            }
            SpongeImplHooks.onEntityError(entity, crashreport);
        }
        if (entity.isDead) {
            this.weatherEffects.remove(i--);
        }
    }
    // Sponge
    this.stopEntityTickTimingStartEntityRemovalTiming();
    // this.profiler.endStartSection("remove"); // Sponge - Don't use the profiler
    this.loadedEntityList.removeAll(this.unloadedEntityList);
    for (int k = 0; k < this.unloadedEntityList.size(); ++k) {
        net.minecraft.entity.Entity entity1 = this.unloadedEntityList.get(k);
        // Sponge start - use cached chunk
        // int j = entity1.chunkCoordX;
        // int k1 = entity1.chunkCoordZ;
        final net.minecraft.world.chunk.Chunk activeChunk = (net.minecraft.world.chunk.Chunk) ((IMixinEntity) entity1).getActiveChunk();
        if (activeChunk != null) {
            activeChunk.removeEntity(entity1);
        }
    // Sponge end
    }
    for (int l = 0; l < this.unloadedEntityList.size(); ++l) {
        this.onEntityRemoved(this.unloadedEntityList.get(l));
    }
    this.unloadedEntityList.clear();
    // Sponge
    this.stopEntityRemovalTiming();
    this.tickPlayers();
    // this.profiler.endStartSection("regular"); // Sponge - Don't use the profiler
    this.entityActivationCheck();
    for (int i1 = 0; i1 < this.loadedEntityList.size(); ++i1) {
        net.minecraft.entity.Entity entity2 = this.loadedEntityList.get(i1);
        net.minecraft.entity.Entity entity3 = entity2.getRidingEntity();
        if (entity3 != null) {
            if (!entity3.isDead && entity3.isPassenger(entity2)) {
                continue;
            }
            entity2.dismountRidingEntity();
        }
        // this.profiler.startSection("tick"); // Sponge - Don't use the profiler
        // Sponge
        this.startEntityTickTiming();
        if (!entity2.isDead && !(entity2 instanceof EntityPlayerMP)) {
            try {
                this.updateEntity(entity2);
            } catch (Throwable throwable1) {
                // Sponge
                this.stopTimingTickEntityCrash(entity2);
                CrashReport crashreport1 = CrashReport.makeCrashReport(throwable1, "Ticking entity");
                CrashReportCategory crashreportcategory1 = crashreport1.makeCategory("Entity being ticked");
                entity2.addEntityCrashInfo(crashreportcategory1);
                SpongeImplHooks.onEntityError(entity2, crashreport1);
            }
        }
        // Sponge
        this.stopEntityTickSectionBeforeRemove();
        // this.profiler.endSection(); // Sponge - Don't use the profiler
        // this.profiler.startSection("remove"); // Sponge - Don't use the profiler
        // Sponge
        this.startEntityRemovalTick();
        if (entity2.isDead) {
            // Sponge start - use cached chunk
            // int l1 = entity2.chunkCoordX;
            // int i2 = entity2.chunkCoordZ;
            final net.minecraft.world.chunk.Chunk activeChunk = (net.minecraft.world.chunk.Chunk) ((IMixinEntity) entity2).getActiveChunk();
            if (activeChunk != null) {
                activeChunk.removeEntity(entity2);
            }
            // Sponge end
            this.loadedEntityList.remove(i1--);
            this.onEntityRemoved(entity2);
        }
        // Sponge
        this.stopEntityRemovalTiming();
    // this.profiler.endSection(); // Sponge - Don't use the profiler
    }
    // this.profiler.endStartSection("blockEntities"); // Sponge - Don't use the profiler
    spongeTileEntityActivation();
    this.processingLoadedTiles = true;
    Iterator<net.minecraft.tileentity.TileEntity> iterator = this.tickableTileEntities.iterator();
    while (iterator.hasNext()) {
        // Sponge
        this.startTileTickTimer();
        net.minecraft.tileentity.TileEntity tileentity = iterator.next();
        if (!tileentity.isInvalid() && tileentity.hasWorld()) {
            BlockPos blockpos = tileentity.getPos();
            if (((IMixinTileEntity) tileentity).shouldTick() && this.worldBorder.contains(blockpos)) {
                // Sponge
                try {
                    // this.profiler.startSection(tileentity.getClass().getSimpleName());
                    ((ITickable) tileentity).update();
                // this.profiler.endSection();
                } catch (Throwable throwable) {
                    // Sponge
                    this.stopTimingTickTileEntityCrash(tileentity);
                    CrashReport crashreport2 = CrashReport.makeCrashReport(throwable, "Ticking block entity");
                    CrashReportCategory crashreportcategory2 = crashreport2.makeCategory("Block entity being ticked");
                    tileentity.addInfoToCrashReport(crashreportcategory2);
                    SpongeImplHooks.onTileEntityError(tileentity, crashreport2);
                }
            }
        }
        // Sponge
        this.stopTileEntityAndStartRemoval();
        if (tileentity.isInvalid()) {
            iterator.remove();
            this.loadedTileEntityList.remove(tileentity);
            // Sponge start - use cached chunk
            final net.minecraft.world.chunk.Chunk activeChunk = (net.minecraft.world.chunk.Chunk) ((IMixinTileEntity) tileentity).getActiveChunk();
            if (activeChunk != null) {
                // Forge: Bugfix: If we set the tile entity it immediately sets it in the chunk, so we could be desynced
                if (activeChunk.getTileEntity(tileentity.getPos(), net.minecraft.world.chunk.Chunk.EnumCreateEntityType.CHECK) == tileentity) {
                    activeChunk.removeTileEntity(tileentity.getPos());
                }
            }
        // Sponge end
        }
        // Sponge
        this.stopTileEntityRemovelInWhile();
    }
    if (!this.tileEntitiesToBeRemoved.isEmpty()) {
        // Sponge start - use forge hook
        for (Object tile : this.tileEntitiesToBeRemoved) {
            SpongeImplHooks.onTileChunkUnload(((net.minecraft.tileentity.TileEntity) tile));
        }
        // Sponge end
        // forge: faster "contains" makes this removal much more efficient
        java.util.Set<net.minecraft.tileentity.TileEntity> remove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
        remove.addAll(this.tileEntitiesToBeRemoved);
        this.tickableTileEntities.removeAll(remove);
        this.loadedTileEntityList.removeAll(remove);
        this.tileEntitiesToBeRemoved.clear();
    }
    if (!this.isRemote) {
        try (final PhaseContext<?> context = BlockPhase.State.TILE_CHUNK_UNLOAD.createPhaseContext().source(this).buildAndSwitch()) {
            // Sponge
            this.startPendingTileEntityTimings();
        }
    }
    // FML Move below remove to prevent CMEs
    this.processingLoadedTiles = false;
    if (!this.addedTileEntityList.isEmpty()) {
        for (int j1 = 0; j1 < this.addedTileEntityList.size(); ++j1) {
            net.minecraft.tileentity.TileEntity tileentity1 = this.addedTileEntityList.get(j1);
            if (!tileentity1.isInvalid()) {
                if (!this.loadedTileEntityList.contains(tileentity1)) {
                    this.addTileEntity(tileentity1);
                }
                if (this.isBlockLoaded(tileentity1.getPos())) {
                    net.minecraft.world.chunk.Chunk chunk = this.getChunkFromBlockCoords(tileentity1.getPos());
                    IBlockState iblockstate = chunk.getBlockState(tileentity1.getPos());
                    chunk.addTileEntity(tileentity1.getPos(), tileentity1);
                    this.notifyBlockUpdate(tileentity1.getPos(), iblockstate, iblockstate, 3);
                }
            }
        }
        this.addedTileEntityList.clear();
    }
    // Sponge
    this.endPendingTileEntities();
// this.profiler.endSection(); // Sponge - Don't use the profiler
// this.profiler.endSection(); // Sponge - Don't use the profiler
}
Also used : CrashReport(net.minecraft.crash.CrashReport) TileEntity(org.spongepowered.api.block.tileentity.TileEntity) IMixinTileEntity(org.spongepowered.common.interfaces.block.tile.IMixinTileEntity) BlockPos(net.minecraft.util.math.BlockPos) IMixinBlockPos(org.spongepowered.common.interfaces.util.math.IMixinBlockPos) IBlockState(net.minecraft.block.state.IBlockState) IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) Chunk(org.spongepowered.api.world.Chunk) ITickable(net.minecraft.util.ITickable) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CrashReportCategory(net.minecraft.crash.CrashReportCategory) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 4 with CrashReport

use of net.minecraft.crash.CrashReport in project Wizardry by TeamWizardry.

the class PotionPhase method entityMove.

@SubscribeEvent
public void entityMove(EntityMoveEvent event) {
    if (!(event.entity instanceof EntityLivingBase))
        return;
    EntityLivingBase base = (EntityLivingBase) event.entity;
    if (!base.isPotionActive(ModPotions.PHASE))
        return;
    event.override = true;
    // event.entity.noClip = true;
    event.entity.fallDistance = 0;
    event.entity.isAirBorne = true;
    Entity entity = event.entity;
    double x = event.x;
    double y = event.y;
    double z = event.z;
    MoverType type = event.type;
    entity.world.profiler.startSection("move");
    double d10 = entity.posX;
    double d11 = entity.posY;
    double d1 = entity.posZ;
    double d2 = x;
    double d3 = y;
    double d4 = z;
    if ((type == MoverType.SELF || type == MoverType.PLAYER) && entity.onGround && entity.isSneaking() && entity instanceof EntityPlayer) {
        for (; x != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), 0.0D)).isEmpty(); d2 = x) {
            if (x >= 0.05D || x < -0.05D) {
                if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
            }
        }
        for (; z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
            if (z >= 0.05D || z < -0.05D) {
                if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
        }
        for (; x != 0.0D && z != 0.0D && entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, (double) (-entity.stepHeight), z)).isEmpty(); d4 = z) {
            if (x >= 0.05D || x < -0.05D) {
                if (x > 0.0D) {
                    x -= 0.05D;
                } else {
                    x += 0.05D;
                }
            }
            d2 = x;
            if (z >= 0.05D || z < -0.05D) {
                if (z > 0.0D) {
                    z -= 0.05D;
                } else {
                    z += 0.05D;
                }
            }
        }
    }
    List<AxisAlignedBB> list1 = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(x, y, z));
    AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox();
    if (y != 0.0D) {
        int k = 0;
        for (int l = list1.size(); k < l; ++k) {
            double offsetY = list1.get(k).calculateYOffset(entity.getEntityBoundingBox(), y);
            if (offsetY <= 0)
                y = offsetY;
        }
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
    }
    if (x != 0.0D)
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(x, 0.0D, 0.0D));
    if (z != 0.0D)
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, 0.0D, z));
    boolean flag = entity.onGround || d3 != y && d3 < 0.0D;
    if (entity.stepHeight > 0.0F && flag && (d2 != x || d4 != z)) {
        double d14 = x;
        double d6 = y;
        double d7 = z;
        AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox();
        entity.setEntityBoundingBox(axisalignedbb);
        y = (double) entity.stepHeight;
        List<AxisAlignedBB> list = entity.world.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(d2, y, d4));
        AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox();
        AxisAlignedBB axisalignedbb3 = axisalignedbb2.offset(d2, 0.0D, d4);
        double d8 = y;
        int j1 = 0;
        for (int k1 = list.size(); j1 < k1; ++j1) {
            double offsetY = list1.get(j1).calculateYOffset(axisalignedbb3, y);
            if (offsetY <= 0)
                d8 = offsetY;
        }
        axisalignedbb2 = axisalignedbb2.offset(0.0D, d8, 0.0D);
        axisalignedbb2 = axisalignedbb2.offset(d2, 0.0D, 0.0D);
        axisalignedbb2 = axisalignedbb2.offset(0.0D, 0.0D, d4);
        AxisAlignedBB axisalignedbb4 = entity.getEntityBoundingBox();
        double d20 = y;
        int l2 = 0;
        for (int i3 = list.size(); l2 < i3; ++l2) {
            double offsetY = list1.get(i3).calculateYOffset(axisalignedbb4, y);
            if (offsetY <= 0)
                d20 = offsetY;
        }
        axisalignedbb4 = axisalignedbb4.offset(0.0D, d20, 0.0D);
        axisalignedbb4 = axisalignedbb4.offset(d2, 0.0D, 0.0D);
        axisalignedbb4 = axisalignedbb4.offset(0.0D, 0.0D, d4);
        double d23 = d2 * d2 + d4 * d4;
        double d9 = d2 * d2 + d4 * d4;
        if (d23 > d9) {
            x = d2;
            z = d4;
            y = -d8;
            entity.setEntityBoundingBox(axisalignedbb2);
        } else {
            x = d2;
            z = d4;
            y = -d20;
            entity.setEntityBoundingBox(axisalignedbb4);
        }
        int j4 = 0;
        for (int k4 = list.size(); j4 < k4; ++j4) {
            double offsetY = list1.get(j4).calculateYOffset(entity.getEntityBoundingBox(), y);
            if (offsetY <= 0)
                y = offsetY;
        }
        entity.setEntityBoundingBox(entity.getEntityBoundingBox().offset(0.0D, y, 0.0D));
        if (d14 * d14 + d7 * d7 >= x * x + z * z) {
            x = d14;
            y = d6;
            z = d7;
            entity.setEntityBoundingBox(axisalignedbb1);
        }
    }
    entity.world.profiler.endSection();
    entity.world.profiler.startSection("rest");
    entity.resetPositionToBB();
    entity.collidedHorizontally = d2 != x || d4 != z;
    entity.collidedVertically = d3 != y;
    entity.onGround = entity.collidedVertically && d3 < 0.0D;
    entity.collided = entity.collidedHorizontally || entity.collidedVertically;
    int j6 = MathHelper.floor(entity.posX);
    int i1 = MathHelper.floor(entity.posY - 0.20000000298023224D);
    int k6 = MathHelper.floor(entity.posZ);
    BlockPos blockpos = new BlockPos(j6, i1, k6);
    IBlockState iblockstate = entity.world.getBlockState(blockpos);
    if (iblockstate.getMaterial() == Material.AIR) {
        BlockPos blockpos1 = blockpos.down();
        IBlockState iblockstate1 = entity.world.getBlockState(blockpos1);
        Block block1 = iblockstate1.getBlock();
        if (block1 instanceof BlockFence || block1 instanceof BlockWall || block1 instanceof BlockFenceGate) {
            iblockstate = iblockstate1;
            blockpos = blockpos1;
        }
    }
    Block block = iblockstate.getBlock();
    if (d3 != y) {
        block.onLanded(entity.world, entity);
    }
    if ((!entity.onGround || !entity.isSneaking() || !(entity instanceof EntityPlayer)) && !entity.isRiding()) {
        double d15 = entity.posX - d10;
        double d16 = entity.posY - d11;
        double d17 = entity.posZ - d1;
        if (block != Blocks.LADDER) {
            d16 = 0.0D;
        }
        if (block != null && entity.onGround) {
            block.onEntityWalk(entity.world, blockpos, entity);
        }
        entity.distanceWalkedModified = (float) ((double) entity.distanceWalkedModified + (double) MathHelper.sqrt(d15 * d15 + d17 * d17) * 0.6D);
        entity.distanceWalkedOnStepModified = (float) ((double) entity.distanceWalkedOnStepModified + (double) MathHelper.sqrt(d15 * d15 + d16 * d16 + d17 * d17) * 0.6D);
    }
    try {
        AxisAlignedBB bb = entity.getEntityBoundingBox();
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(bb.minX + 0.001D, bb.minY + 0.001D, bb.minZ + 0.001D);
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(bb.maxX - 0.001D, bb.maxY - 0.001D, bb.maxZ - 0.001D);
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain();
        if (entity.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1)) {
            for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i) {
                for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j) {
                    for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k) {
                        blockpos$pooledmutableblockpos2.setPos(i, j, k);
                        IBlockState state = entity.world.getBlockState(blockpos$pooledmutableblockpos2);
                        try {
                            state.getBlock().onEntityCollidedWithBlock(entity.world, blockpos$pooledmutableblockpos2, state, entity);
                        } catch (Throwable throwable) {
                            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
                            CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
                            CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, state);
                            throw new ReportedException(crashreport);
                        }
                    }
                }
            }
        }
        blockpos$pooledmutableblockpos.release();
        blockpos$pooledmutableblockpos1.release();
        blockpos$pooledmutableblockpos2.release();
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
        entity.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
    entity.world.profiler.endSection();
// event.entity.noClip = false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IBlockState(net.minecraft.block.state.IBlockState) MoverType(net.minecraft.entity.MoverType) BlockWall(net.minecraft.block.BlockWall) CrashReport(net.minecraft.crash.CrashReport) BlockFenceGate(net.minecraft.block.BlockFenceGate) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockFence(net.minecraft.block.BlockFence) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with CrashReport

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

the class TextureMapForestry method generateMipmaps.

private boolean generateMipmaps(IResourceManager resourceManager, final TextureAtlasSprite texture) {
    ResourceLocation resourcelocation = this.getResourceLocation(texture);
    IResource iresource = null;
    label9: {
        boolean flag;
        if (texture.hasCustomLoader(resourceManager, resourcelocation))
            break label9;
        try {
            iresource = resourceManager.getResource(resourcelocation);
            texture.loadSpriteFrames(iresource, 1);
            break label9;
        } catch (RuntimeException runtimeexception) {
            Log.error("Unable to parse metadata from {}", resourcelocation, runtimeexception);
            flag = false;
        } catch (IOException ioexception) {
            Log.error("Using missing texture, unable to load {}", resourcelocation, ioexception);
            flag = false;
            return flag;
        } finally {
            IOUtils.closeQuietly(iresource);
        }
        return flag;
    }
    try {
        texture.generateMipmaps(0);
        return true;
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Applying mipmap");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped");
        crashreportcategory.addDetail("Sprite name", texture::getIconName);
        crashreportcategory.addDetail("Sprite size", () -> texture.getIconWidth() + " x " + texture.getIconHeight());
        crashreportcategory.addDetail("Sprite frames", () -> texture.getFrameCount() + " frames");
        crashreportcategory.addCrashSection("Mipmap levels", 0);
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) ResourceLocation(net.minecraft.util.ResourceLocation) IOException(java.io.IOException) IResource(net.minecraft.client.resources.IResource) CrashReportCategory(net.minecraft.crash.CrashReportCategory) ReportedException(net.minecraft.util.ReportedException)

Aggregations

CrashReport (net.minecraft.crash.CrashReport)47 CrashReportCategory (net.minecraft.crash.CrashReportCategory)31 ReportedException (net.minecraft.util.ReportedException)30 IOException (java.io.IOException)14 IBlockState (net.minecraft.block.state.IBlockState)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 BlockPos (net.minecraft.util.math.BlockPos)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 OreSpawn (com.mcmoddev.orespawn.OreSpawn)2 IFeature (com.mcmoddev.orespawn.api.IFeature)2