mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
Add @Nullable and friends (#1007)
* Boost to Loom 0.5 Add null related annotations * Rearrange nullable to be overline * Fix anno sorting for picky * Add imports * Address feedback * Fix import
This commit is contained in:
parent
ca18475868
commit
5f10696617
32 changed files with 118 additions and 52 deletions
|
@ -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.util.math.BlockPos;
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.function.BiConsumer;
|
|||
|
||||
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 final class GameRuleFactory {
|
|||
* @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<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue, /* @Nullable */ BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback) {
|
||||
public static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue, @Nullable BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback) {
|
||||
return new GameRules.Type<>(
|
||||
() -> IntegerArgumentType.integer(minimumValue, maximumValue),
|
||||
type -> new BoundedIntRule(type, defaultValue, minimumValue, maximumValue), // Internally use a bounded int rule
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
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 final class EnumRule<E extends Enum<E>> extends GameRules.Rule<EnumRule<E
|
|||
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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 @@ import net.fabricmc.fabric.impl.gamerule.RuleKeyExtensions;
|
|||
|
||||
@Mixin(GameRules.Key.class)
|
||||
public abstract class RuleKeyMixin implements RuleKeyExtensions {
|
||||
/* @Nullable */
|
||||
@Unique
|
||||
@Nullable
|
||||
private CustomGameRuleCategory customCategory;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.stream.Collectors;
|
|||
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 @@ public class ModelLoadingRegistryImpl implements ModelLoadingRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
/* @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);
|
||||
|
|
|
@ -19,6 +19,7 @@ package net.fabricmc.fabric.api.object.builder.v1.villager;
|
|||
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<Block> secondaryJobSiteBlockBuilder = ImmutableSet.builder();
|
||||
private Identifier identifier;
|
||||
private PointOfInterestType pointOfInterestType;
|
||||
/* @Nullable */
|
||||
@Nullable
|
||||
private SoundEvent workSoundEvent;
|
||||
|
||||
private VillagerProfessionBuilder() {
|
||||
|
@ -54,6 +55,7 @@ public final class 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 final class VillagerProfessionBuilder {
|
|||
* @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;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package net.fabricmc.fabric.impl.object.builder;
|
|||
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 final class FabricBlockInternals {
|
|||
|
||||
public static final class ExtraData {
|
||||
private final List<MiningLevel> miningLevels = new ArrayList<>();
|
||||
/* @Nullable */ private Boolean breakByHand;
|
||||
@Nullable
|
||||
private Boolean breakByHand;
|
||||
|
||||
public ExtraData(Block.Settings settings) {
|
||||
}
|
||||
|
|
|
@ -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 @@ import net.minecraft.world.poi.PointOfInterestType;
|
|||
@Mixin(VillagerProfession.class)
|
||||
public interface VillagerProfessionAccessor {
|
||||
@Invoker("<init>")
|
||||
static VillagerProfession create(String id, PointOfInterestType type, ImmutableSet<Item> gatherableItems, ImmutableSet<Block> secondaryJobSites, /* @Nullable */ SoundEvent soundEvent) {
|
||||
static VillagerProfession create(String id, PointOfInterestType type, ImmutableSet<Item> gatherableItems, ImmutableSet<Block> secondaryJobSites, @Nullable SoundEvent soundEvent) {
|
||||
throw new AssertionError("Untransformed accessor!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
|||
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 final class RegistrySyncManager {
|
|||
* @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()) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
|||
* <p>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);
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 @@ public interface QuadView {
|
|||
* 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 @@ public interface QuadView {
|
|||
* 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.
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Arrays;
|
|||
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 abstract class ModelHelper {
|
|||
* 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];
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package net.fabricmc.fabric.impl.client.indigo.renderer.helper;
|
|||
|
||||
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 abstract class GeometryHelper {
|
|||
*
|
||||
* @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;
|
||||
}
|
||||
|
|
|
@ -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 abstract class NormalHelper {
|
|||
* <p>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)) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
*
|
||||
* <p>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 {
|
|||
* <p>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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 interface ColorProviderRegistry<T, Provider> {
|
|||
* @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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<T, Provider> {
|
|||
* @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);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.HashMap;
|
|||
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 final class BuiltinItemRendererRegistryImpl implements BuiltinItemRendere
|
|||
}
|
||||
}
|
||||
|
||||
/* @Nullable */
|
||||
@Nullable
|
||||
public static DynamicItemRenderer getRenderer(Item item) {
|
||||
return RENDERERS.get(item);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package net.fabricmc.fabric.api.tool.attribute.v1;
|
|||
|
||||
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 @@ public interface DynamicAttributeTool {
|
|||
* @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<Item> tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) {
|
||||
default int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) {
|
||||
return getMiningLevel(stack, user);
|
||||
}
|
||||
|
||||
|
@ -70,9 +69,8 @@ public interface DynamicAttributeTool {
|
|||
* @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 @@ public interface DynamicAttributeTool {
|
|||
* @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<Item> tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) {
|
||||
default float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) {
|
||||
return getMiningSpeedMultiplier(stack, user);
|
||||
}
|
||||
|
||||
|
@ -103,7 +100,7 @@ public interface DynamicAttributeTool {
|
|||
* @param isEffective whether the tool has been handled
|
||||
* @return the speed after post processing
|
||||
*/
|
||||
default float postProcessMiningSpeed(Tag<Item> tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user, float currentSpeed, boolean isEffective) {
|
||||
default float postProcessMiningSpeed(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user, float currentSpeed, boolean isEffective) {
|
||||
return currentSpeed;
|
||||
}
|
||||
|
||||
|
@ -117,8 +114,7 @@ public interface DynamicAttributeTool {
|
|||
* @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<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, /* @Nullable */ LivingEntity user) {
|
||||
default Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) {
|
||||
return EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 final class ToolManager {
|
|||
* @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 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 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 final class ToolManager {
|
|||
* @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 final class ToolManager {
|
|||
* @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);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.IdentityHashMap;
|
|||
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 final class ToolManagerImpl {
|
|||
/**
|
||||
* 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<Tag<Item>, Event<ToolHandler>> 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 final class ToolManagerImpl {
|
|||
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<Item> handledTag = null;
|
||||
boolean handled = false;
|
||||
|
@ -239,7 +240,7 @@ public final class ToolManagerImpl {
|
|||
* @param user the user involved in breaking the block, null if not applicable.
|
||||
* @return the result of effectiveness
|
||||
*/
|
||||
default ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, /* @Nullable */ LivingEntity user) {
|
||||
default ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
|
@ -252,7 +253,7 @@ public final class ToolManagerImpl {
|
|||
* @param user the user involved in breaking the block, null if not applicable.
|
||||
* @return the result of mining speed.
|
||||
*/
|
||||
default TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
default TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue