personthecat.catlib.mixin.TitleScreenMixin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of catlib-quilt Show documentation
Show all versions of catlib-quilt Show documentation
Utilities for serialization, commands, noise generation, IO, and some new data types.
The newest version!
package personthecat.catlib.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import personthecat.catlib.client.gui.LibErrorMenu;
import personthecat.catlib.event.error.LibErrorContext;
import personthecat.catlib.event.lifecycle.CheckErrorsEvent;
import personthecat.catlib.event.lifecycle.GameReadyEvent;
import java.util.concurrent.atomic.AtomicBoolean;
import net.minecraft.class_2561;
import net.minecraft.class_310;
import net.minecraft.class_437;
import net.minecraft.class_442;
@Mixin(class_442.class)
public abstract class TitleScreenMixin extends class_437 {
private static final AtomicBoolean INIT_COMPLETE = new AtomicBoolean(false);
protected TitleScreenMixin(final class_2561 title) {
super(title);
}
@Inject(method = "init", at = @At("TAIL"))
public void postInit(final CallbackInfo ci) {
if (INIT_COMPLETE.compareAndSet(false, true)) {
CheckErrorsEvent.EVENT.invoker().run();
if (LibErrorContext.hasErrors()) {
class_310.method_1551().method_1507(new LibErrorMenu(this));
} else {
GameReadyEvent.CLIENT.invoker().run();
}
}
}
}