Skip to content

Commit

Permalink
Replace old nullability comments with annotations (#2800)
Browse files Browse the repository at this point in the history
* Replace useless nullability comments with jetbrains annotation

* These were old comments

* Revert "These were old comments"

This reverts commit 4e9555ad51bc95a7bf12a2b33379d8eb03f57d2d.

* checkstyle + nullability in mixin
  • Loading branch information
SilverAndro authored Jan 2, 2023
1 parent 0a2a0d0 commit e498f5f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,7 +92,7 @@ public interface Before {
* @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
Expand All @@ -104,7 +106,7 @@ public interface After {
* @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
Expand All @@ -118,6 +120,6 @@ public interface Canceled {
* @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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.WeakHashMap;

import org.jetbrains.annotations.Nullable;

import net.minecraft.item.Item;

import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
Expand All @@ -43,8 +45,8 @@ public static void onBuild(Item.Settings settings, Item item) {
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,9 +34,11 @@
@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"))
Expand All @@ -44,22 +47,24 @@ private void onConstruct(Item.Settings settings, CallbackInfo info) {
}

@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -272,7 +273,7 @@ public EntityType<T> build() {
* @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) {
Expand Down

0 comments on commit e498f5f

Please sign in to comment.