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 4e9555ad51.

* checkstyle + nullability in mixin
This commit is contained in:
Silver 2023-01-02 08:04:34 -05:00 committed by GitHub
parent 0a2a0d0b13
commit e498f5f0a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

View file

@ -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 <strong>before</strong> 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 <strong>before</strong> 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);
}
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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 = "<init>", 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;
}
}

View file

@ -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.block.Block;
import net.minecraft.entity.Entity;
@ -272,7 +273,7 @@ public class FabricEntityTypeBuilder<T extends Entity> {
* @param <T> Entity class.
*/
public static class Living<T extends LivingEntity> extends FabricEntityTypeBuilder<T> {
/* @Nullable */
@Nullable
private Supplier<DefaultAttributeContainer.Builder> defaultAttributeBuilder;
protected Living(SpawnGroup spawnGroup, EntityType.EntityFactory<T> function) {