From 9785ec356d948991a9bfaa11b72c1a4ef3f61711 Mon Sep 17 00:00:00 2001
From: Silver <52360088+SilverAndro@users.noreply.github.com>
Date: Mon, 2 Jan 2023 08:04:34 -0500
Subject: [PATCH] Replace old nullability comments with annotations (#2800)
* Replace useless nullability comments with jetbrains annotation
* These were old comments
* Revert "These were old comments"
This reverts commit 4e9555ad51bc95a7bf12a2b33379d8eb03f57d2d.
* checkstyle + nullability in mixin
(cherry picked from commit e498f5f0a9c300b253b134276a4a9456ad7aff0c)
---
.../fabric/api/event/player/PlayerBlockBreakEvents.java | 8 +++++---
.../fabricmc/fabric/impl/item/FabricItemInternals.java | 6 ++++--
.../net/fabricmc/fabric/impl/item/ItemExtensions.java | 6 ++++--
.../java/net/fabricmc/fabric/mixin/item/ItemMixin.java | 9 +++++++--
.../builder/v1/entity/FabricEntityTypeBuilder.java | 3 ++-
5 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/PlayerBlockBreakEvents.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/PlayerBlockBreakEvents.java
index acc977fab..7e28b2f1e 100644
--- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/PlayerBlockBreakEvents.java
+++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/PlayerBlockBreakEvents.java
@@ -16,6 +16,8 @@
package net.fabricmc.fabric.api.event.player;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -90,7 +92,7 @@ public final class PlayerBlockBreakEvents {
* @param blockEntity the block entity before the block is broken, can be {@code null}
* @return {@code false} to cancel block breaking action, or {@code true} to pass to next listener
*/
- boolean beforeBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, /* Nullable */ BlockEntity blockEntity);
+ boolean beforeBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity);
}
@FunctionalInterface
@@ -104,7 +106,7 @@ public final class PlayerBlockBreakEvents {
* @param state the block state before the block was broken
* @param blockEntity the block entity of the broken block, can be {@code null}
*/
- void afterBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, /* Nullable */ BlockEntity blockEntity);
+ void afterBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity);
}
@FunctionalInterface
@@ -118,6 +120,6 @@ public final class PlayerBlockBreakEvents {
* @param state the block state of the block that was going to be broken
* @param blockEntity the block entity of the block that was going to be broken, can be {@code null}
*/
- void onBlockBreakCanceled(World world, PlayerEntity player, BlockPos pos, BlockState state, /* Nullable */ BlockEntity blockEntity);
+ void onBlockBreakCanceled(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity);
}
}
diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/FabricItemInternals.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/FabricItemInternals.java
index fd35fd862..dc9936190 100644
--- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/FabricItemInternals.java
+++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/FabricItemInternals.java
@@ -18,6 +18,8 @@ package net.fabricmc.fabric.impl.item;
import java.util.WeakHashMap;
+import org.jetbrains.annotations.Nullable;
+
import net.minecraft.item.Item;
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
@@ -43,8 +45,8 @@ public final class FabricItemInternals {
}
public static final class ExtraData {
- private /* @Nullable */ EquipmentSlotProvider equipmentSlotProvider;
- private /* @Nullable */ CustomDamageHandler customDamageHandler;
+ private @Nullable EquipmentSlotProvider equipmentSlotProvider;
+ private @Nullable CustomDamageHandler customDamageHandler;
public void equipmentSlot(EquipmentSlotProvider equipmentSlotProvider) {
this.equipmentSlotProvider = equipmentSlotProvider;
diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/ItemExtensions.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/ItemExtensions.java
index 664a3e74e..ffd3c9082 100644
--- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/ItemExtensions.java
+++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/impl/item/ItemExtensions.java
@@ -16,12 +16,14 @@
package net.fabricmc.fabric.impl.item;
+import org.jetbrains.annotations.Nullable;
+
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider;
public interface ItemExtensions {
- /* @Nullable */ EquipmentSlotProvider fabric_getEquipmentSlotProvider();
+ @Nullable EquipmentSlotProvider fabric_getEquipmentSlotProvider();
void fabric_setEquipmentSlotProvider(EquipmentSlotProvider equipmentSlotProvider);
- /* @Nullable */ CustomDamageHandler fabric_getCustomDamageHandler();
+ @Nullable CustomDamageHandler fabric_getCustomDamageHandler();
void fabric_setCustomDamageHandler(CustomDamageHandler handler);
}
diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemMixin.java
index d23f58c89..8214295ee 100644
--- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemMixin.java
+++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemMixin.java
@@ -16,6 +16,7 @@
package net.fabricmc.fabric.mixin.item;
+import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -33,9 +34,11 @@ import net.fabricmc.fabric.impl.item.ItemExtensions;
@Mixin(Item.class)
abstract class ItemMixin implements ItemExtensions, FabricItem {
@Unique
+ @Nullable
private EquipmentSlotProvider equipmentSlotProvider;
@Unique
+ @Nullable
private CustomDamageHandler customDamageHandler;
@Inject(method = "", at = @At("RETURN"))
@@ -44,22 +47,24 @@ abstract class ItemMixin implements ItemExtensions, FabricItem {
}
@Override
+ @Nullable
public EquipmentSlotProvider fabric_getEquipmentSlotProvider() {
return equipmentSlotProvider;
}
@Override
- public void fabric_setEquipmentSlotProvider(EquipmentSlotProvider equipmentSlotProvider) {
+ public void fabric_setEquipmentSlotProvider(@Nullable EquipmentSlotProvider equipmentSlotProvider) {
this.equipmentSlotProvider = equipmentSlotProvider;
}
@Override
+ @Nullable
public CustomDamageHandler fabric_getCustomDamageHandler() {
return customDamageHandler;
}
@Override
- public void fabric_setCustomDamageHandler(CustomDamageHandler handler) {
+ public void fabric_setCustomDamageHandler(@Nullable CustomDamageHandler handler) {
this.customDamageHandler = handler;
}
}
diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java
index 5129a178f..db3e0f368 100644
--- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java
+++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java
@@ -20,6 +20,7 @@ import java.util.Objects;
import java.util.function.Supplier;
import com.google.common.collect.ImmutableSet;
+import org.jetbrains.annotations.Nullable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@@ -271,7 +272,7 @@ public class FabricEntityTypeBuilder {
* @param Entity class.
*/
public static class Living extends FabricEntityTypeBuilder {
- /* @Nullable */
+ @Nullable
private Supplier defaultAttributeBuilder;
protected Living(SpawnGroup spawnGroup, EntityType.EntityFactory function) {