use of net.minecraft.util.crash.CrashException 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();
}
use of net.minecraft.util.crash.CrashException 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);
}
}
}
use of net.minecraft.util.crash.CrashException 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);
}
}
}
}
use of net.minecraft.util.crash.CrashException 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);
}
}
use of net.minecraft.util.crash.CrashException 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;
}
Aggregations