diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/block/BlockPickInteractionAware.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/block/BlockPickInteractionAware.java index 3689a1cc04..7d49b3155d 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/block/BlockPickInteractionAware.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/block/BlockPickInteractionAware.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.block; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -24,5 +26,5 @@ import net.minecraft.world.BlockView; public interface BlockPickInteractionAware { - ItemStack getPickedStack(BlockState state, BlockView view, BlockPos pos, /* nullable */ PlayerEntity player, /* nullable */ HitResult result); + ItemStack getPickedStack(BlockState state, BlockView view, BlockPos pos, @Nullable PlayerEntity player, @Nullable HitResult result); } diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityPickInteractionAware.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityPickInteractionAware.java index 7bf7e0c1b1..f32dfbf98e 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityPickInteractionAware.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityPickInteractionAware.java @@ -16,10 +16,12 @@ package net.fabricmc.fabric.api.entity; +import org.jetbrains.annotations.Nullable; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.hit.HitResult; public interface EntityPickInteractionAware { - ItemStack getPickedStack(/* nullable */ PlayerEntity player, /* nullable */ HitResult result); + ItemStack getPickedStack(@Nullable PlayerEntity player, @Nullable HitResult result); } diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/AttackEntityCallback.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/AttackEntityCallback.java index dfe348d1a4..2f23751776 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/AttackEntityCallback.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/AttackEntityCallback.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.event.player; +import org.jetbrains.annotations.Nullable; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; @@ -50,5 +52,5 @@ public interface AttackEntityCallback { } ); - ActionResult interact(PlayerEntity player, World world, Hand hand, Entity entity, /* Nullable */ EntityHitResult hitResult); + ActionResult interact(PlayerEntity player, World world, Hand hand, Entity entity, @Nullable EntityHitResult hitResult); } diff --git a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseEntityCallback.java b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseEntityCallback.java index 8ecc0a6096..67c78058a5 100644 --- a/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseEntityCallback.java +++ b/fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/api/event/player/UseEntityCallback.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.event.player; +import org.jetbrains.annotations.Nullable; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; @@ -50,5 +52,5 @@ public interface UseEntityCallback { } ); - ActionResult interact(PlayerEntity player, World world, Hand hand, Entity entity, /* Nullable */ EntityHitResult hitResult); + ActionResult interact(PlayerEntity player, World world, Hand hand, Entity entity, @Nullable EntityHitResult hitResult); } diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/GameRuleFactory.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/GameRuleFactory.java index 31f6c7374a..58d7079b88 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/GameRuleFactory.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/GameRuleFactory.java @@ -22,6 +22,7 @@ import com.mojang.brigadier.arguments.DoubleArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType; +import org.jetbrains.annotations.Nullable; import net.minecraft.server.MinecraftServer; import net.minecraft.world.GameRules; @@ -140,7 +141,7 @@ public static GameRules.Type createIntRule(int defaultValue, * @param changedCallback a callback that is invoked when the value of a game rule has changed * @return an integer rule type */ - public static GameRules.Type createIntRule(int defaultValue, int minimumValue, int maximumValue, /* @Nullable */ BiConsumer changedCallback) { + public static GameRules.Type createIntRule(int defaultValue, int minimumValue, int maximumValue, @Nullable BiConsumer changedCallback) { return new GameRules.Type<>( () -> IntegerArgumentType.integer(minimumValue, maximumValue), type -> new BoundedIntRule(type, defaultValue, minimumValue, maximumValue), // Internally use a bounded int rule diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/EnumRule.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/EnumRule.java index 61aa5401db..1cb64438b4 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/EnumRule.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/EnumRule.java @@ -26,6 +26,7 @@ import com.mojang.brigadier.context.CommandContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.Nullable; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; @@ -144,7 +145,7 @@ public boolean supports(E value) { return this.supportedValues.contains(value); } - public void set(E value, /* @Nullable */ MinecraftServer server) throws IllegalArgumentException { + public void set(E value, @Nullable MinecraftServer server) throws IllegalArgumentException { checkNotNull(value); if (!this.supports(value)) { diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/impl/gamerule/RuleKeyExtensions.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/impl/gamerule/RuleKeyExtensions.java index 7c5bbcd7db..81bb318814 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/impl/gamerule/RuleKeyExtensions.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/impl/gamerule/RuleKeyExtensions.java @@ -16,10 +16,12 @@ package net.fabricmc.fabric.impl.gamerule; +import org.jetbrains.annotations.Nullable; + import net.fabricmc.fabric.api.gamerule.v1.CustomGameRuleCategory; public interface RuleKeyExtensions { - /* @Nullable */ + @Nullable CustomGameRuleCategory fabric_getCustomCategory(); void fabric_setCustomCategory(CustomGameRuleCategory customCategory); diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/RuleKeyMixin.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/RuleKeyMixin.java index def90e399d..dbe3ecbd37 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/RuleKeyMixin.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/RuleKeyMixin.java @@ -16,6 +16,7 @@ package net.fabricmc.fabric.mixin.gamerule; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -26,8 +27,8 @@ @Mixin(GameRules.Key.class) public abstract class RuleKeyMixin implements RuleKeyExtensions { - /* @Nullable */ @Unique + @Nullable private CustomGameRuleCategory customCategory; @Override diff --git a/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelResourceProvider.java b/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelResourceProvider.java index b6544414c5..b7e7eb60b0 100644 --- a/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelResourceProvider.java +++ b/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelResourceProvider.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.model; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.util.Identifier; @@ -46,5 +48,6 @@ public interface ModelResourceProvider { * @return The loaded UnbakedModel, or null if this ModelResourceProvider doesn't handle a specific Identifier * (or if there was no error!). */ - /* @Nullable */ UnbakedModel loadModelResource(Identifier resourceId, ModelProviderContext context) throws ModelProviderException; + @Nullable + UnbakedModel loadModelResource(Identifier resourceId, ModelProviderContext context) throws ModelProviderException; } diff --git a/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelVariantProvider.java b/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelVariantProvider.java index 81bcf0dc37..b2ab8e6c5d 100644 --- a/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelVariantProvider.java +++ b/fabric-models-v0/src/main/java/net/fabricmc/fabric/api/client/model/ModelVariantProvider.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.model; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.util.ModelIdentifier; @@ -43,5 +45,6 @@ public interface ModelVariantProvider { * @return The loaded UnbakedModel, or null if this ModelVariantProvider doesn't handle a specific Identifier * (or if there was no error!). */ - /* @Nullable */ UnbakedModel loadModelVariant(ModelIdentifier modelId, ModelProviderContext context) throws ModelProviderException; + @Nullable + UnbakedModel loadModelVariant(ModelIdentifier modelId, ModelProviderContext context) throws ModelProviderException; } diff --git a/fabric-models-v0/src/main/java/net/fabricmc/fabric/impl/client/model/ModelLoadingRegistryImpl.java b/fabric-models-v0/src/main/java/net/fabricmc/fabric/impl/client/model/ModelLoadingRegistryImpl.java index 8951aec57a..7915634570 100644 --- a/fabric-models-v0/src/main/java/net/fabricmc/fabric/impl/client/model/ModelLoadingRegistryImpl.java +++ b/fabric-models-v0/src/main/java/net/fabricmc/fabric/impl/client/model/ModelLoadingRegistryImpl.java @@ -27,6 +27,7 @@ import com.google.common.collect.Lists; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.Nullable; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.UnbakedModel; @@ -139,12 +140,12 @@ private UnbakedModel loadCustomModel(CustomModelItf function, Collection< } } - /* @Nullable */ + @Nullable public UnbakedModel loadModelFromResource(Identifier resourceId) { return loadCustomModel((r) -> r.loadModelResource(resourceId, this), modelResourceProviders, "resource provider"); } - /* @Nullable */ + @Nullable public UnbakedModel loadModelFromVariant(Identifier variantId) { if (!(variantId instanceof ModelIdentifier)) { return loadModelFromResource(variantId); diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/villager/VillagerProfessionBuilder.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/villager/VillagerProfessionBuilder.java index bac223b0d1..7cb0e2f1f2 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/villager/VillagerProfessionBuilder.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/villager/VillagerProfessionBuilder.java @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.Nullable; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -46,7 +47,7 @@ public final class VillagerProfessionBuilder { private final ImmutableSet.Builder secondaryJobSiteBlockBuilder = ImmutableSet.builder(); private Identifier identifier; private PointOfInterestType pointOfInterestType; - /* @Nullable */ + @Nullable private SoundEvent workSoundEvent; private VillagerProfessionBuilder() { @@ -54,6 +55,7 @@ private VillagerProfessionBuilder() { /** * Creates a builder instance to allow for creation of a {@link VillagerProfession}. + * * @return A new builder. */ public static VillagerProfessionBuilder create() { @@ -140,7 +142,7 @@ public VillagerProfessionBuilder secondaryJobSites(Iterable blocks) { * @param workSoundEvent The {@link SoundEvent} to be played. * @return this builder. */ - public VillagerProfessionBuilder workSound(/* @Nullable */ SoundEvent workSoundEvent) { + public VillagerProfessionBuilder workSound(@Nullable SoundEvent workSoundEvent) { this.workSoundEvent = workSoundEvent; return this; } diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java index d72ef29e5f..826a4eaf38 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.List; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.tag.Tag; @@ -56,7 +58,8 @@ public static void onBuild(Block.Settings settings, Block block) { public static final class ExtraData { private final List miningLevels = new ArrayList<>(); - /* @Nullable */ private Boolean breakByHand; + @Nullable + private Boolean breakByHand; public ExtraData(Block.Settings settings) { } diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/VillagerProfessionAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/VillagerProfessionAccessor.java index 46bfb6c2a7..59be007946 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/VillagerProfessionAccessor.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/VillagerProfessionAccessor.java @@ -16,6 +16,7 @@ package net.fabricmc.fabric.mixin.object.builder; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; import com.google.common.collect.ImmutableSet; @@ -29,7 +30,7 @@ @Mixin(VillagerProfession.class) public interface VillagerProfessionAccessor { @Invoker("") - static VillagerProfession create(String id, PointOfInterestType type, ImmutableSet gatherableItems, ImmutableSet secondaryJobSites, /* @Nullable */ SoundEvent soundEvent) { + static VillagerProfession create(String id, PointOfInterestType type, ImmutableSet gatherableItems, ImmutableSet secondaryJobSites, @Nullable SoundEvent soundEvent) { throw new AssertionError("Untransformed accessor!"); } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistrySyncManager.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistrySyncManager.java index 28903074cd..3ef0973dfb 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistrySyncManager.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/RegistrySyncManager.java @@ -35,6 +35,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.Nullable; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Packet; @@ -105,7 +106,8 @@ public static void receivePacket(PacketContext context, PacketByteBuf buf, boole * @param activeTag contains the registry ids that were previously read and applied, can be null. * @return a {@link CompoundTag} to save or sync, null when empty */ - public static CompoundTag toTag(boolean isClientSync, CompoundTag activeTag) { + @Nullable + public static CompoundTag toTag(boolean isClientSync, @Nullable CompoundTag activeTag) { CompoundTag mainTag = new CompoundTag(); for (Identifier registryId : Registry.REGISTRIES.getIds()) { diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/Renderer.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/Renderer.java index da3b8749e3..9d364e6455 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/Renderer.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/Renderer.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.renderer.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder; @@ -50,6 +52,7 @@ public interface Renderer { * Return a material previously registered via {@link #registerMaterial(Identifier, RenderMaterial)}. * Will return null if no material was found matching the given identifier. */ + @Nullable RenderMaterial materialById(Identifier id); /** diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/RendererAccess.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/RendererAccess.java index 565b6db4ab..5c23d71779 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/RendererAccess.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/RendererAccess.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.renderer.v1; +import org.jetbrains.annotations.Nullable; + import net.fabricmc.fabric.impl.renderer.RendererAccessImpl; /** @@ -37,6 +39,7 @@ public interface RendererAccess { * Access to the current {@link Renderer} for creating and retrieving model builders * and materials. Will return null if no render plug in is active. */ + @Nullable Renderer getRenderer(); /** diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java index 77e093b698..31bc7ff641 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.renderer.v1.mesh; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.Vector3f; @@ -115,7 +117,8 @@ public interface MutableQuadView extends QuadView { * is computed based on face geometry and must be non-null in vanilla quads. * That computed value is returned by {@link #lightFace()}. */ - MutableQuadView cullFace(Direction face); + @Nullable + MutableQuadView cullFace(@Nullable Direction face); /** * Provides a hint to renderer about the facing of this quad. Not required, @@ -130,6 +133,7 @@ public interface MutableQuadView extends QuadView { *

Note: This value is not persisted independently when the quad is encoded. * When reading encoded quads, this value will always be the same as {@link #lightFace()}. */ + @Nullable MutableQuadView nominalFace(Direction face); /** diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadView.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadView.java index 952293be2a..203dc27969 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadView.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadView.java @@ -16,6 +16,9 @@ package net.fabricmc.fabric.api.renderer.v1.mesh; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.texture.Sprite; @@ -77,6 +80,7 @@ public interface QuadView { * calculations and will be the block face to which the quad is most closely aligned. Always * the same as cull face for quads that are on a block face, but never null. */ + @NotNull Direction lightFace(); /** @@ -85,7 +89,7 @@ public interface QuadView { * * @see MutableQuadView#cullFace(Direction) */ - Direction cullFace(); + @Nullable Direction cullFace(); /** * See {@link MutableQuadView#nominalFace(Direction)}. @@ -135,7 +139,7 @@ default BakedQuad toBakedQuad(int spriteIndex, Sprite sprite, boolean isItem) { * Pass a non-null target to avoid allocation - will be returned with values. * Otherwise returns a new instance. */ - Vector3f copyPos(int vertexIndex, Vector3f target); + Vector3f copyPos(int vertexIndex, @Nullable Vector3f target); /** * Convenience: access x, y, z by index 0-2. @@ -167,7 +171,8 @@ default BakedQuad toBakedQuad(int spriteIndex, Sprite sprite, boolean isItem) { * Pass a non-null target to avoid allocation - will be returned with values. * Otherwise returns a new instance. Returns null if normal not present. */ - Vector3f copyNormal(int vertexIndex, Vector3f target); + @Nullable + Vector3f copyNormal(int vertexIndex, @Nullable Vector3f target); /** * Will return {@link Float#NaN} if normal not present. diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ModelHelper.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ModelHelper.java index 6166cd67e5..507a050cd1 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ModelHelper.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ModelHelper.java @@ -20,6 +20,7 @@ import java.util.List; import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.Contract; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.model.BakedQuad; @@ -56,6 +57,7 @@ public static int toFaceIndex(Direction face) { * optionally including the null face. (Use < or <= {@link #NULL_FACE_ID} * to exclude or include the null value, respectively.) */ + @Contract("null -> null") public static Direction faceFromIndex(int faceIndex) { return FACES[faceIndex]; } diff --git a/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/GeometryHelper.java b/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/GeometryHelper.java index 6c81e80179..4eaec65dde 100644 --- a/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/GeometryHelper.java +++ b/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/GeometryHelper.java @@ -18,6 +18,8 @@ import static net.minecraft.util.math.MathHelper.approximatelyEquals; +import org.jetbrains.annotations.NotNull; + import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.util.math.Vector3f; import net.minecraft.util.math.Direction; @@ -114,7 +116,7 @@ public static boolean isParallelQuadOnFace(Direction lightFace, QuadView quad) { * * @param lightFace MUST be non-null. */ - public static boolean isQuadCubic(Direction lightFace, QuadView quad) { + public static boolean isQuadCubic(@NotNull Direction lightFace, QuadView quad) { if (lightFace == null) { return false; } diff --git a/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/NormalHelper.java b/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/NormalHelper.java index e6cf4c31d8..a437440471 100644 --- a/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/NormalHelper.java +++ b/fabric-renderer-indigo/src/main/java/net/fabricmc/fabric/impl/client/indigo/renderer/helper/NormalHelper.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.impl.client.indigo.renderer.helper; +import org.jetbrains.annotations.NotNull; + import net.minecraft.client.util.math.Vector3f; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; @@ -69,7 +71,7 @@ public static float getPackedNormalComponent(int packedNormal, int component) { *

Will work with triangles also. Assumes counter-clockwise winding order, which is the norm. * Expects convex quads with all points co-planar. */ - public static void computeFaceNormal(Vector3f saveTo, QuadView q) { + public static void computeFaceNormal(@NotNull Vector3f saveTo, QuadView q) { final Direction nominalFace = q.nominalFace(); if (GeometryHelper.isQuadParallelToFace(nominalFace, q)) { diff --git a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java b/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java index ca4c9916ce..d8ed54fb24 100644 --- a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java +++ b/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.rendering.data.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockRenderView; @@ -58,6 +60,7 @@ public interface RenderAttachedBlockView extends BlockRenderView { * * @param pos Position of the block for the block model. */ + @Nullable default Object getBlockEntityRenderAttachment(BlockPos pos) { BlockEntity be = ((BlockRenderView) this).getBlockEntity(pos); return be == null ? null : ((RenderAttachmentBlockEntity) be).getRenderAttachmentData(); diff --git a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java b/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java index 4cc023e4e5..c14d0a34e1 100644 --- a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java +++ b/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.rendering.data.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.entity.BlockEntity; /** @@ -35,5 +37,6 @@ public interface RenderAttachmentBlockEntity { /** * @return The model state data provided by this block entity. Can be null. */ + @Nullable Object getRenderAttachmentData(); } diff --git a/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandler.java b/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandler.java index 2d9def7381..bf2ceda73c 100644 --- a/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandler.java +++ b/fabric-rendering-fluids-v1/src/main/java/net/fabricmc/fabric/api/client/render/fluid/v1/FluidRenderHandler.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.render.fluid.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.texture.Sprite; import net.minecraft.fluid.FluidState; import net.minecraft.util.math.BlockPos; @@ -32,13 +34,13 @@ public interface FluidRenderHandler { * *

The "fabric-textures" module contains sprite rendering facilities, which may come in handy here. * - * @param view The world view pertaining to the fluid. May be null! - * @param pos The position of the fluid in the world. May be null! + * @param view The world view pertaining to the fluid. May be null! + * @param pos The position of the fluid in the world. May be null! * @param state The current state of the fluid. * @return An array of size two: the first entry contains the "still" sprite, * while the second entry contains the "flowing" sprite. */ - Sprite[] getFluidSprites(/* Nullable */ BlockRenderView view, /* Nullable */ BlockPos pos, FluidState state); + Sprite[] getFluidSprites(@Nullable BlockRenderView view, @Nullable BlockPos pos, FluidState state); /** * Get the tint color for a fluid being rendered at a given position. @@ -46,12 +48,12 @@ public interface FluidRenderHandler { *

Note: As of right now, our hook cannot handle setting a custom alpha * tint here - as such, it must be contained in the texture itself! * - * @param view The world view pertaining to the fluid. May be null! - * @param pos The position of the fluid in the world. May be null! + * @param view The world view pertaining to the fluid. May be null! + * @param pos The position of the fluid in the world. May be null! * @param state The current state of the fluid. * @return The tint color of the fluid. */ - default int getFluidColor(BlockRenderView view, BlockPos pos, FluidState state) { + default int getFluidColor(@Nullable BlockRenderView view, @Nullable BlockPos pos, FluidState state) { return -1; } } diff --git a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java index 5326ca6b9f..1b39226cda 100644 --- a/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java +++ b/fabric-rendering-v0/src/main/java/net/fabricmc/fabric/api/client/render/ColorProviderRegistry.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.render; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.client.color.block.BlockColorProvider; import net.minecraft.client.color.item.ItemColorProvider; @@ -67,5 +69,6 @@ public BlockColorProvider get(Block object) { * @param object The object to acquire the provide for. * @return The registered mapper for this provider, or {@code null} if none is registered or available. */ + @Nullable Provider get(T object); } diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java index ee2863d499..2c3c8ce9f3 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.rendering.v1; +import org.jetbrains.annotations.NotNull; + import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.util.math.MatrixStack; @@ -76,7 +78,7 @@ public interface BuiltinItemRendererRegistry { * @throws IllegalArgumentException if the item already has a registered renderer * @throws NullPointerException if either the item or the renderer is null */ - void register(ItemConvertible item, DynamicItemRenderer renderer); + void register(@NotNull ItemConvertible item, @NotNull DynamicItemRenderer renderer); /** * Dynamic item renderers render items with custom code. diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java index 44619153a4..f8fb4c28fb 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ColorProviderRegistry.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.rendering.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.client.color.block.BlockColorProvider; import net.minecraft.client.color.item.ItemColorProvider; @@ -45,5 +47,6 @@ public interface ColorProviderRegistry { * @param object The object to acquire the provide for. * @return The registered mapper for this provider, or {@code null} if none is registered or available. */ + @Nullable Provider get(T object); } diff --git a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java index ada9a560e6..ab3b6521ea 100644 --- a/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java +++ b/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/impl/client/rendering/BuiltinItemRendererRegistryImpl.java @@ -20,6 +20,8 @@ import java.util.Map; import java.util.Objects; +import org.jetbrains.annotations.Nullable; + import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; import net.minecraft.util.registry.Registry; @@ -61,7 +63,7 @@ public void register(ItemConvertible item, DynamicItemRenderer renderer) { } } - /* @Nullable */ + @Nullable public static DynamicItemRenderer getRenderer(Item item) { return RENDERERS.get(item); } diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java index 845251563e..a8f8313bdd 100644 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java +++ b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Multimap; +import org.jetbrains.annotations.Nullable; import net.minecraft.block.BlockState; import net.minecraft.entity.EquipmentSlot; @@ -42,9 +43,8 @@ public interface DynamicAttributeTool { * @return The mining level of the item. 3 is equal to a diamond pick. * @deprecated Use {@link #getMiningLevel(Tag, BlockState, ItemStack, LivingEntity)} to detect tag and block. */ - // nullable on user once we have an official @Nullable annotation in @Deprecated - default int getMiningLevel(ItemStack stack, /* @Nullable */ LivingEntity user) { + default int getMiningLevel(ItemStack stack, @Nullable LivingEntity user) { return 0; } @@ -57,8 +57,7 @@ default int getMiningLevel(ItemStack stack, /* @Nullable */ LivingEntity user) { * @param user The current user of the tool, or null if there isn't any * @return The mining level of the item. 3 is equal to a diamond pick. */ - // nullable on user once we have an official @Nullable annotation in - default int getMiningLevel(Tag tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + default int getMiningLevel(Tag tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { return getMiningLevel(stack, user); } @@ -70,9 +69,8 @@ default int getMiningLevel(Tag tag, BlockState state, ItemStack stack, /* * @return The mining speed multiplier of the item. 8.0 is equal to a diamond pick. * @deprecated Use {@link #getMiningSpeedMultiplier(Tag, BlockState, ItemStack, LivingEntity)} to detect tag and block. */ - // nullable on user once we have an official @Nullable annotation in @Deprecated - default float getMiningSpeedMultiplier(ItemStack stack, /* @Nullable */ LivingEntity user) { + default float getMiningSpeedMultiplier(ItemStack stack, @Nullable LivingEntity user) { return 1.0F; } @@ -85,8 +83,7 @@ default float getMiningSpeedMultiplier(ItemStack stack, /* @Nullable */ LivingEn * @param user The current user of the tool, or null if there isn't any * @return The mining speed multiplier of the item. 8.0 is equal to a diamond pick. */ - // nullable on user once we have an official @Nullable annotation in - default float getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + default float getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { return getMiningSpeedMultiplier(stack, user); } @@ -103,7 +100,7 @@ default float getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStac * @param isEffective whether the tool has been handled * @return the speed after post processing */ - default float postProcessMiningSpeed(Tag tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user, float currentSpeed, boolean isEffective) { + default float postProcessMiningSpeed(Tag tag, BlockState state, ItemStack stack, @Nullable LivingEntity user, float currentSpeed, boolean isEffective) { return currentSpeed; } @@ -117,8 +114,7 @@ default float postProcessMiningSpeed(Tag tag, BlockState state, ItemStack * @param user The current user of the tool, or none if there isn't any * @return The dynamic modifiers to add on top of other modifiers on this stack. If none, return {@link #EMPTY}. */ - // nullable on user once we have an official @Nullable annotation in - default Multimap getDynamicModifiers(EquipmentSlot slot, ItemStack stack, /* @Nullable */ LivingEntity user) { + default Multimap getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { return EMPTY; } } diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java index fb968f4dc1..ebffaeb991 100644 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java +++ b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.tool.attribute.v1; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; @@ -35,7 +37,7 @@ public final class ToolManager { * @param user the user involved in breaking the block, null if not applicable. * @return whether the tool is effective */ - public static boolean handleIsEffectiveOn(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + public static boolean handleIsEffectiveOn(BlockState state, ItemStack stack, @Nullable LivingEntity user) { return stack.isEffectiveOn(state) || handleIsEffectiveOnIgnoresVanilla(state, stack, user, false); } @@ -48,7 +50,7 @@ public static boolean handleIsEffectiveOn(BlockState state, ItemStack stack, /* * @param vanillaResult whether the tool is considered effective by vanilla * @return whether the tool is effective */ - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user, boolean vanillaResult) { + public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user, boolean vanillaResult) { return ToolManagerImpl.handleIsEffectiveOnIgnoresVanilla(state, stack, user, vanillaResult); } @@ -60,7 +62,7 @@ public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemSt * @param user the user involved in breaking the block, null if not applicable. * @return whether the tool is effective */ - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { return ToolManagerImpl.handleIsEffectiveOnIgnoresVanilla(state, stack, user, false); } @@ -72,7 +74,7 @@ public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemSt * @param user the user involved in breaking the block, null if not applicable. * @return the speed multiplier in breaking the block, 1.0 if no change. */ - public static float handleBreakingSpeed(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + public static float handleBreakingSpeed(BlockState state, ItemStack stack, @Nullable LivingEntity user) { return Math.max(stack.getMiningSpeedMultiplier(state), handleBreakingSpeedIgnoresVanilla(state, stack, user)); } @@ -84,7 +86,7 @@ public static float handleBreakingSpeed(BlockState state, ItemStack stack, /* @N * @param user the user involved in breaking the block, null if not applicable. * @return the speed multiplier in breaking the block, 1.0 if no change. */ - public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { return ToolManagerImpl.handleBreakingSpeedIgnoresVanilla(state, stack, user); } diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java index c4b39fb426..eec0982738 100644 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java +++ b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java @@ -22,6 +22,8 @@ import java.util.Map; import java.util.Objects; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; @@ -167,8 +169,7 @@ public static void registerBreakByTool(Block block, Tag tag, int miningLev /** * Hook for ItemStack.isEffectiveOn and similar methods. */ - //TODO: nullable on user once we have an official @Nullable annotation in - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, LivingEntity user, boolean vanillaResult) { + public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user, boolean vanillaResult) { for (Map.Entry, Event> eventEntry : HANDLER_MAP.entrySet()) { if (stack.getItem().isIn(eventEntry.getKey())) { ActionResult effective = eventEntry.getValue().invoker().isEffectiveOn(eventEntry.getKey(), state, stack, user); @@ -183,7 +184,7 @@ public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemSt return (entry != null && entry.defaultValue.get()) || (entry == null && vanillaResult); } - public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { float breakingSpeed = 0f; Tag handledTag = null; boolean handled = false; @@ -239,7 +240,7 @@ public interface ToolHandler { * @param user the user involved in breaking the block, null if not applicable. * @return the result of effectiveness */ - default ActionResult isEffectiveOn(Tag tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) { + default ActionResult isEffectiveOn(Tag tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { return ActionResult.PASS; } @@ -252,7 +253,7 @@ default ActionResult isEffectiveOn(Tag tag, BlockState state, ItemStack st * @param user the user involved in breaking the block, null if not applicable. * @return the result of mining speed. */ - default TypedActionResult getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStack stack, LivingEntity user) { + default TypedActionResult getMiningSpeedMultiplier(Tag tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { return null; } }