Skip to content

Commit 0e4cca3

Browse files
committed
Fix a bunch of nullability-related warnings
1 parent b388861 commit 0e4cca3

File tree

59 files changed

+168
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+168
-144
lines changed

src/client/java/aztech/modern_industrialization/client/MIRenderTypes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
import com.mojang.blaze3d.vertex.VertexFormat;
2929
import net.minecraft.client.renderer.RenderType;
3030
import net.minecraft.client.renderer.texture.TextureAtlas;
31+
import org.jspecify.annotations.Nullable;
3132

3233
public class MIRenderTypes {
33-
private static RenderType MACHINE_WRENCH_OVERLAY;
34-
private static RenderType CUTOUT_HIGHLIGHT; // used by hatch preview and wrong block highlight
34+
private static @Nullable RenderType MACHINE_WRENCH_OVERLAY;
35+
private static @Nullable RenderType CUTOUT_HIGHLIGHT; // used by hatch preview and wrong block highlight
3536

3637
public static RenderType machineOverlay() {
3738
if (MACHINE_WRENCH_OVERLAY == null) {

src/client/java/aztech/modern_industrialization/client/QuadCube.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737

3838
public class QuadCube {
3939
private final ResourceLocation spriteLocation;
40-
@Nullable
41-
private BakedQuad[] quads;
40+
private BakedQuad @Nullable [] quads;
4241

4342
public QuadCube(ResourceLocation spriteLocation) {
4443
this.spriteLocation = spriteLocation;

src/client/java/aztech/modern_industrialization/compat/sodium/SodiumCompat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class SodiumCompat {
5353
METHOD_HANDLE = handle;
5454
}
5555

56-
public static void markSpriteActive(TextureAtlasSprite sprite) {
56+
public static void markSpriteActive(@Nullable TextureAtlasSprite sprite) {
5757
if (sprite != null && METHOD_HANDLE != null) {
5858
try {
5959
METHOD_HANDLE.invokeExact(sprite);

src/client/java/aztech/modern_industrialization/compat/viewer/impl/emi/MachineStackProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ public EmiStackInteraction getStackAt(MachineScreen screen, int x, int y) {
4141
ConfigurableFluidStack stack = ((ConfigurableFluidStack.ConfigurableFluidSlot) slot).getConfStack();
4242
if (stack.getAmount() > 0) {
4343
Fluid fluid = stack.getResource().getFluid();
44-
if (fluid != null) {
45-
return new EmiStackInteraction(EmiStack.of(fluid), null, false);
46-
}
44+
return new EmiStackInteraction(EmiStack.of(fluid), null, false);
4745
} else if (stack.getLockedInstance() != null) {
4846
Fluid fluid = stack.getLockedInstance();
4947
if (fluid != null) {

src/client/java/aztech/modern_industrialization/compat/viewer/impl/rei/MachineFocusedStackProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public CompoundEventResult<EntryStack<?>> provide(Screen screen, Point mouse) {
4545
ConfigurableFluidStack stack = ((ConfigurableFluidStack.ConfigurableFluidSlot) slot).getConfStack();
4646
if (stack.getAmount() > 0) {
4747
Fluid fluid = stack.getResource().getFluid();
48-
if (fluid != null) {
49-
return CompoundEventResult.interruptTrue(EntryStacks.of(fluid));
50-
}
48+
return CompoundEventResult.interruptTrue(EntryStacks.of(fluid));
5149
} else if (stack.getLockedInstance() != null) {
5250
Fluid fluid = stack.getLockedInstance();
5351
if (fluid != null) {

src/client/java/aztech/modern_industrialization/datagen/model/MIModelProvider.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public MIModelProvider(PackOutput output, ExistingFileHelper exFileHelper) {
4646
@Override
4747
protected void registerStatesAndModels() {
4848
for (BlockDefinition<?> blockDefinition : MIBlock.BLOCK_DEFINITIONS.values()) {
49-
if (blockDefinition.modelGenerator != null) {
50-
blockDefinition.modelGenerator.accept(blockDefinition.asBlock(), this);
51-
}
49+
blockDefinition.modelGenerator.accept(blockDefinition.asBlock(), this);
5250
}
5351

5452
for (FluidDefinition fluidDefinition : MIFluids.FLUID_DEFINITIONS.values()) {
@@ -61,9 +59,7 @@ protected void registerStatesAndModels() {
6159

6260
// Item models as well...
6361
for (ItemDefinition<?> itemDefinition : MIItem.ITEM_DEFINITIONS.values()) {
64-
if (itemDefinition.modelGenerator != null) {
65-
itemDefinition.modelGenerator.accept(itemDefinition.asItem(), itemModels());
66-
}
62+
itemDefinition.modelGenerator.accept(itemDefinition.asItem(), itemModels());
6763
}
6864

6965
// Machine models

src/client/java/aztech/modern_industrialization/machines/MachineBlockEntityRenderer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@
5757
*/
5858
public class MachineBlockEntityRenderer<T extends MachineBlockEntity> implements BlockEntityRenderer<T> {
5959
private final BlockModelShaper blockModels;
60+
@Nullable
6061
private BlockState lastBlockState = null;
6162
@Nullable
6263
private MachineBakedModel model = null;
6364
private final IdentityHashMap<MachineCasing, Object[]> quadCache = new IdentityHashMap<>();
6465
private static final Object NO_QUAD = new Object();
6566

67+
@Nullable
6668
private static final MethodHandle UNWRAP_BAKED_MODEL;
6769
static {
6870
MethodHandle unwrapBakedModel = null;

src/client/java/aztech/modern_industrialization/machines/models/MachineUnbakedModel.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class MachineUnbakedModel implements IUnbakedGeometry<MachineUnbakedModel
5454
private static final Gson GSON = new GsonBuilder().registerTypeAdapter(ResourceLocation.class, new ResourceLocation.Serializer()).create();
5555

5656
private final MachineCasing baseCasing;
57-
private final Material[] defaultOverlays;
58-
private final Map<MachineCasing, Material[]> tieredOverlays = new HashMap<>();
57+
private final @Nullable Material[] defaultOverlays;
58+
private final Map<MachineCasing, @Nullable Material[]> tieredOverlays = new HashMap<>();
5959

6060
private MachineUnbakedModel(JsonObject obj) {
6161
this.baseCasing = MachineCasings.get(GsonHelper.getAsString(obj, "casing"));
@@ -81,7 +81,7 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Functio
8181
return new MachineBakedModel(baseCasing, defaultOverlays, tieredOverlays);
8282
}
8383

84-
private static TextureAtlasSprite[] loadSprites(Function<Material, TextureAtlasSprite> textureGetter, Material[] ids) {
84+
private static TextureAtlasSprite[] loadSprites(Function<Material, TextureAtlasSprite> textureGetter, @Nullable Material[] ids) {
8585
var sprites = new TextureAtlasSprite[ids.length];
8686
for (int i = 0; i < ids.length; ++i) {
8787
if (ids[i] != null) {
@@ -93,39 +93,39 @@ private static TextureAtlasSprite[] loadSprites(Function<Material, TextureAtlasS
9393

9494
private static class OverlaysJson {
9595
// All fields are nullable.
96-
private ResourceLocation top;
97-
private ResourceLocation top_active;
98-
private ResourceLocation side;
99-
private ResourceLocation side_active;
100-
private ResourceLocation bottom;
101-
private ResourceLocation bottom_active;
102-
private ResourceLocation front;
103-
private ResourceLocation front_active;
104-
private ResourceLocation left;
105-
private ResourceLocation left_active;
106-
private ResourceLocation right;
107-
private ResourceLocation right_active;
108-
private ResourceLocation back;
109-
private ResourceLocation back_active;
110-
private ResourceLocation top_s;
111-
private ResourceLocation top_s_active;
112-
private ResourceLocation top_w;
113-
private ResourceLocation top_w_active;
114-
private ResourceLocation top_n;
115-
private ResourceLocation top_n_active;
116-
private ResourceLocation top_e;
117-
private ResourceLocation top_e_active;
118-
private ResourceLocation bottom_s;
119-
private ResourceLocation bottom_s_active;
120-
private ResourceLocation bottom_w;
121-
private ResourceLocation bottom_w_active;
122-
private ResourceLocation bottom_n;
123-
private ResourceLocation bottom_n_active;
124-
private ResourceLocation bottom_e;
125-
private ResourceLocation bottom_e_active;
126-
private ResourceLocation output;
127-
private ResourceLocation item_auto;
128-
private ResourceLocation fluid_auto;
96+
private @Nullable ResourceLocation top;
97+
private @Nullable ResourceLocation top_active;
98+
private @Nullable ResourceLocation side;
99+
private @Nullable ResourceLocation side_active;
100+
private @Nullable ResourceLocation bottom;
101+
private @Nullable ResourceLocation bottom_active;
102+
private @Nullable ResourceLocation front;
103+
private @Nullable ResourceLocation front_active;
104+
private @Nullable ResourceLocation left;
105+
private @Nullable ResourceLocation left_active;
106+
private @Nullable ResourceLocation right;
107+
private @Nullable ResourceLocation right_active;
108+
private @Nullable ResourceLocation back;
109+
private @Nullable ResourceLocation back_active;
110+
private @Nullable ResourceLocation top_s;
111+
private @Nullable ResourceLocation top_s_active;
112+
private @Nullable ResourceLocation top_w;
113+
private @Nullable ResourceLocation top_w_active;
114+
private @Nullable ResourceLocation top_n;
115+
private @Nullable ResourceLocation top_n_active;
116+
private @Nullable ResourceLocation top_e;
117+
private @Nullable ResourceLocation top_e_active;
118+
private @Nullable ResourceLocation bottom_s;
119+
private @Nullable ResourceLocation bottom_s_active;
120+
private @Nullable ResourceLocation bottom_w;
121+
private @Nullable ResourceLocation bottom_w_active;
122+
private @Nullable ResourceLocation bottom_n;
123+
private @Nullable ResourceLocation bottom_n_active;
124+
private @Nullable ResourceLocation bottom_e;
125+
private @Nullable ResourceLocation bottom_e_active;
126+
private @Nullable ResourceLocation output;
127+
private @Nullable ResourceLocation item_auto;
128+
private @Nullable ResourceLocation fluid_auto;
129129

130130
private static OverlaysJson parse(JsonObject json, @Nullable OverlaysJson defaultOverlay) {
131131
var overlays = GSON.fromJson(json, OverlaysJson.class);
@@ -151,8 +151,8 @@ private static OverlaysJson parse(JsonObject json, @Nullable OverlaysJson defaul
151151
* Active and inactive: front, left, back, right, top S/W/N/E, bottom S/W/N/E,
152152
* output, item auto, fluid auto
153153
*/
154-
private Material[] toSpriteIds() {
155-
return new Material[] {
154+
private @Nullable Material[] toSpriteIds() {
155+
return new @Nullable Material[] {
156156
select(front, side),
157157
select(front_active, front, side_active, side),
158158
select(left, side),

src/client/java/aztech/modern_industrialization/machines/multiblocks/MultiblockMachineBER.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void render(MultiblockMachineBlockEntity be, float tickDelta, PoseStack m
7979
}
8080
}
8181
if (drawHighlights) {
82-
if (!matcher.matches(pos, be.getLevel(), null)) {
82+
if (!matcher.matches(pos, be.getLevel())) {
8383
var existingState = be.getLevel().getBlockState(pos);
8484
if (existingState.isAir() || /* approximate check for e.g. grass and snow */ existingState.canBeReplaced()) {
8585
// Enqueue state preview

src/client/java/aztech/modern_industrialization/pipes/fluid/FluidPipeScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void updateNetworkFluid() {
9797
if (iface.getNetworkFluid().isBlank()) {
9898
// Want to set the fluid
9999
FluidVariant fluid = FluidVariant.of(FluidUtil.getFluidContained(menu.getCarried()).orElse(FluidStack.EMPTY));
100-
if (fluid != null && !fluid.isBlank()) {
100+
if (!fluid.isBlank()) {
101101
targetFluid = fluid;
102102
}
103103
} else if (hasShiftDown()) {

0 commit comments

Comments
 (0)