Search in sources :

Example 6 with CrashReportSection

use of net.minecraft.util.crash.CrashReportSection in project Indium by comp500.

the class IndiumTerrainRenderContext method tesselateBlock.

/**
 * Called from chunk renderer hook.
 */
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model, MatrixStack matrixStack) {
    this.matrix = matrixStack.peek().getModel();
    this.normalMatrix = matrixStack.peek().getNormal();
    try {
        aoCalc.clear();
        blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
        ((FabricBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
    } catch (Throwable var9) {
        CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Indium Renderer");
        CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
        CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
        throw new CrashException(crashReport_1);
    }
    // false because we've already marked the chunk as populated - caller doesn't need to
    return false;
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) FabricBakedModel(net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 7 with CrashReportSection

use of net.minecraft.util.crash.CrashReportSection in project roadrunner by MaxNeedsSnacks.

the class DataTrackerMixin method onGetException.

private static <T> CrashException onGetException(Throwable cause, TrackedData<T> data) {
    CrashReport report = CrashReport.create(cause, "Getting synced entity data");
    CrashReportSection section = report.addElement("Synced entity data");
    section.add("Data ID", data);
    return new CrashException(report);
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 8 with CrashReportSection

use of net.minecraft.util.crash.CrashReportSection in project jGui by ReplayMod.

the class AbstractGuiContainer method layout.

@Override
public void layout(ReadableDimension size, RenderInfo renderInfo) {
    super.layout(size, renderInfo);
    if (size == null)
        return;
    try {
        layedOutElements = layout.layOut(this, size);
    } catch (Exception ex) {
        CrashReport crashReport = CrashReport.create(ex, "Gui Layout");
        renderInfo.addTo(crashReport);
        CrashReportSection category = crashReport.addElement("Gui container details");
        MCVer.addDetail(category, "Container", this::toString);
        MCVer.addDetail(category, "Layout", layout::toString);
        throw new CrashException(crashReport);
    }
    for (final Map.Entry<GuiElement, Pair<ReadablePoint, ReadableDimension>> e : layedOutElements.entrySet()) {
        GuiElement element = e.getKey();
        if (element instanceof ComposedGuiElement) {
            if (((ComposedGuiElement) element).getMaxLayer() < renderInfo.layer) {
                continue;
            }
        } else {
            if (element.getLayer() != renderInfo.layer) {
                continue;
            }
        }
        ReadablePoint ePosition = e.getValue().getLeft();
        ReadableDimension eSize = e.getValue().getRight();
        element.layout(eSize, renderInfo.offsetMouse(ePosition.getX(), ePosition.getY()).layer(renderInfo.getLayer() - element.getLayer()));
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection) AbstractComposedGuiElement(de.johni0702.minecraft.gui.element.AbstractComposedGuiElement) GuiElement(de.johni0702.minecraft.gui.element.GuiElement) ComposedGuiElement(de.johni0702.minecraft.gui.element.ComposedGuiElement) AbstractComposedGuiElement(de.johni0702.minecraft.gui.element.AbstractComposedGuiElement) ComposedGuiElement(de.johni0702.minecraft.gui.element.ComposedGuiElement) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) CrashException(net.minecraft.util.crash.CrashException) Pair(org.apache.commons.lang3.tuple.Pair)

Example 9 with CrashReportSection

use of net.minecraft.util.crash.CrashReportSection in project jGui by ReplayMod.

the class AbstractGuiOverlay method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    if (mouseVisible && renderInfo.layer == getMaxLayer()) {
        final GuiElement tooltip = forEach(GuiElement.class, e -> e.getTooltip(renderInfo));
        if (tooltip != null) {
            final ReadableDimension tooltipSize = tooltip.getMinSize();
            int x, y;
            if (renderInfo.mouseX + 8 + tooltipSize.getWidth() < screenSize.getWidth()) {
                x = renderInfo.mouseX + 8;
            } else {
                x = screenSize.getWidth() - tooltipSize.getWidth() - 1;
            }
            if (renderInfo.mouseY + 8 + tooltipSize.getHeight() < screenSize.getHeight()) {
                y = renderInfo.mouseY + 8;
            } else {
                y = screenSize.getHeight() - tooltipSize.getHeight() - 1;
            }
            final ReadablePoint position = new Point(x, y);
            try {
                OffsetGuiRenderer eRenderer = new OffsetGuiRenderer(renderer, position, tooltipSize);
                tooltip.draw(eRenderer, tooltipSize, renderInfo);
            } catch (Exception ex) {
                CrashReport crashReport = CrashReport.create(ex, "Rendering Gui Tooltip");
                renderInfo.addTo(crashReport);
                CrashReportSection category = crashReport.addElement("Gui container details");
                MCVer.addDetail(category, "Container", this::toString);
                MCVer.addDetail(category, "Width", () -> "" + size.getWidth());
                MCVer.addDetail(category, "Height", () -> "" + size.getHeight());
                category = crashReport.addElement("Tooltip details");
                MCVer.addDetail(category, "Element", tooltip::toString);
                MCVer.addDetail(category, "Position", position::toString);
                MCVer.addDetail(category, "Size", tooltipSize::toString);
                throw new CrashException(crashReport);
            }
        }
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) CrashReport(net.minecraft.util.crash.CrashReport) OffsetGuiRenderer(de.johni0702.minecraft.gui.OffsetGuiRenderer) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) CrashReportSection(net.minecraft.util.crash.CrashReportSection) GuiElement(de.johni0702.minecraft.gui.element.GuiElement) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) CrashException(net.minecraft.util.crash.CrashException)

Example 10 with CrashReportSection

use of net.minecraft.util.crash.CrashReportSection in project fabric by FabricMC.

the class MixinSpriteAtlasTexture method beforeSpriteLoad.

// Handles DependentSprite + custom sprite object injections.
@ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/SpriteAtlasTexture;loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;"), method = "stitch")
public Set<Identifier> beforeSpriteLoad(Set<Identifier> set) {
    fabric_injectedSprites = new HashMap<>();
    ClientSpriteRegistryCallback.Registry registry = new ClientSpriteRegistryCallback.Registry(fabric_injectedSprites, set::add);
    // noinspection ConstantConditions
    for (Identifier id : fabric_localIds) {
        SpriteRegistryCallbackHolder.eventLocal(id).invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
    }
    SpriteRegistryCallbackHolder.EVENT_GLOBAL.invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry);
    // TODO: Unoptimized.
    Set<DependentSprite> dependentSprites = new HashSet<>();
    Set<Identifier> dependentSpriteIds = new HashSet<>();
    for (Identifier id : set) {
        Sprite sprite;
        if ((sprite = fabric_injectedSprites.get(id)) instanceof DependentSprite) {
            dependentSprites.add((DependentSprite) sprite);
            dependentSpriteIds.add(id);
        }
    }
    Set<Identifier> result = set;
    boolean isResultNew = false;
    if (!dependentSprites.isEmpty()) {
        if (!isResultNew) {
            result = new LinkedHashSet<>();
            isResultNew = true;
        }
        for (Identifier id : set) {
            if (!dependentSpriteIds.contains(id)) {
                result.add(id);
            }
        }
        int lastSpriteSize = 0;
        while (lastSpriteSize != result.size() && result.size() < set.size()) {
            lastSpriteSize = result.size();
            for (DependentSprite sprite : dependentSprites) {
                Identifier id = ((Sprite) sprite).getId();
                if (!result.contains(id) && result.containsAll(sprite.getDependencies())) {
                    result.add(id);
                }
            }
        }
        if (result.size() < set.size()) {
            CrashReport report = CrashReport.create(new Throwable(), "Resolving sprite dependencies");
            for (DependentSprite sprite : dependentSprites) {
                Identifier id = ((Sprite) sprite).getId();
                if (!result.contains(id)) {
                    CrashReportSection element = report.addElement("Unresolved sprite");
                    element.add("Sprite", id);
                    element.add("Dependencies", Joiner.on(',').join(sprite.getDependencies()));
                }
            }
            throw new CrashException(report);
        }
    }
    if (!fabric_injectedSprites.isEmpty()) {
        if (!isResultNew) {
            result = new LinkedHashSet<>(set);
            isResultNew = true;
        }
        result.removeAll(fabric_injectedSprites.keySet());
    }
    return result;
}
Also used : CrashException(net.minecraft.util.crash.CrashException) Sprite(net.minecraft.client.texture.Sprite) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection) Identifier(net.minecraft.util.Identifier) ClientSpriteRegistryCallback(net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Aggregations

CrashReportSection (net.minecraft.util.crash.CrashReportSection)12 CrashException (net.minecraft.util.crash.CrashException)11 CrashReport (net.minecraft.util.crash.CrashReport)11 GuiElement (de.johni0702.minecraft.gui.element.GuiElement)4 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)4 ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)4 OffsetGuiRenderer (de.johni0702.minecraft.gui.OffsetGuiRenderer)3 AbstractComposedGuiElement (de.johni0702.minecraft.gui.element.AbstractComposedGuiElement)2 ComposedGuiElement (de.johni0702.minecraft.gui.element.ComposedGuiElement)2 Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)2 FabricBakedModel (net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)1 DynamicBakedModel (grondag.frex.api.model.DynamicBakedModel)1 ClientSpriteRegistryCallback (net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback)1 BakedModel (net.minecraft.client.render.model.BakedModel)1 Sprite (net.minecraft.client.texture.Sprite)1 Identifier (net.minecraft.util.Identifier)1 ModifyVariable (org.spongepowered.asm.mixin.injection.ModifyVariable)1