1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

Default Forge/Common API to non-null

This commit is contained in:
Jonathan Coates 2022-11-06 15:50:24 +00:00
parent 76710eec9d
commit 955b9c7d28
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
45 changed files with 161 additions and 246 deletions

View File

@ -7,6 +7,7 @@ import cc.tweaked.gradle.MinecraftConfigurations
plugins {
id("cc-tweaked.java-convention")
id("cc-tweaked.errorprone")
id("net.minecraftforge.gradle")
id("org.parchmentmc.librarian.forgegradle")
}

View File

@ -6,6 +6,7 @@ import cc.tweaked.gradle.MinecraftConfigurations
plugins {
id("cc-tweaked.java-convention")
id("cc-tweaked.errorprone")
id("org.spongepowered.gradle.vanilla")
}

View File

@ -10,7 +10,6 @@
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
import dan200.computercraft.impl.client.ComputerCraftAPIClientService;
import javax.annotation.Nonnull;
public final class ComputerCraftAPIClient {
private ComputerCraftAPIClient() {
@ -26,11 +25,10 @@ private ComputerCraftAPIClient() {
* @param modeller The upgrade modeller.
* @param <T> The type of the turtle upgrade.
*/
public static <T extends ITurtleUpgrade> void registerTurtleUpgradeModeller(@Nonnull TurtleUpgradeSerialiser<T> serialiser, @Nonnull TurtleUpgradeModeller<T> modeller) {
public static <T extends ITurtleUpgrade> void registerTurtleUpgradeModeller(TurtleUpgradeSerialiser<T> serialiser, TurtleUpgradeModeller<T> modeller) {
getInstance().registerTurtleUpgradeModeller(serialiser, modeller);
}
@Nonnull
private static ComputerCraftAPIClientService getInstance() {
return ComputerCraftAPIClientService.get();
}

View File

@ -13,7 +13,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.Objects;
/**
@ -23,37 +22,35 @@ public final class TransformedModel {
private final BakedModel model;
private final Transformation matrix;
public TransformedModel(@Nonnull BakedModel model, @Nonnull Transformation matrix) {
public TransformedModel(BakedModel model, Transformation matrix) {
this.model = Objects.requireNonNull(model);
this.matrix = Objects.requireNonNull(matrix);
}
public TransformedModel(@Nonnull BakedModel model) {
public TransformedModel(BakedModel model) {
this.model = Objects.requireNonNull(model);
matrix = Transformation.identity();
}
public static TransformedModel of(@Nonnull ModelResourceLocation location) {
public static TransformedModel of(ModelResourceLocation location) {
var modelManager = Minecraft.getInstance().getModelManager();
return new TransformedModel(modelManager.getModel(location));
}
public static TransformedModel of(@Nonnull ResourceLocation location) {
public static TransformedModel of(ResourceLocation location) {
var modelManager = Minecraft.getInstance().getModelManager();
return new TransformedModel(ClientPlatformHelper.get().getModel(modelManager, location));
}
public static TransformedModel of(@Nonnull ItemStack item, @Nonnull Transformation transform) {
public static TransformedModel of(ItemStack item, Transformation transform) {
var model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel(item);
return new TransformedModel(model, transform);
}
@Nonnull
public BakedModel getModel() {
return model;
}
@Nonnull
public Transformation getMatrix() {
return matrix;
}

View File

@ -14,7 +14,6 @@
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -34,8 +33,7 @@ public interface TurtleUpgradeModeller<T extends ITurtleUpgrade> {
* @param side Which side of the turtle (left or right) the upgrade resides on.
* @return The model that you wish to be used to render your upgrade.
*/
@Nonnull
TransformedModel getModel(@Nonnull T upgrade, @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side);
TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, TurtleSide side);
/**
* A basic {@link TurtleUpgradeModeller} which renders using the upgrade's {@linkplain ITurtleUpgrade#getCraftingItem()

View File

@ -12,7 +12,6 @@
import dan200.computercraft.impl.Services;
import org.jetbrains.annotations.ApiStatus;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -27,7 +26,7 @@ static ComputerCraftAPIClientService get() {
return instance == null ? Services.raise(ComputerCraftAPIClientService.class, Instance.ERROR) : instance;
}
<T extends ITurtleUpgrade> void registerTurtleUpgradeModeller(@Nonnull TurtleUpgradeSerialiser<T> serialiser, @Nonnull TurtleUpgradeModeller<T> modeller);
<T extends ITurtleUpgrade> void registerTurtleUpgradeModeller(TurtleUpgradeSerialiser<T> serialiser, TurtleUpgradeModeller<T> modeller);
final class Instance {
static final @Nullable ComputerCraftAPIClientService INSTANCE;

View File

@ -31,7 +31,6 @@
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -43,7 +42,6 @@
public final class ComputerCraftAPI {
public static final String MOD_ID = "computercraft";
@Nonnull
public static String getInstalledVersion() {
return getInstance().getInstalledVersion();
}
@ -61,7 +59,7 @@ public static String getInstalledVersion() {
* available for writing.
* @see #createSaveDirMount(Level, String, long)
*/
public static int createUniqueNumberedSaveDir(@Nonnull Level world, @Nonnull String parentSubPath) {
public static int createUniqueNumberedSaveDir(Level world, String parentSubPath) {
return getInstance().createUniqueNumberedSaveDir(world, parentSubPath);
}
@ -84,7 +82,7 @@ public static int createUniqueNumberedSaveDir(@Nonnull Level world, @Nonnull Str
* @see IWritableMount
*/
@Nullable
public static IWritableMount createSaveDirMount(@Nonnull Level world, @Nonnull String subPath, long capacity) {
public static IWritableMount createSaveDirMount(Level world, String subPath, long capacity) {
return getInstance().createSaveDirMount(world, subPath, capacity);
}
@ -107,7 +105,7 @@ public static IWritableMount createSaveDirMount(@Nonnull Level world, @Nonnull S
* @see IMount
*/
@Nullable
public static IMount createResourceMount(@Nonnull String domain, @Nonnull String subPath) {
public static IMount createResourceMount(String domain, String subPath) {
return getInstance().createResourceMount(domain, subPath);
}
@ -120,7 +118,7 @@ public static IMount createResourceMount(@Nonnull String domain, @Nonnull String
* @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)} instead.
*/
@Deprecated(forRemoval = true)
public static void registerPeripheralProvider(@Nonnull IPeripheralProvider provider) {
public static void registerPeripheralProvider(IPeripheralProvider provider) {
getInstance().registerPeripheralProvider(provider);
}
@ -130,7 +128,7 @@ public static void registerPeripheralProvider(@Nonnull IPeripheralProvider provi
* @param source The method source to register.
* @see GenericSource
*/
public static void registerGenericSource(@Nonnull GenericSource source) {
public static void registerGenericSource(GenericSource source) {
getInstance().registerGenericSource(source);
}
@ -142,7 +140,7 @@ public static void registerGenericSource(@Nonnull GenericSource source) {
* @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI} instead.
*/
@Deprecated(forRemoval = true)
public static void registerGenericCapability(@Nonnull Capability<?> capability) {
public static void registerGenericCapability(Capability<?> capability) {
getInstance().registerGenericCapability(capability);
}
@ -152,7 +150,7 @@ public static void registerGenericCapability(@Nonnull Capability<?> capability)
* @param provider The bundled redstone provider to register.
* @see IBundledRedstoneProvider
*/
public static void registerBundledRedstoneProvider(@Nonnull IBundledRedstoneProvider provider) {
public static void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) {
getInstance().registerBundledRedstoneProvider(provider);
}
@ -166,7 +164,7 @@ public static void registerBundledRedstoneProvider(@Nonnull IBundledRedstoneProv
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
* @see IBundledRedstoneProvider
*/
public static int getBundledRedstoneOutput(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side) {
public static int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side) {
return getInstance().getBundledRedstoneOutput(world, pos, side);
}
@ -176,7 +174,7 @@ public static int getBundledRedstoneOutput(@Nonnull Level world, @Nonnull BlockP
* @param provider The media provider to register.
* @see IMediaProvider
*/
public static void registerMediaProvider(@Nonnull IMediaProvider provider) {
public static void registerMediaProvider(IMediaProvider provider) {
getInstance().registerMediaProvider(provider);
}
@ -189,7 +187,7 @@ public static IPacketNetwork getWirelessNetwork() {
return getInstance().getWirelessNetwork();
}
public static void registerAPIFactory(@Nonnull ILuaAPIFactory factory) {
public static void registerAPIFactory(ILuaAPIFactory factory) {
getInstance().registerAPIFactory(factory);
}
@ -204,7 +202,7 @@ public static void registerAPIFactory(@Nonnull ILuaAPIFactory factory) {
* @deprecated Use {@link DetailRegistry#addProvider(IDetailProvider)} to register your provider.
*/
@Deprecated(forRemoval = true)
public static <T> void registerDetailProvider(@Nonnull Class<T> type, @Nonnull IDetailProvider<T> provider) {
public static <T> void registerDetailProvider(Class<T> type, IDetailProvider<T> provider) {
getInstance().registerDetailProvider(type, provider);
}
@ -215,8 +213,7 @@ public static <T> void registerDetailProvider(@Nonnull Class<T> type, @Nonnull I
* @return The element's node
* @see IWiredElement#getNode()
*/
@Nonnull
public static IWiredNode createWiredNodeForElement(@Nonnull IWiredElement element) {
public static IWiredNode createWiredNodeForElement(IWiredElement element) {
return getInstance().createWiredNodeForElement(element);
}
@ -230,17 +227,15 @@ public static IWiredNode createWiredNodeForElement(@Nonnull IWiredElement elemen
* @see IWiredElement#getNode()
* @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI#getWiredElementAt(BlockGetter, BlockPos, Direction)}
*/
@Nonnull
@Deprecated(forRemoval = true)
public static LazyOptional<IWiredElement> getWiredElementAt(@Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side) {
public static LazyOptional<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
return getInstance().getWiredElementAt(world, pos, side);
}
public static void registerRefuelHandler(@Nonnull TurtleRefuelHandler handler) {
public static void registerRefuelHandler(TurtleRefuelHandler handler) {
getInstance().registerRefuelHandler(handler);
}
@Nonnull
private static ComputerCraftAPIService getInstance() {
return ComputerCraftAPIService.get();
}

View File

@ -8,7 +8,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@ -20,7 +20,7 @@
*/
public abstract class BasicItemDetailProvider<T> implements IDetailProvider<ItemStack> {
private final Class<T> itemType;
private final String namespace;
private final @Nullable String namespace;
/**
* Create a new item detail provider. Meta will be inserted into a new sub-map named as per {@code namespace}.
@ -28,7 +28,7 @@ public abstract class BasicItemDetailProvider<T> implements IDetailProvider<Item
* @param itemType The type the stack's item must have.
* @param namespace The namespace to use for this provider.
*/
public BasicItemDetailProvider(String namespace, @Nonnull Class<T> itemType) {
public BasicItemDetailProvider(@Nullable String namespace, Class<T> itemType) {
Objects.requireNonNull(itemType);
this.itemType = itemType;
this.namespace = namespace;
@ -39,7 +39,7 @@ public BasicItemDetailProvider(String namespace, @Nonnull Class<T> itemType) {
*
* @param itemType The type the stack's item must have.
*/
public BasicItemDetailProvider(@Nonnull Class<T> itemType) {
public BasicItemDetailProvider(Class<T> itemType) {
this(null, itemType);
}
@ -54,11 +54,12 @@ public BasicItemDetailProvider(@Nonnull Class<T> itemType) {
* @param stack The item stack to provide details for.
* @param item The item to provide details for.
*/
public abstract void provideDetails(@Nonnull Map<? super String, Object> data, @Nonnull ItemStack stack,
@Nonnull T item);
public abstract void provideDetails(
Map<? super String, Object> data, ItemStack stack, T item
);
@Override
public void provideDetails(@Nonnull Map<? super String, Object> data, @Nonnull ItemStack stack) {
public void provideDetails(Map<? super String, Object> data, ItemStack stack) {
var item = stack.getItem();
if (!itemType.isInstance(item)) return;

View File

@ -10,7 +10,6 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -22,9 +21,9 @@
* @param blockEntity The block entity at this position, if it exists.
*/
public record BlockReference(
@Nonnull Level level,
@Nonnull BlockPos pos,
@Nonnull BlockState state,
Level level,
BlockPos pos,
BlockState state,
@Nullable BlockEntity blockEntity
) {
public BlockReference(Level level, BlockPos pos) {

View File

@ -5,7 +5,6 @@
*/
package dan200.computercraft.api.detail;
import javax.annotation.Nonnull;
import java.util.Map;
/**
@ -30,5 +29,5 @@ public interface IDetailProvider<T> {
* @param data The full details to be returned. New properties should be added to this map.
* @param object The object to provide details for.
*/
void provideDetails(@Nonnull Map<? super String, Object> data, @Nonnull T object);
void provideDetails(Map<? super String, Object> data, T object);
}

View File

@ -11,7 +11,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -28,7 +27,7 @@ public interface IMedia {
* @return The label. ie: "Dan's Programs".
*/
@Nullable
String getLabel(@Nonnull ItemStack stack);
String getLabel(ItemStack stack);
/**
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
@ -37,7 +36,7 @@ public interface IMedia {
* @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified.
*/
default boolean setLabel(@Nonnull ItemStack stack, @Nullable String label) {
default boolean setLabel(ItemStack stack, @Nullable String label) {
return false;
}
@ -49,7 +48,7 @@ default boolean setLabel(@Nonnull ItemStack stack, @Nullable String label) {
* @return The name, or null if this item does not represent an item with audio.
*/
@Nullable
default String getAudioTitle(@Nonnull ItemStack stack) {
default String getAudioTitle(ItemStack stack) {
return null;
}
@ -60,7 +59,7 @@ default String getAudioTitle(@Nonnull ItemStack stack) {
* @return The name, or null if this item does not represent an item with audio.
*/
@Nullable
default SoundEvent getAudio(@Nonnull ItemStack stack) {
default SoundEvent getAudio(ItemStack stack) {
return null;
}
@ -78,7 +77,7 @@ default SoundEvent getAudio(@Nonnull ItemStack stack) {
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String)
*/
@Nullable
default IMount createDataMount(@Nonnull ItemStack stack, @Nonnull Level world) {
default IMount createDataMount(ItemStack stack, Level world) {
return null;
}
}

View File

@ -7,7 +7,6 @@
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -25,5 +24,5 @@ public interface IMediaProvider {
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
*/
@Nullable
IMedia getMedia(@Nonnull ItemStack stack);
IMedia getMedia(ItemStack stack);
}

View File

@ -5,7 +5,6 @@
*/
package dan200.computercraft.api.network;
import javax.annotation.Nonnull;
/**
* A packet network represents a collection of devices which can send and receive packets.
@ -19,14 +18,14 @@ public interface IPacketNetwork {
*
* @param receiver The receiver to register to the network.
*/
void addReceiver(@Nonnull IPacketReceiver receiver);
void addReceiver(IPacketReceiver receiver);
/**
* Remove a receiver from the network.
*
* @param receiver The device to remove from the network.
*/
void removeReceiver(@Nonnull IPacketReceiver receiver);
void removeReceiver(IPacketReceiver receiver);
/**
* Determine whether this network is wireless.
@ -44,7 +43,7 @@ public interface IPacketNetwork {
* @see #transmitInterdimensional(Packet)
* @see IPacketReceiver#receiveSameDimension(Packet, double)
*/
void transmitSameDimension(@Nonnull Packet packet, double range);
void transmitSameDimension(Packet packet, double range);
/**
* Submit a packet for transmitting across the network. This will route the packet through the network, sending it
@ -54,5 +53,5 @@ public interface IPacketNetwork {
* @see #transmitSameDimension(Packet, double)
* @see IPacketReceiver#receiveDifferentDimension(Packet)
*/
void transmitInterdimensional(@Nonnull Packet packet);
void transmitInterdimensional(Packet packet);
}

View File

@ -8,7 +8,6 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull;
/**
* An object on an {@link IPacketNetwork}, capable of receiving packets.
@ -19,7 +18,6 @@ public interface IPacketReceiver {
*
* @return The receivers's world.
*/
@Nonnull
Level getLevel();
/**
@ -27,7 +25,6 @@ public interface IPacketReceiver {
*
* @return The receiver's position.
*/
@Nonnull
Vec3 getPosition();
/**
@ -67,7 +64,7 @@ public interface IPacketReceiver {
* @see IPacketNetwork#transmitSameDimension(Packet, double)
* @see IPacketNetwork#transmitInterdimensional(Packet)
*/
void receiveSameDimension(@Nonnull Packet packet, double distance);
void receiveSameDimension(Packet packet, double distance);
/**
* Receive a network packet from a different dimension.
@ -79,5 +76,5 @@ public interface IPacketReceiver {
* @see IPacketNetwork#transmitSameDimension(Packet, double)
* @see #isInterdimensional()
*/
void receiveDifferentDimension(@Nonnull Packet packet);
void receiveDifferentDimension(Packet packet);
}

View File

@ -8,7 +8,6 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull;
/**
* An object on a {@link IPacketNetwork}, capable of sending packets.
@ -19,7 +18,6 @@ public interface IPacketSender {
*
* @return The sender's world.
*/
@Nonnull
Level getLevel();
/**
@ -27,7 +25,6 @@ public interface IPacketSender {
*
* @return The sender's position.
*/
@Nonnull
Vec3 getPosition();
/**
@ -36,6 +33,5 @@ public interface IPacketSender {
*
* @return This device's id.
*/
@Nonnull
String getSenderID();
}

View File

@ -7,7 +7,6 @@
import dan200.computercraft.api.ComputerCraftAPI;
import javax.annotation.Nonnull;
/**
* An object which may be part of a wired network.
@ -27,6 +26,6 @@ public interface IWiredElement extends IWiredSender {
* @param change The change which occurred.
* @see IWiredNetworkChange
*/
default void networkChanged(@Nonnull IWiredNetworkChange change) {
default void networkChanged(IWiredNetworkChange change) {
}
}

View File

@ -7,7 +7,6 @@
import dan200.computercraft.api.peripheral.IPeripheral;
import javax.annotation.Nonnull;
import java.util.Map;
/**
@ -38,7 +37,7 @@ public interface IWiredNetwork {
* @see IWiredNode#connectTo(IWiredNode)
* @see IWiredNetwork#connect(IWiredNode, IWiredNode)
*/
boolean connect(@Nonnull IWiredNode left, @Nonnull IWiredNode right);
boolean connect(IWiredNode left, IWiredNode right);
/**
* Destroy a connection between this node and another.
@ -53,7 +52,7 @@ public interface IWiredNetwork {
* @see IWiredNode#disconnectFrom(IWiredNode)
* @see IWiredNetwork#connect(IWiredNode, IWiredNode)
*/
boolean disconnect(@Nonnull IWiredNode left, @Nonnull IWiredNode right);
boolean disconnect(IWiredNode left, IWiredNode right);
/**
* Sever all connections this node has, removing it from this network.
@ -67,7 +66,7 @@ public interface IWiredNetwork {
* @throws IllegalArgumentException If the node is not in the network.
* @see IWiredNode#remove()
*/
boolean remove(@Nonnull IWiredNode node);
boolean remove(IWiredNode node);
/**
* Update the peripherals a node provides.
@ -80,5 +79,5 @@ public interface IWiredNetwork {
* @throws IllegalArgumentException If the node is not in the network.
* @see IWiredNode#updatePeripherals(Map)
*/
void updatePeripherals(@Nonnull IWiredNode node, @Nonnull Map<String, IPeripheral> peripherals);
void updatePeripherals(IWiredNode node, Map<String, IPeripheral> peripherals);
}

View File

@ -7,7 +7,6 @@
import dan200.computercraft.api.peripheral.IPeripheral;
import javax.annotation.Nonnull;
import java.util.Map;
/**
@ -22,7 +21,6 @@ public interface IWiredNetworkChange {
*
* @return The set of removed peripherals.
*/
@Nonnull
Map<String, IPeripheral> peripheralsRemoved();
/**
@ -31,6 +29,5 @@ public interface IWiredNetworkChange {
*
* @return The set of added peripherals.
*/
@Nonnull
Map<String, IPeripheral> peripheralsAdded();
}

View File

@ -8,7 +8,6 @@
import dan200.computercraft.api.network.IPacketNetwork;
import dan200.computercraft.api.peripheral.IPeripheral;
import javax.annotation.Nonnull;
import java.util.Map;
/**
@ -30,7 +29,6 @@ public interface IWiredNode extends IPacketNetwork {
*
* @return This node's element.
*/
@Nonnull
IWiredElement getElement();
/**
@ -41,7 +39,6 @@ public interface IWiredNode extends IPacketNetwork {
*
* @return This node's network.
*/
@Nonnull
IWiredNetwork getNetwork();
/**
@ -54,7 +51,7 @@ public interface IWiredNode extends IPacketNetwork {
* @see IWiredNetwork#connect(IWiredNode, IWiredNode)
* @see IWiredNode#disconnectFrom(IWiredNode)
*/
default boolean connectTo(@Nonnull IWiredNode node) {
default boolean connectTo(IWiredNode node) {
return getNetwork().connect(this, node);
}
@ -69,7 +66,7 @@ default boolean connectTo(@Nonnull IWiredNode node) {
* @see IWiredNetwork#disconnect(IWiredNode, IWiredNode)
* @see IWiredNode#connectTo(IWiredNode)
*/
default boolean disconnectFrom(@Nonnull IWiredNode node) {
default boolean disconnectFrom(IWiredNode node) {
return getNetwork().disconnect(this, node);
}
@ -97,7 +94,7 @@ default boolean remove() {
* @param peripherals The new peripherals for this node.
* @see IWiredNetwork#updatePeripherals(IWiredNode, Map)
*/
default void updatePeripherals(@Nonnull Map<String, IPeripheral> peripherals) {
default void updatePeripherals(Map<String, IPeripheral> peripherals) {
getNetwork().updatePeripherals(this, peripherals);
}
}

View File

@ -7,7 +7,6 @@
import dan200.computercraft.api.network.IPacketSender;
import javax.annotation.Nonnull;
/**
* An object on a {@link IWiredNetwork} capable of sending packets.
@ -24,6 +23,5 @@ public interface IWiredSender extends IPacketSender {
*
* @return The node for this element.
*/
@Nonnull
IWiredNode getNode();
}

View File

@ -11,7 +11,6 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull;
/**
* This interface is used to create peripheral implementations for blocks.
@ -34,6 +33,5 @@ public interface IPeripheralProvider {
* @param side The side to get the peripheral from.
* @return A peripheral, or {@link LazyOptional#empty()} if there is not a peripheral here you'd like to handle.
*/
@Nonnull
LazyOptional<IPeripheral> getPeripheral(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side);
LazyOptional<IPeripheral> getPeripheral(Level world, BlockPos pos, Direction side);
}

View File

@ -9,7 +9,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
/**
* A base class for {@link IPocketUpgrade}s.
@ -31,19 +30,16 @@ protected AbstractPocketUpgrade(ResourceLocation id, ItemStack stack) {
this(id, IUpgradeBase.getDefaultAdjective(id), stack);
}
@Nonnull
@Override
public final ResourceLocation getUpgradeID() {
return id;
}
@Nonnull
@Override
public final String getUnlocalisedAdjective() {
return adjective;
}
@Nonnull
@Override
public final ItemStack getCraftingItem() {
return stack;

View File

@ -10,7 +10,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
@ -72,7 +71,6 @@ public interface IPocketAccess {
* @return The upgrade's NBT.
* @see #updateUpgradeNBTData()
*/
@Nonnull
CompoundTag getUpgradeNBTData();
/**
@ -92,6 +90,5 @@ public interface IPocketAccess {
*
* @return A collection of all upgrade names.
*/
@Nonnull
Map<ResourceLocation, IPeripheral> getUpgrades();
}

View File

@ -9,7 +9,6 @@
import dan200.computercraft.api.upgrades.IUpgradeBase;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -37,7 +36,7 @@ public interface IPocketUpgrade extends IUpgradeBase {
* @see #update(IPocketAccess, IPeripheral)
*/
@Nullable
IPeripheral createPeripheral(@Nonnull IPocketAccess access);
IPeripheral createPeripheral(IPocketAccess access);
/**
* Called when the pocket computer item stack updates.
@ -46,7 +45,7 @@ public interface IPocketUpgrade extends IUpgradeBase {
* @param peripheral The peripheral for this upgrade.
* @see #createPeripheral(IPocketAccess)
*/
default void update(@Nonnull IPocketAccess access, @Nullable IPeripheral peripheral) {
default void update(IPocketAccess access, @Nullable IPeripheral peripheral) {
}
/**
@ -60,7 +59,7 @@ default void update(@Nonnull IPocketAccess access, @Nullable IPeripheral periphe
* access the GUI.
* @see #createPeripheral(IPocketAccess)
*/
default boolean onRightClick(@Nonnull Level world, @Nonnull IPocketAccess access, @Nullable IPeripheral peripheral) {
default boolean onRightClick(Level world, IPocketAccess access, @Nullable IPeripheral peripheral) {
return false;
}
}

View File

@ -8,7 +8,6 @@
import dan200.computercraft.api.upgrades.UpgradeDataProvider;
import net.minecraft.data.DataGenerator;
import javax.annotation.Nonnull;
import java.util.function.Consumer;
/**
@ -20,7 +19,7 @@
* @see PocketUpgradeSerialiser
*/
public abstract class PocketUpgradeDataProvider extends UpgradeDataProvider<IPocketUpgrade, PocketUpgradeSerialiser<?>> {
public PocketUpgradeDataProvider(@Nonnull DataGenerator generator) {
public PocketUpgradeDataProvider(DataGenerator generator) {
super(generator, "Pocket Computer Upgrades", "computercraft/pocket_upgrades", PocketUpgradeSerialiser.REGISTRY_ID);
}
}

View File

@ -18,7 +18,6 @@
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryManager;
import javax.annotation.Nonnull;
import java.util.function.BiFunction;
import java.util.function.Function;
@ -60,8 +59,7 @@ static IForgeRegistry<PocketUpgradeSerialiser<?>> registry() {
* @param <T> The type of the generated upgrade.
* @return The serialiser for this upgrade
*/
@Nonnull
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simple(@Nonnull Function<ResourceLocation, T> factory) {
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simple(Function<ResourceLocation, T> factory) {
final class Impl extends SimpleSerialiser<T> implements PocketUpgradeSerialiser<T> {
private Impl(Function<ResourceLocation, T> constructor) {
super(constructor);
@ -80,8 +78,7 @@ private Impl(Function<ResourceLocation, T> constructor) {
* @return The serialiser for this upgrade.
* @see #simple(Function) For upgrades whose crafting stack should not vary.
*/
@Nonnull
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simpleWithCustomItem(@Nonnull BiFunction<ResourceLocation, ItemStack, T> factory) {
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simpleWithCustomItem(BiFunction<ResourceLocation, ItemStack, T> factory) {
final class Impl extends SerialiserWithCraftingItem<T> implements PocketUpgradeSerialiser<T> {
private Impl(BiFunction<ResourceLocation, ItemStack, T> factory) {
super(factory);

View File

@ -9,7 +9,6 @@
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import javax.annotation.Nonnull;
/**
* This interface is used to provide bundled redstone output for blocks.
@ -28,5 +27,5 @@ public interface IBundledRedstoneProvider {
* handle this block.
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
*/
int getBundledRedstoneOutput(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side);
int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side);
}

View File

@ -9,7 +9,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
/**
* A base class for {@link ITurtleUpgrade}s.
@ -33,25 +32,21 @@ protected AbstractTurtleUpgrade(ResourceLocation id, TurtleUpgradeType type, Ite
this(id, type, IUpgradeBase.getDefaultAdjective(id), stack);
}
@Nonnull
@Override
public final ResourceLocation getUpgradeID() {
return id;
}
@Nonnull
@Override
public final String getUnlocalisedAdjective() {
return adjective;
}
@Nonnull
@Override
public final TurtleUpgradeType getType() {
return type;
}
@Nonnull
@Override
public final ItemStack getCraftingItem() {
return stack;

View File

@ -17,7 +17,6 @@
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -32,7 +31,6 @@ public interface ITurtleAccess {
*
* @return the world in which the turtle resides.
*/
@Nonnull
Level getLevel();
/**
@ -40,7 +38,6 @@ public interface ITurtleAccess {
*
* @return a vector containing the integer co-ordinates at which the turtle resides.
*/
@Nonnull
BlockPos getPosition();
/**
@ -69,7 +66,7 @@ public interface ITurtleAccess {
* was cancelled.
* @throws UnsupportedOperationException When attempting to teleport on the client side.
*/
boolean teleportTo(@Nonnull Level world, @Nonnull BlockPos pos);
boolean teleportTo(Level world, BlockPos pos);
/**
* Returns a vector containing the floating point co-ordinates at which the turtle is rendered.
@ -79,7 +76,6 @@ public interface ITurtleAccess {
* @return A vector containing the floating point co-ordinates at which the turtle resides.
* @see #getVisualYaw(float)
*/
@Nonnull
Vec3 getVisualPosition(float f);
/**
@ -97,7 +93,6 @@ public interface ITurtleAccess {
* @return The world direction the turtle is currently facing.
* @see #setDirection(Direction)
*/
@Nonnull
Direction getDirection();
/**
@ -107,7 +102,7 @@ public interface ITurtleAccess {
* @param dir The new direction to set. This should be on either the x or z axis (so north, south, east or west).
* @see #getDirection()
*/
void setDirection(@Nonnull Direction dir);
void setDirection(Direction dir);
/**
* Get the currently selected slot in the turtle's inventory.
@ -163,7 +158,6 @@ public interface ITurtleAccess {
* @return This turtle's inventory
* @see #getItemHandler()
*/
@Nonnull
Container getInventory();
/**
@ -176,7 +170,6 @@ public interface ITurtleAccess {
* @see IItemHandlerModifiable
* @deprecated Use {@link #getInventory()} directly.
*/
@Nonnull
@Deprecated(forRemoval = true)
IItemHandlerModifiable getItemHandler();
@ -249,8 +242,7 @@ public interface ITurtleAccess {
* @see ITurtleCommand
* @see MethodResult#pullEvent(String, ILuaCallback)
*/
@Nonnull
MethodResult executeCommand(@Nonnull ITurtleCommand command);
MethodResult executeCommand(ITurtleCommand command);
/**
* Start playing a specific animation. This will prevent other turtle commands from executing until
@ -260,7 +252,7 @@ public interface ITurtleAccess {
* @throws UnsupportedOperationException When attempting to execute play an animation on the client side.
* @see TurtleAnimation
*/
void playAnimation(@Nonnull TurtleAnimation animation);
void playAnimation(TurtleAnimation animation);
/**
* Returns the turtle on the specified side of the turtle, if there is one.
@ -270,7 +262,7 @@ public interface ITurtleAccess {
* @see #setUpgrade(TurtleSide, ITurtleUpgrade)
*/
@Nullable
ITurtleUpgrade getUpgrade(@Nonnull TurtleSide side);
ITurtleUpgrade getUpgrade(TurtleSide side);
/**
* Set the upgrade for a given side, resetting peripherals and clearing upgrade specific data.
@ -279,7 +271,7 @@ public interface ITurtleAccess {
* @param upgrade The upgrade to set, may be {@code null} to clear.
* @see #getUpgrade(TurtleSide)
*/
void setUpgrade(@Nonnull TurtleSide side, @Nullable ITurtleUpgrade upgrade);
void setUpgrade(TurtleSide side, @Nullable ITurtleUpgrade upgrade);
/**
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
@ -288,7 +280,7 @@ public interface ITurtleAccess {
* @return The peripheral created by the upgrade on the specified side of the turtle, {@code null} if none exists.
*/
@Nullable
IPeripheral getPeripheral(@Nonnull TurtleSide side);
IPeripheral getPeripheral(TurtleSide side);
/**
* Get an upgrade-specific NBT compound, which can be used to store arbitrary data.
@ -300,7 +292,6 @@ public interface ITurtleAccess {
* @return The upgrade-specific data.
* @see #updateUpgradeNBTData(TurtleSide)
*/
@Nonnull
CompoundTag getUpgradeNBTData(@Nullable TurtleSide side);
/**
@ -310,5 +301,5 @@ public interface ITurtleAccess {
* @param side The side to mark dirty.
* @see #updateUpgradeNBTData(TurtleSide)
*/
void updateUpgradeNBTData(@Nonnull TurtleSide side);
void updateUpgradeNBTData(TurtleSide side);
}

View File

@ -5,7 +5,6 @@
*/
package dan200.computercraft.api.turtle;
import javax.annotation.Nonnull;
/**
* An interface for objects executing custom turtle commands, used with {@link ITurtleAccess#executeCommand(ITurtleCommand)}.
@ -27,6 +26,5 @@ public interface ITurtleCommand {
* @see TurtleCommandResult#failure(String)
* @see TurtleCommandResult
*/
@Nonnull
TurtleCommandResult execute(@Nonnull ITurtleAccess turtle);
TurtleCommandResult execute(ITurtleAccess turtle);
}

View File

@ -9,7 +9,6 @@
import dan200.computercraft.api.upgrades.IUpgradeBase;
import net.minecraft.core.Direction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -32,7 +31,6 @@ public interface ITurtleUpgrade extends IUpgradeBase {
* @return The type of upgrade this is.
* @see TurtleUpgradeType for the differences between them.
*/
@Nonnull
TurtleUpgradeType getType();
/**
@ -48,7 +46,7 @@ public interface ITurtleUpgrade extends IUpgradeBase {
* and this method is not expected to be called.
*/
@Nullable
default IPeripheral createPeripheral(@Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side) {
default IPeripheral createPeripheral(ITurtleAccess turtle, TurtleSide side) {
return null;
}
@ -70,8 +68,7 @@ default IPeripheral createPeripheral(@Nonnull ITurtleAccess turtle, @Nonnull Tur
* a swinging animation. You may return {@code null} if this turtle is a Peripheral and this method is not expected
* to be called.
*/
@Nonnull
default TurtleCommandResult useTool(@Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull Direction direction) {
default TurtleCommandResult useTool(ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, Direction direction) {
return TurtleCommandResult.failure();
}
@ -81,6 +78,6 @@ default TurtleCommandResult useTool(@Nonnull ITurtleAccess turtle, @Nonnull Turt
* @param turtle Access to the turtle that the upgrade resides on.
* @param side Which side of the turtle (left or right) the upgrade resides on.
*/
default void update(@Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side) {
default void update(ITurtleAccess turtle, TurtleSide side) {
}
}

View File

@ -7,7 +7,6 @@
import net.minecraft.core.Direction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -25,7 +24,6 @@ public final class TurtleCommandResult {
*
* @return A successful command result with no values.
*/
@Nonnull
public static TurtleCommandResult success() {
return EMPTY_SUCCESS;
}
@ -36,7 +34,6 @@ public static TurtleCommandResult success() {
* @param results The results of executing this command.
* @return A successful command result with the given values.
*/
@Nonnull
public static TurtleCommandResult success(@Nullable Object[] results) {
if (results == null || results.length == 0) return EMPTY_SUCCESS;
return new TurtleCommandResult(true, null, results);
@ -47,7 +44,6 @@ public static TurtleCommandResult success(@Nullable Object[] results) {
*
* @return A failed command result with no message.
*/
@Nonnull
public static TurtleCommandResult failure() {
return EMPTY_FAILURE;
}
@ -58,17 +54,16 @@ public static TurtleCommandResult failure() {
* @param errorMessage The error message to provide.
* @return A failed command result with a message.
*/
@Nonnull
public static TurtleCommandResult failure(@Nullable String errorMessage) {
if (errorMessage == null) return EMPTY_FAILURE;
return new TurtleCommandResult(false, errorMessage, null);
}
private final boolean success;
private final String errorMessage;
private final Object[] results;
private final @Nullable String errorMessage;
private final @Nullable Object[] results;
private TurtleCommandResult(boolean success, String errorMessage, Object[] results) {
private TurtleCommandResult(boolean success, @Nullable String errorMessage, @Nullable Object[] results) {
this.success = success;
this.errorMessage = errorMessage;
this.results = results;

View File

@ -17,7 +17,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.Consumer;
/**
@ -43,8 +43,7 @@ public TurtleUpgradeDataProvider(DataGenerator generator) {
* to specify {@link ToolBuilder#damageMultiplier(float)} and {@link ToolBuilder#breakable(TagKey)}.
* @return A tool builder,
*/
@Nonnull
public final ToolBuilder tool(@Nonnull ResourceLocation id, @Nonnull Item item) {
public final ToolBuilder tool(ResourceLocation id, Item item) {
return new ToolBuilder(id, existingSerialiser(TOOL_ID), item);
}
@ -57,10 +56,10 @@ public static class ToolBuilder {
private final ResourceLocation id;
private final TurtleUpgradeSerialiser<?> serialiser;
private final Item toolItem;
private String adjective;
private Item craftingItem;
private Float damageMultiplier = null;
private TagKey<Block> breakable;
private @Nullable String adjective;
private @Nullable Item craftingItem;
private @Nullable Float damageMultiplier = null;
private @Nullable TagKey<Block> breakable;
ToolBuilder(ResourceLocation id, TurtleUpgradeSerialiser<?> serialiser, Item toolItem) {
this.id = id;
@ -75,8 +74,7 @@ public static class ToolBuilder {
* @param adjective The new adjective to use.
* @return The tool builder, for further use.
*/
@Nonnull
public ToolBuilder adjective(@Nonnull String adjective) {
public ToolBuilder adjective(String adjective) {
this.adjective = adjective;
return this;
}
@ -88,8 +86,7 @@ public ToolBuilder adjective(@Nonnull String adjective) {
* @param craftingItem The item used to craft this upgrade.
* @return The tool builder, for further use.
*/
@Nonnull
public ToolBuilder craftingItem(@Nonnull Item craftingItem) {
public ToolBuilder craftingItem(Item craftingItem) {
this.craftingItem = craftingItem;
return this;
}
@ -115,7 +112,7 @@ public ToolBuilder damageMultiplier(float damageMultiplier) {
* @return The tool builder, for further use.
* @see ComputerCraftTags.Blocks
*/
public ToolBuilder breakable(@Nonnull TagKey<Block> breakable) {
public ToolBuilder breakable(TagKey<Block> breakable) {
this.breakable = breakable;
return this;
}
@ -125,7 +122,7 @@ public ToolBuilder breakable(@Nonnull TagKey<Block> breakable) {
*
* @param add The callback given to {@link #addUpgrades(Consumer)}.
*/
public void add(@Nonnull Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> add) {
public void add(Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> add) {
add.accept(new Upgrade<>(id, serialiser, s -> {
s.addProperty("item", PlatformHelper.get().getRegistryKey(Registry.ITEM_REGISTRY, toolItem).toString());
if (adjective != null) s.addProperty("adjective", adjective);

View File

@ -19,7 +19,6 @@
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.RegistryManager;
import javax.annotation.Nonnull;
import java.util.function.BiFunction;
import java.util.function.Function;
@ -95,8 +94,7 @@ static IForgeRegistry<TurtleUpgradeSerialiser<?>> registry() {
* @param <T> The type of the generated upgrade.
* @return The serialiser for this upgrade
*/
@Nonnull
static <T extends ITurtleUpgrade> TurtleUpgradeSerialiser<T> simple(@Nonnull Function<ResourceLocation, T> factory) {
static <T extends ITurtleUpgrade> TurtleUpgradeSerialiser<T> simple(Function<ResourceLocation, T> factory) {
final class Impl extends SimpleSerialiser<T> implements TurtleUpgradeSerialiser<T> {
private Impl(Function<ResourceLocation, T> constructor) {
super(constructor);
@ -115,8 +113,7 @@ private Impl(Function<ResourceLocation, T> constructor) {
* @return The serialiser for this upgrade.
* @see #simple(Function) For upgrades whose crafting stack should not vary.
*/
@Nonnull
static <T extends ITurtleUpgrade> TurtleUpgradeSerialiser<T> simpleWithCustomItem(@Nonnull BiFunction<ResourceLocation, ItemStack, T> factory) {
static <T extends ITurtleUpgrade> TurtleUpgradeSerialiser<T> simpleWithCustomItem(BiFunction<ResourceLocation, ItemStack, T> factory) {
final class Impl extends SerialiserWithCraftingItem<T> implements TurtleUpgradeSerialiser<T> {
private Impl(BiFunction<ResourceLocation, ItemStack, T> factory) {
super(factory);

View File

@ -12,7 +12,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.Objects;
/**
* Common functionality between {@link ITurtleUpgrade} and {@link IPocketUpgrade}.
@ -27,7 +27,6 @@ public interface IUpgradeBase {
*
* @return The unique ID for this upgrade.
*/
@Nonnull
ResourceLocation getUpgradeID();
/**
@ -37,7 +36,6 @@ public interface IUpgradeBase {
*
* @return The localisation key for this upgrade's adjective.
*/
@Nonnull
String getUnlocalisedAdjective();
/**
@ -51,7 +49,6 @@ public interface IUpgradeBase {
*
* @return The item stack to craft with, or {@link ItemStack#EMPTY} if it cannot be crafted.
*/
@Nonnull
ItemStack getCraftingItem();
/**
@ -70,7 +67,7 @@ public interface IUpgradeBase {
* {@link #getCraftingItem()}.
* @return If this stack may be used to equip this upgrade.
*/
default boolean isItemSuitable(@Nonnull ItemStack stack) {
default boolean isItemSuitable(ItemStack stack) {
var crafting = getCraftingItem();
// A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a
@ -78,7 +75,7 @@ default boolean isItemSuitable(@Nonnull ItemStack stack) {
var shareTag = PlatformHelper.get().getShareTag(stack);
var craftingShareTag = PlatformHelper.get().getShareTag(crafting);
if (shareTag == craftingShareTag) return true;
if (shareTag == null) return craftingShareTag.isEmpty();
if (shareTag == null) return Objects.requireNonNull(craftingShareTag).isEmpty();
if (craftingShareTag == null) return shareTag.isEmpty();
return shareTag.equals(craftingShareTag);
}
@ -91,8 +88,7 @@ default boolean isItemSuitable(@Nonnull ItemStack stack) {
* @return The generated adjective.
* @see #getUnlocalisedAdjective()
*/
@Nonnull
static String getDefaultAdjective(@Nonnull ResourceLocation id) {
static String getDefaultAdjective(ResourceLocation id) {
return Util.makeDescriptionId("upgrade", id) + ".adjective";
}
}

View File

@ -21,7 +21,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
@ -45,9 +45,9 @@ public abstract class UpgradeDataProvider<T extends IUpgradeBase, R extends Upgr
private final String folder;
private final ResourceKey<Registry<R>> registry;
private List<T> upgrades;
private @Nullable List<T> upgrades;
protected UpgradeDataProvider(@Nonnull DataGenerator generator, @Nonnull String name, @Nonnull String folder, @Nonnull ResourceKey<Registry<R>> registry) {
protected UpgradeDataProvider(DataGenerator generator, String name, String folder, ResourceKey<Registry<R>> registry) {
this.generator = generator;
this.name = name;
this.folder = folder;
@ -61,8 +61,7 @@ protected UpgradeDataProvider(@Nonnull DataGenerator generator, @Nonnull String
* @param serialiser The simple serialiser.
* @return The constructed upgrade, ready to be passed off to {@link #addUpgrades(Consumer)}'s consumer.
*/
@Nonnull
public final Upgrade<R> simple(@Nonnull ResourceLocation id, @Nonnull R serialiser) {
public final Upgrade<R> simple(ResourceLocation id, R serialiser) {
if (!(serialiser instanceof SimpleSerialiser)) {
throw new IllegalStateException(serialiser + " must be a simple() seriaiser.");
}
@ -79,8 +78,7 @@ public final Upgrade<R> simple(@Nonnull ResourceLocation id, @Nonnull R serialis
* @param item The crafting upgrade for this item.
* @return The constructed upgrade, ready to be passed off to {@link #addUpgrades(Consumer)}'s consumer.
*/
@Nonnull
public final Upgrade<R> simpleWithCustomItem(@Nonnull ResourceLocation id, @Nonnull R serialiser, @Nonnull Item item) {
public final Upgrade<R> simpleWithCustomItem(ResourceLocation id, R serialiser, Item item) {
if (!(serialiser instanceof SerialiserWithCraftingItem)) {
throw new IllegalStateException(serialiser + " must be a simpleWithCustomItem() serialiser.");
}
@ -95,17 +93,17 @@ public final Upgrade<R> simpleWithCustomItem(@Nonnull ResourceLocation id, @Nonn
* <p>
* <strong>Example usage:</strong>
* <pre>{@code
* protected void addUpgrades(@Nonnull Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> addUpgrade) {
* protected void addUpgrades(Consumer<Upgrade<TurtleUpgradeSerialiser<?>>> addUpgrade) {
* simple(new ResourceLocation("mymod", "speaker"), SPEAKER_SERIALISER.get()).add(addUpgrade);
* }
* }</pre>
*
* @param addUpgrade A callback used to register an upgrade.
*/
protected abstract void addUpgrades(@Nonnull Consumer<Upgrade<R>> addUpgrade);
protected abstract void addUpgrades(Consumer<Upgrade<R>> addUpgrade);
@Override
public final void run(@Nonnull CachedOutput cache) throws IOException {
public final void run(CachedOutput cache) throws IOException {
var base = generator.getOutputFolder().resolve("data");
Set<ResourceLocation> seen = new HashSet<>();
@ -134,20 +132,17 @@ public final void run(@Nonnull CachedOutput cache) throws IOException {
this.upgrades = upgrades;
}
@Nonnull
@Override
public final String getName() {
return name;
}
@Nonnull
public final R existingSerialiser(@Nonnull ResourceLocation id) {
public final R existingSerialiser(ResourceLocation id) {
var result = PlatformHelper.get().getRegistryObject(registry, id);
if (result == null) throw new IllegalArgumentException("No such serialiser " + registry);
return result;
}
@Nonnull
public List<T> getGeneratedUpgrades() {
if (upgrades == null) throw new IllegalStateException("Upgrades have not beeen generated yet");
return upgrades;
@ -169,7 +164,7 @@ public record Upgrade<R extends UpgradeSerialiser<?>>(
*
* @param add The callback given to {@link #addUpgrades(Consumer)}
*/
public void add(@Nonnull Consumer<Upgrade<R>> add) {
public void add(Consumer<Upgrade<R>> add) {
add.accept(this);
}
}

View File

@ -11,7 +11,6 @@
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nonnull;
/**
* Base interface for upgrade serialisers. This should generally not be implemented directly, instead implementing one
@ -32,8 +31,7 @@ public interface UpgradeSerialiser<T extends IUpgradeBase> {
* @return The constructed upgrade, with a {@link IUpgradeBase#getUpgradeID()} equal to {@code id}.
* @see net.minecraft.util.GsonHelper For additional JSON helper methods.
*/
@Nonnull
T fromJson(@Nonnull ResourceLocation id, @Nonnull JsonObject object);
T fromJson(ResourceLocation id, JsonObject object);
/**
* Read this upgrade from a network packet, sent from the server.
@ -42,8 +40,7 @@ public interface UpgradeSerialiser<T extends IUpgradeBase> {
* @param buffer The buffer object to read this upgrade from.
* @return The constructed upgrade, with a {@link IUpgradeBase#getUpgradeID()} equal to {@code id}.
*/
@Nonnull
T fromNetwork(@Nonnull ResourceLocation id, @Nonnull FriendlyByteBuf buffer);
T fromNetwork(ResourceLocation id, FriendlyByteBuf buffer);
/**
* Write this upgrade to a network packet, to be sent to the client.
@ -51,6 +48,6 @@ public interface UpgradeSerialiser<T extends IUpgradeBase> {
* @param buffer The buffer object to write this upgrade to
* @param upgrade The upgrade to write.
*/
void toNetwork(@Nonnull FriendlyByteBuf buffer, @Nonnull T upgrade);
void toNetwork(FriendlyByteBuf buffer, T upgrade);
}

View File

@ -29,7 +29,6 @@
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.ApiStatus;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@ -44,46 +43,42 @@ static ComputerCraftAPIService get() {
return instance == null ? Services.raise(ComputerCraftAPIService.class, Instance.ERROR) : instance;
}
@Nonnull
String getInstalledVersion();
int createUniqueNumberedSaveDir(@Nonnull Level world, @Nonnull String parentSubPath);
int createUniqueNumberedSaveDir(Level world, String parentSubPath);
@Nullable
IWritableMount createSaveDirMount(@Nonnull Level world, @Nonnull String subPath, long capacity);
IWritableMount createSaveDirMount(Level world, String subPath, long capacity);
@Nullable
IMount createResourceMount(@Nonnull String domain, @Nonnull String subPath);
IMount createResourceMount(String domain, String subPath);
@Deprecated
void registerPeripheralProvider(@Nonnull IPeripheralProvider provider);
void registerPeripheralProvider(IPeripheralProvider provider);
void registerGenericSource(@Nonnull GenericSource source);
void registerGenericSource(GenericSource source);
@Deprecated
void registerGenericCapability(@Nonnull Capability<?> capability);
void registerGenericCapability(Capability<?> capability);
void registerBundledRedstoneProvider(@Nonnull IBundledRedstoneProvider provider);
void registerBundledRedstoneProvider(IBundledRedstoneProvider provider);
int getBundledRedstoneOutput(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side);
int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side);
void registerMediaProvider(@Nonnull IMediaProvider provider);
void registerMediaProvider(IMediaProvider provider);
@Nonnull
IPacketNetwork getWirelessNetwork();
void registerAPIFactory(@Nonnull ILuaAPIFactory factory);
void registerAPIFactory(ILuaAPIFactory factory);
@Deprecated
<T> void registerDetailProvider(@Nonnull Class<T> type, @Nonnull IDetailProvider<T> provider);
<T> void registerDetailProvider(Class<T> type, IDetailProvider<T> provider);
@Nonnull
IWiredNode createWiredNodeForElement(@Nonnull IWiredElement element);
IWiredNode createWiredNodeForElement(IWiredElement element);
@Nonnull
LazyOptional<IWiredElement> getWiredElementAt(@Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side);
LazyOptional<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side);
void registerRefuelHandler(@Nonnull TurtleRefuelHandler handler);
void registerRefuelHandler(TurtleRefuelHandler handler);
DetailRegistry<ItemStack> getItemStackDetailRegistry();

View File

@ -71,6 +71,7 @@ public static <T> LoadedService<T> tryLoad(Class<T> klass) {
* @see #tryLoad(Class)
* @see LoadedService#error()
*/
@SuppressWarnings("DoNotCallSuggester")
public static <T> T raise(Class<T> klass, @Nullable Throwable e) {
// Throw a new exception so there's a useful stack trace there somewhere!
throw new ServiceException("Failed to instantiate " + klass.getName(), e);

View File

@ -0,0 +1,21 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
/**
* Internal interfaces for ComputerCraft's API.
*/
@ApiStatus.Internal
@DefaultQualifier(value = NonNull.class, locations = {
TypeUseLocation.RETURN,
TypeUseLocation.PARAMETER,
TypeUseLocation.FIELD,
})
package dan200.computercraft.impl;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.checkerframework.framework.qual.TypeUseLocation;
import org.jetbrains.annotations.ApiStatus;

View File

@ -14,7 +14,6 @@
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import javax.annotation.Nonnull;
import java.util.function.BiFunction;
/**
@ -32,22 +31,20 @@ protected SerialiserWithCraftingItem(BiFunction<ResourceLocation, ItemStack, T>
this.factory = factory;
}
@Nonnull
@Override
public final T fromJson(@Nonnull ResourceLocation id, @Nonnull JsonObject object) {
public final T fromJson(ResourceLocation id, JsonObject object) {
var item = GsonHelper.getAsItem(object, "item");
return factory.apply(id, new ItemStack(item));
}
@Nonnull
@Override
public final T fromNetwork(@Nonnull ResourceLocation id, @Nonnull FriendlyByteBuf buffer) {
public final T fromNetwork(ResourceLocation id, FriendlyByteBuf buffer) {
var item = buffer.readItem();
return factory.apply(id, item);
}
@Override
public final void toNetwork(@Nonnull FriendlyByteBuf buffer, @Nonnull T upgrade) {
public final void toNetwork(FriendlyByteBuf buffer, T upgrade) {
buffer.writeItem(upgrade.getCraftingItem());
}
}

View File

@ -12,7 +12,6 @@
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
import javax.annotation.Nonnull;
import java.util.function.Function;
/**
@ -30,19 +29,17 @@ public SimpleSerialiser(Function<ResourceLocation, T> constructor) {
this.constructor = constructor;
}
@Nonnull
@Override
public final T fromJson(@Nonnull ResourceLocation id, @Nonnull JsonObject object) {
return constructor.apply(id);
}
@Nonnull
@Override
public final T fromNetwork(@Nonnull ResourceLocation id, @Nonnull FriendlyByteBuf buffer) {
public final T fromJson(ResourceLocation id, JsonObject object) {
return constructor.apply(id);
}
@Override
public final void toNetwork(@Nonnull FriendlyByteBuf buffer, @Nonnull T upgrade) {
public final T fromNetwork(ResourceLocation id, FriendlyByteBuf buffer) {
return constructor.apply(id);
}
@Override
public final void toNetwork(FriendlyByteBuf buffer, T upgrade) {
}
}

View File

@ -16,8 +16,6 @@
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull;
/**
* The forge-specific entrypoint for ComputerCraft's API.
*/
@ -34,7 +32,7 @@ private ForgeComputerCraftAPI() {
* @see IPeripheral
* @see IPeripheralProvider
*/
public static void registerPeripheralProvider(@Nonnull IPeripheralProvider provider) {
public static void registerPeripheralProvider(IPeripheralProvider provider) {
getInstance().registerPeripheralProvider(provider);
}
@ -44,7 +42,7 @@ public static void registerPeripheralProvider(@Nonnull IPeripheralProvider provi
* @param capability The capability to register.
* @see GenericSource
*/
public static void registerGenericCapability(@Nonnull Capability<?> capability) {
public static void registerGenericCapability(Capability<?> capability) {
getInstance().registerGenericCapability(capability);
}
@ -57,12 +55,10 @@ public static void registerGenericCapability(@Nonnull Capability<?> capability)
* @return The element's node
* @see IWiredElement#getNode()
*/
@Nonnull
public static LazyOptional<IWiredElement> getWiredElementAt(@Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction side) {
public static LazyOptional<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
return getInstance().getWiredElementAt(world, pos, side);
}
@Nonnull
private static ComputerCraftAPIForgeService getInstance() {
return ComputerCraftAPIForgeService.get();
}

View File

@ -8,7 +8,6 @@
import dan200.computercraft.api.turtle.ITurtleAccess;
import net.minecraftforge.eventbus.api.Event;
import javax.annotation.Nonnull;
import java.util.Objects;
/**
@ -23,7 +22,7 @@
public abstract class TurtleEvent extends Event {
private final ITurtleAccess turtle;
protected TurtleEvent(@Nonnull ITurtleAccess turtle) {
protected TurtleEvent(ITurtleAccess turtle) {
Objects.requireNonNull(turtle, "turtle cannot be null");
this.turtle = turtle;
}
@ -33,7 +32,6 @@ protected TurtleEvent(@Nonnull ITurtleAccess turtle) {
*
* @return The access for this turtle.
*/
@Nonnull
public ITurtleAccess getTurtle() {
return turtle;
}

View File

@ -9,7 +9,6 @@
import dan200.computercraft.api.turtle.TurtleRefuelHandler;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Objects;
@ -23,9 +22,9 @@
@Deprecated(forRemoval = true)
public class TurtleRefuelEvent extends TurtleEvent {
private final ItemStack stack;
private Handler handler;
private @Nullable Handler handler;
public TurtleRefuelEvent(@Nonnull ITurtleAccess turtle, @Nonnull ItemStack stack) {
public TurtleRefuelEvent(ITurtleAccess turtle, ItemStack stack) {
super(turtle);
Objects.requireNonNull(turtle, "turtle cannot be null");
@ -82,6 +81,6 @@ public interface Handler {
* items to consume.
* @return The amount of fuel gained.
*/
int refuel(@Nonnull ITurtleAccess turtle, @Nonnull ItemStack stack, int slot, int limit);
int refuel(ITurtleAccess turtle, ItemStack stack, int slot, int limit);
}
}