Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dependencies {
compileOnly(libs.jetbrains.annotations)
implementation(libs.jspecify)

testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ modDevGradle = "2.0.86"
lombok = "8.14"

jetbrains-annotations = "26.0.1"
jspecify = "1.0.0"
renderNurse = "0.0.12"
mixin = "0.8.7"
evalEx = "3.6.0"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
minecraftForge = { module = "net.minecraftforge:forge", version.ref = "minecraftForge" }
jspecify = {module = "org.jspecify:jspecify", version.ref = "jspecify" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
renderNurse = { module = "net.neoforged:render-nurse", version.ref = "renderNurse" }
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
Expand Down
3 changes: 3 additions & 0 deletions logs/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[24Aug2026 20:32:27.493] [Test worker/DEBUG] [io.netty.util.internal.logging.InternalLoggerFactory/]: Using SLF4J as the default logging framework
[24Aug2026 20:32:27.496] [Test worker/DEBUG] [io.netty.util.ResourceLeakDetector/]: -Dio.netty.leakDetection.level: simple
[24Aug2026 20:32:27.496] [Test worker/DEBUG] [io.netty.util.ResourceLeakDetector/]: -Dio.netty.leakDetection.targetRecords: 4
Empty file added logs/latest.log
Empty file.
4 changes: 2 additions & 2 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# this is the highest directory lombok should search for config files
config.stopBubbling = true

# use jetbrains nullability annotations
lombok.addNullAnnotations = jetbrains
# use jspecify nullability annotations
lombok.addNullAnnotations = jspecify

# add annotations that @Getter and @Setter should copy from the field
lombok.copyableAnnotations += dev.latvian.mods.rhino.util.HideFromJS
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/brachy/modularui/ModularUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.nio.file.Path;
import java.util.function.Predicate;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/brachy/modularui/animation/Animator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import brachy.modularui.utils.Interpolation;

import lombok.Getter;
import org.jspecify.annotations.Nullable;

import java.util.concurrent.TimeUnit;
import java.util.function.DoubleConsumer;
Expand All @@ -19,8 +20,8 @@ public class Animator extends BaseAnimator<Animator> implements IAnimator {
private int duration = 250;
@Getter
private IInterpolation curve = Interpolation.LINEAR;
private DoublePredicate onUpdate;
private Runnable onFinish;
private @Nullable DoublePredicate onUpdate;
private @Nullable Runnable onFinish;

private int progress = 0;

Expand Down Expand Up @@ -180,7 +181,7 @@ public Animator curve(IInterpolation curve) {
* @param onUpdate update function
* @return this
*/
public Animator onUpdate(DoublePredicate onUpdate) {
public Animator onUpdate(@Nullable DoublePredicate onUpdate) {
this.onUpdate = onUpdate;
return this;
}
Expand All @@ -205,7 +206,7 @@ public Animator onUpdate(DoubleConsumer onUpdate) {
* @param onFinish finish function
* @return this
*/
public Animator onFinish(Runnable onFinish) {
public Animator onFinish(@Nullable Runnable onFinish) {
this.onFinish = onFinish;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public void onDraw(ScreenEvent.Render.Pre event) {
checkClearAnimators();
if (lastTime > 0 && !animators.isEmpty()) {
animators.removeIf(animator -> {
if (animator == null) return true;
if (animator.isPaused()) return false;
animator.advance(elapsedTime);
return !animator.isAnimating();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/brachy/modularui/animation/BaseAnimator.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package brachy.modularui.animation;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

public abstract class BaseAnimator<A extends BaseAnimator<A>> implements IAnimator {

private IAnimator parent;
private @Nullable IAnimator parent;
protected boolean reverseOnFinish = false;
protected int repeats = 0;

Expand All @@ -22,8 +22,7 @@ public A getThis() {
return (A) this;
}

@Nullable
public final IAnimator getParent() {
public final @Nullable IAnimator getParent() {
return parent;
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/brachy/modularui/animation/IAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import net.minecraft.Util;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

public interface IAnimator {

@Nullable
IAnimator getParent();
@Nullable IAnimator getParent();

default void animate(boolean reverse) {
reset(reverse);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package brachy.modularui.animation;

import org.jspecify.annotations.Nullable;

import java.util.function.Consumer;

public class MutableObjectAnimator<T extends IAnimatable<T>> extends Animator {

private final T from;
private final T to;
private final T animatable;
private Consumer<T> intermediateConsumer;
private @Nullable Consumer<T> intermediateConsumer;

public MutableObjectAnimator(T animatable, T from, T to) {
this.from = from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ParallelAnimator extends BaseAnimator<ParallelAnimator> implements
public ParallelAnimator(List<IAnimator> animators) {
this.animators = new ArrayList<>(animators);
this.animators.forEach(animator -> {
if (animator instanceof BaseAnimator baseAnimator) {
if (animator instanceof BaseAnimator<?> baseAnimator) {
baseAnimator.setParent(this);
}
});
Expand All @@ -26,7 +26,7 @@ public ParallelAnimator(IAnimator... animators) {
this.animators = new ArrayList<>();
Collections.addAll(this.animators, animators);
this.animators.forEach(animator -> {
if (animator instanceof BaseAnimator baseAnimator) {
if (animator instanceof BaseAnimator<?> baseAnimator) {
baseAnimator.setParent(this);
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/brachy/modularui/animation/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@NullMarked
package brachy.modularui.animation;

import org.jspecify.annotations.NullMarked;
2 changes: 0 additions & 2 deletions src/main/java/brachy/modularui/api/IMuiScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraftforge.api.distmarker.OnlyIn;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;

Expand All @@ -35,7 +34,6 @@ public interface IMuiScreen {
*
* @return the wrapped modular screen
*/
@NotNull
ModularScreen screen();

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/brachy/modularui/api/ISyncedAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import net.minecraft.network.FriendlyByteBuf;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

@FunctionalInterface
public interface ISyncedAction {

@ApiStatus.OverrideOnly
void invoke(@NotNull FriendlyByteBuf packet);
void invoke(FriendlyByteBuf packet);
}
4 changes: 1 addition & 3 deletions src/main/java/brachy/modularui/api/IThemeApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;
import org.jspecify.annotations.Nullable;

import java.util.List;

Expand Down Expand Up @@ -144,7 +143,6 @@ static IThemeApi get() {
* @param id id of the theme
* @return the found theme or {@link #getDefaultTheme()} if no theme was found
*/
@NotNull
ITheme getTheme(String id);

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/brachy/modularui/api/ITreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import brachy.modularui.utils.ObjectList;

import org.jspecify.annotations.Nullable;

import java.util.List;
import java.util.function.Predicate;

public interface ITreeNode<T extends ITreeNode<T>> {

T getParent();
@Nullable T getParent();

default boolean hasParent() {
return getParent() != null;
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/brachy/modularui/api/MCHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.List;

public class MCHelper {

@SuppressWarnings("DataFlowIssue")
@Nullable
@SideOnly(Side.CLIENT)
public static Minecraft getMc() {
public static @Nullable Minecraft getMc() {
return Minecraft.getInstance();
}

@Nullable
@SideOnly(Side.CLIENT)
public static Player getPlayer() {
public static @Nullable Player getPlayer() {
return getMc() == null ? null : getMc().player;
}

Expand Down Expand Up @@ -55,21 +53,22 @@ public static void popScreen(boolean openParentOnClose, Screen parent) {
}
}

public static void setScreen(Screen screen) {
public static void setScreen(@Nullable Screen screen) {
if (screen == null) {
closeScreen();
} else {
getMc().setScreen(screen);
Minecraft mc = getMc();
if (mc != null) mc.setScreen(screen);
}
}

@SideOnly(Side.CLIENT)
public static Screen getCurrentScreen() {
public static @Nullable Screen getCurrentScreen() {
return getMc() == null ? null : getMc().screen;
}

@SideOnly(Side.CLIENT)
public static Font getFont() {
public static @Nullable Font getFont() {
return getMc() == null ? null : getMc().font;
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/brachy/modularui/api/UIFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.minecraftforge.api.distmarker.OnlyIn;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.NonNull;

/**
* An interface for UI factories. They are responsible for opening synced GUIs and syncing necessary data.
Expand All @@ -30,7 +30,6 @@ public interface UIFactory<D extends GuiData> {
*
* @return the factory name
*/
@NotNull
ResourceLocation getFactoryName();

/**
Expand Down Expand Up @@ -112,7 +111,7 @@ default boolean canInteractWith(Player player, D guiData) {
* @param buffer buffer
* @return new gui data
*/
@NotNull
@NonNull
@ApiStatus.OverrideOnly
D readGuiData(Player player, FriendlyByteBuf buffer);
}
4 changes: 2 additions & 2 deletions src/main/java/brachy/modularui/api/drawable/IDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import net.minecraftforge.api.distmarker.OnlyIn;

import com.google.gson.JsonElement;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* An object which can be drawn at any size. This is mainly used for backgrounds and overlays in
Expand All @@ -31,7 +31,7 @@
*/
public interface IDrawable {

static IDrawable of(IDrawable... drawables) {
static @Nullable IDrawable of(IDrawable @Nullable... drawables) {
if (drawables == null || drawables.length == 0) {
return null;
} else if (drawables.length == 1) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/brachy/modularui/api/drawable/IHoverable.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import brachy.modularui.widget.sizer.Area;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* This marks an {@link IDrawable} as hoverable in a {@link RichText RichText}. This should not be
Expand All @@ -20,8 +20,7 @@ public interface IHoverable extends IIcon {
*/
default void onHover() {}

@Nullable
default RichTooltip getTooltip() {
default @Nullable RichTooltip getTooltip() {
return null;
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/brachy/modularui/api/drawable/IIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import net.minecraft.world.inventory.tooltip.TooltipComponent;

import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

/**
* A {@link IDrawable} with a fixed size.
Expand All @@ -18,8 +18,7 @@ public interface IIcon extends IDrawable, TooltipComponent {
/**
* @return the drawable this icon wraps or null if it doesn't wrap anything
*/
@Nullable
IDrawable getWrappedDrawable();
@Nullable IDrawable getWrappedDrawable();

/**
* @return width of this icon or 0 if the width should be dynamic
Expand Down Expand Up @@ -48,7 +47,7 @@ default int getDefaultHeight() {
/**
* @return the margin of this icon. Only used if width or height is 0
*/
Box getMargin();
@Nullable Box getMargin();

default IDrawable getRootDrawable() {
IDrawable drawable = this;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/brachy/modularui/api/drawable/ITextLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import net.minecraft.client.gui.Font;

import org.jspecify.annotations.Nullable;

public interface ITextLine {

int getWidth();
Expand All @@ -12,5 +14,5 @@ public interface ITextLine {

void draw(GuiContext context, Font font, float x, float y, int color, boolean shadow, int availableWidth, int availableHeight);

Object getHoveringElement(Font font, int x, int y);
@Nullable Object getHoveringElement(Font font, int x, int y);
}
Loading