mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-28 10:36:43 -05:00
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 commit4e9555ad51
. * checkstyle + nullability in mixin (cherry picked from commite498f5f0a9
)
This commit is contained in:
parent
10eb22f456
commit
9785ec356d
5 changed files with 22 additions and 10 deletions
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package net.fabricmc.fabric.api.event.player;
|
package net.fabricmc.fabric.api.event.player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
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}
|
* @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
|
* @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
|
@FunctionalInterface
|
||||||
|
@ -104,7 +106,7 @@ public final class PlayerBlockBreakEvents {
|
||||||
* @param state the block state <strong>before</strong> the block was broken
|
* @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}
|
* @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
|
@FunctionalInterface
|
||||||
|
@ -118,6 +120,6 @@ public final class PlayerBlockBreakEvents {
|
||||||
* @param state the block state of the block that was going to be broken
|
* @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}
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package net.fabricmc.fabric.impl.item;
|
||||||
|
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
|
import net.fabricmc.fabric.api.item.v1.CustomDamageHandler;
|
||||||
|
@ -43,8 +45,8 @@ public final class FabricItemInternals {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ExtraData {
|
public static final class ExtraData {
|
||||||
private /* @Nullable */ EquipmentSlotProvider equipmentSlotProvider;
|
private @Nullable EquipmentSlotProvider equipmentSlotProvider;
|
||||||
private /* @Nullable */ CustomDamageHandler customDamageHandler;
|
private @Nullable CustomDamageHandler customDamageHandler;
|
||||||
|
|
||||||
public void equipmentSlot(EquipmentSlotProvider equipmentSlotProvider) {
|
public void equipmentSlot(EquipmentSlotProvider equipmentSlotProvider) {
|
||||||
this.equipmentSlotProvider = equipmentSlotProvider;
|
this.equipmentSlotProvider = equipmentSlotProvider;
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
|
|
||||||
package net.fabricmc.fabric.impl.item;
|
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.CustomDamageHandler;
|
||||||
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider;
|
import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider;
|
||||||
|
|
||||||
public interface ItemExtensions {
|
public interface ItemExtensions {
|
||||||
/* @Nullable */ EquipmentSlotProvider fabric_getEquipmentSlotProvider();
|
@Nullable EquipmentSlotProvider fabric_getEquipmentSlotProvider();
|
||||||
void fabric_setEquipmentSlotProvider(EquipmentSlotProvider equipmentSlotProvider);
|
void fabric_setEquipmentSlotProvider(EquipmentSlotProvider equipmentSlotProvider);
|
||||||
/* @Nullable */ CustomDamageHandler fabric_getCustomDamageHandler();
|
@Nullable CustomDamageHandler fabric_getCustomDamageHandler();
|
||||||
void fabric_setCustomDamageHandler(CustomDamageHandler handler);
|
void fabric_setCustomDamageHandler(CustomDamageHandler handler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package net.fabricmc.fabric.mixin.item;
|
package net.fabricmc.fabric.mixin.item;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -33,9 +34,11 @@ import net.fabricmc.fabric.impl.item.ItemExtensions;
|
||||||
@Mixin(Item.class)
|
@Mixin(Item.class)
|
||||||
abstract class ItemMixin implements ItemExtensions, FabricItem {
|
abstract class ItemMixin implements ItemExtensions, FabricItem {
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private EquipmentSlotProvider equipmentSlotProvider;
|
private EquipmentSlotProvider equipmentSlotProvider;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
|
@Nullable
|
||||||
private CustomDamageHandler customDamageHandler;
|
private CustomDamageHandler customDamageHandler;
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
|
@ -44,22 +47,24 @@ abstract class ItemMixin implements ItemExtensions, FabricItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public EquipmentSlotProvider fabric_getEquipmentSlotProvider() {
|
public EquipmentSlotProvider fabric_getEquipmentSlotProvider() {
|
||||||
return equipmentSlotProvider;
|
return equipmentSlotProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabric_setEquipmentSlotProvider(EquipmentSlotProvider equipmentSlotProvider) {
|
public void fabric_setEquipmentSlotProvider(@Nullable EquipmentSlotProvider equipmentSlotProvider) {
|
||||||
this.equipmentSlotProvider = equipmentSlotProvider;
|
this.equipmentSlotProvider = equipmentSlotProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public CustomDamageHandler fabric_getCustomDamageHandler() {
|
public CustomDamageHandler fabric_getCustomDamageHandler() {
|
||||||
return customDamageHandler;
|
return customDamageHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabric_setCustomDamageHandler(CustomDamageHandler handler) {
|
public void fabric_setCustomDamageHandler(@Nullable CustomDamageHandler handler) {
|
||||||
this.customDamageHandler = handler;
|
this.customDamageHandler = handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Objects;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -271,7 +272,7 @@ public class FabricEntityTypeBuilder<T extends Entity> {
|
||||||
* @param <T> Entity class.
|
* @param <T> Entity class.
|
||||||
*/
|
*/
|
||||||
public static class Living<T extends LivingEntity> extends FabricEntityTypeBuilder<T> {
|
public static class Living<T extends LivingEntity> extends FabricEntityTypeBuilder<T> {
|
||||||
/* @Nullable */
|
@Nullable
|
||||||
private Supplier<DefaultAttributeContainer.Builder> defaultAttributeBuilder;
|
private Supplier<DefaultAttributeContainer.Builder> defaultAttributeBuilder;
|
||||||
|
|
||||||
protected Living(SpawnGroup spawnGroup, EntityType.EntityFactory<T> function) {
|
protected Living(SpawnGroup spawnGroup, EntityType.EntityFactory<T> function) {
|
||||||
|
|
Loading…
Reference in a new issue