Search in sources :

Example 1 with CrashReport

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

the class LithiumServerTickScheduler method executeTicks.

public void executeTicks(Consumer<ScheduledTick<T>> consumer) {
    TickEntry<T> tick = null;
    try {
        // Execute all executing ticks
        ArrayList<TickEntry<T>> ticks = this.executingTicks;
        for (int i = 0, ticksSize = ticks.size(); i < ticksSize; i++) {
            tick = ticks.get(i);
            if (tick == null) {
                continue;
            }
            // Mark as consumed before execution per vanilla behaviour
            tick.consumed = true;
            // Perform tick execution
            consumer.accept(tick);
        }
    } catch (Throwable e) {
        CrashReport crash = CrashReport.create(e, "Exception while ticking");
        CrashReportSection section = crash.addElement("Block being ticked");
        CrashReportSection.addBlockInfo(section, tick == null ? BlockPos.ORIGIN : tick.pos, null);
        throw new CrashException(crash);
    }
    // We finished executing those ticks, so empty the list.
    this.executingTicks.clear();
    this.executingTicksSet.clear();
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 2 with CrashReport

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

the class AbstractGuiContainer method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    if (backgroundColor != null && renderInfo.getLayer() == 0) {
        renderer.drawRect(0, 0, size.getWidth(), size.getHeight(), backgroundColor);
    }
    for (final Map.Entry<GuiElement, Pair<ReadablePoint, ReadableDimension>> e : layedOutElements.entrySet()) {
        GuiElement element = e.getKey();
        boolean strict;
        if (element instanceof ComposedGuiElement) {
            if (((ComposedGuiElement) element).getMaxLayer() < renderInfo.layer) {
                continue;
            }
            strict = renderInfo.layer == 0;
        } else {
            if (element.getLayer() != renderInfo.layer) {
                continue;
            }
            strict = true;
        }
        final ReadablePoint ePosition = e.getValue().getLeft();
        final ReadableDimension eSize = e.getValue().getRight();
        try {
            OffsetGuiRenderer eRenderer = new OffsetGuiRenderer(renderer, ePosition, eSize, strict);
            eRenderer.startUsing();
            e.getKey().draw(eRenderer, eSize, renderInfo.offsetMouse(ePosition.getX(), ePosition.getY()).layer(renderInfo.getLayer() - e.getKey().getLayer()));
            eRenderer.stopUsing();
        } catch (Exception ex) {
            CrashReport crashReport = CrashReport.create(ex, "Rendering Gui");
            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());
            MCVer.addDetail(category, "Layout", layout::toString);
            category = crashReport.addElement("Gui element details");
            MCVer.addDetail(category, "Element", () -> e.getKey().toString());
            MCVer.addDetail(category, "Position", ePosition::toString);
            MCVer.addDetail(category, "Size", eSize::toString);
            if (e.getKey() instanceof GuiContainer) {
                MCVer.addDetail(category, "Layout", () -> ((GuiContainer) e.getKey()).getLayout().toString());
            }
            throw new CrashException(crashReport);
        }
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection) AbstractComposedGuiElement(de.johni0702.minecraft.gui.element.AbstractComposedGuiElement) ComposedGuiElement(de.johni0702.minecraft.gui.element.ComposedGuiElement) CrashException(net.minecraft.util.crash.CrashException) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) OffsetGuiRenderer(de.johni0702.minecraft.gui.OffsetGuiRenderer) AbstractComposedGuiElement(de.johni0702.minecraft.gui.element.AbstractComposedGuiElement) GuiElement(de.johni0702.minecraft.gui.element.GuiElement) ComposedGuiElement(de.johni0702.minecraft.gui.element.ComposedGuiElement) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with CrashReport

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

the class AbstractGuiScreen method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    if (renderInfo.layer == 0) {
        switch(background) {
            case NONE:
                break;
            case DEFAULT:
                // #if MC>=11600
                wrapped.renderBackground(renderer.getMatrixStack());
                // #endif
                break;
            case TRANSPARENT:
                int top = 0xc0_10_10_10, bottom = 0xd0_10_10_10;
                renderer.drawRect(0, 0, size.getWidth(), size.getHeight(), top, top, bottom, bottom);
                break;
            case DIRT:
                // #if MC>=11600
                wrapped.renderBackgroundTexture(0);
                // #endif
                break;
        }
        if (title != null) {
            ReadableDimension titleSize = title.getMinSize();
            int x = screenSize.getWidth() / 2 - titleSize.getWidth() / 2;
            OffsetGuiRenderer eRenderer = new OffsetGuiRenderer(renderer, new Point(x, 10), new Dimension(0, 0));
            title.draw(eRenderer, titleSize, renderInfo);
        }
    }
    super.draw(renderer, size, renderInfo);
    if (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) Dimension(de.johni0702.minecraft.gui.utils.lwjgl.Dimension) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) 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 4 with CrashReport

use of net.minecraft.util.crash.CrashReport in project canvas by vram-guild.

the class TerrainRenderContext method tesselateBlock.

/**
 * Called from chunk renderer hook.
 */
public void tesselateBlock(BlockState blockState, BlockPos blockPos) {
    try {
        final BakedModel model = blockRenderManager.getModel(blockState);
        aoCalc.clear();
        blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
        chunkInfo.beginBlock();
        ((DynamicBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
    } catch (final Throwable var9) {
        final CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Canvas Renderer");
        final CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
        CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
        throw new CrashException(crashReport_1);
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) DynamicBakedModel(grondag.frex.api.model.DynamicBakedModel) CrashReport(net.minecraft.util.crash.CrashReport) BakedModel(net.minecraft.client.render.model.BakedModel) DynamicBakedModel(grondag.frex.api.model.DynamicBakedModel) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 5 with CrashReport

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

Aggregations

CrashException (net.minecraft.util.crash.CrashException)11 CrashReport (net.minecraft.util.crash.CrashReport)11 CrashReportSection (net.minecraft.util.crash.CrashReportSection)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