Search in sources :

Example 11 with CrashReport

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

Example 12 with CrashReport

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

the class TerrainRenderContext method tesselateBlock.

/**
 * Called from chunk renderer hook.
 */
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model) {
    try {
        aoCalc.clear();
        blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
        chunkInfo.beginBlock();
        ((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 - Indigo Renderer");
        CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
        CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
        throw new CrashException(crashReport_1);
    }
    return chunkInfo.resultFlags[blockInfo.defaultLayerIndex];
}
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 13 with CrashReport

use of net.minecraft.util.crash.CrashReport in project databreaker by SuperCoder7979.

the class Databreaker method onInitialize.

@Override
public void onInitialize() {
    if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
        logger.info("I am become Databreaker, destroyer of loading times");
    } else {
        // Congrats on making it this far, use -Ddatabreaker.i_accept_responsibility_for_my_actions=true to have a chance of screwing up your world.
        if (System.getProperty("databreaker.i_accept_responsibility_for_my_actions", "false").equals("true")) {
            logger.warn("SUPERCODER79 IS NOT RESPONSIBLE FOR ANY DAMAGE CAUSED BY USING DATABREAKER IN A PRODUCTION ENVIRONMENT.");
            logger.warn("THERE IS A GOOD CHANCE THAT YOUR GAME WILL BE COMPLETELY SCREWED UP IF YOU LOAD UP A WORLD WITHOUT OPTIMIZING.");
            logger.warn("DO NOT USE DATABREAKER IN A NON-DEVELOPMENT ENVIRONMENT.");
        } else {
            // Please don't do it.
            throw new CrashException(new CrashReport("Do not use DataBreaker in a production environment.", new RuntimeException()));
        }
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport)

Example 14 with CrashReport

use of net.minecraft.util.crash.CrashReport in project Wurst7 by Wurst-Imperium.

the class CmdProcessor method runCmd.

private void runCmd(Command cmd, String input) {
    String[] args = input.split(" ");
    args = Arrays.copyOfRange(args, 1, args.length);
    try {
        cmd.call(args);
    } catch (CmdException e) {
        e.printToChat(cmd);
    } catch (Throwable e) {
        CrashReport report = CrashReport.create(e, "Running Wurst command");
        CrashReportSection section = report.addElement("Affected command");
        section.add("Command input", () -> input);
        throw new CrashException(report);
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 15 with CrashReport

use of net.minecraft.util.crash.CrashReport in project Wurst7 by Wurst-Imperium.

the class EventManager method fireImpl.

private <L extends Listener, E extends Event<L>> void fireImpl(E event) {
    if (!wurst.isEnabled())
        return;
    try {
        Class<L> type = event.getListenerType();
        @SuppressWarnings("unchecked") ArrayList<L> listeners = (ArrayList<L>) listenerMap.get(type);
        if (listeners == null || listeners.isEmpty())
            return;
        // Creating a copy of the list to avoid concurrent modification
        // issues.
        ArrayList<L> listeners2 = new ArrayList<>(listeners);
        // remove() sets an element to null before removing it. When one
        // thread calls remove() while another calls fire(), it is possible
        // for this list to contain null elements, which need to be filtered
        // out.
        listeners2.removeIf(Objects::isNull);
        event.fire(listeners2);
    } catch (Throwable e) {
        e.printStackTrace();
        CrashReport report = CrashReport.create(e, "Firing Wurst event");
        CrashReportSection section = report.addElement("Affected event");
        section.add("Event class", () -> event.getClass().getName());
        throw new CrashException(report);
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) CrashReport(net.minecraft.util.crash.CrashReport) ArrayList(java.util.ArrayList) Objects(java.util.Objects) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Aggregations

CrashException (net.minecraft.util.crash.CrashException)16 CrashReport (net.minecraft.util.crash.CrashReport)16 CrashReportSection (net.minecraft.util.crash.CrashReportSection)15 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 ArrayList (java.util.ArrayList)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 Objects (java.util.Objects)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