1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-06-05 16:14:11 +00:00

Add @Nullable and @NonNull annotations

This commit is contained in:
SquidDev 2017-05-07 00:07:42 +01:00
parent 9d1872c948
commit dc5517303f
128 changed files with 818 additions and 381 deletions

View File

@ -722,7 +722,7 @@ public class ComputerCraft
} }
} }
public static IMount createResourceMount( Class modClass, String domain, String subPath ) public static IMount createResourceMount( Class<?> modClass, String domain, String subPath )
{ {
// Start building list of mounts // Start building list of mounts
List<IMount> mounts = new ArrayList<IMount>(); List<IMount> mounts = new ArrayList<IMount>();
@ -806,7 +806,7 @@ public class ComputerCraft
} }
} }
private static File getContainingJar( Class modClass ) private static File getContainingJar( Class<?> modClass )
{ {
String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath(); String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
int bangIndex = path.indexOf( "!" ); int bangIndex = path.indexOf( "!" );
@ -831,7 +831,7 @@ public class ComputerCraft
return file; return file;
} }
private static File getDebugCodeDir( Class modClass ) private static File getDebugCodeDir( Class<?> modClass )
{ {
String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath(); String path = modClass.getProtectionDomain().getCodeSource().getLocation().getPath();
int bangIndex = path.indexOf("!"); int bangIndex = path.indexOf("!");

View File

@ -21,6 +21,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/** /**
@ -36,6 +38,7 @@ public final class ComputerCraftAPI
return computerCraft != null; return computerCraft != null;
} }
@Nonnull
public static String getInstalledVersion() public static String getInstalledVersion()
{ {
findCC(); findCC();
@ -50,6 +53,7 @@ public final class ComputerCraftAPI
return ""; return "";
} }
@Nonnull
public static String getAPIVersion() public static String getAPIVersion()
{ {
return "${version}"; return "${version}";
@ -68,7 +72,7 @@ public final class ComputerCraftAPI
* available for writing. * available for writing.
* @see #createSaveDirMount(World, String, long) * @see #createSaveDirMount(World, String, long)
*/ */
public static int createUniqueNumberedSaveDir( World world, String parentSubPath ) public static int createUniqueNumberedSaveDir( @Nonnull World world, @Nonnull String parentSubPath )
{ {
findCC(); findCC();
if( computerCraft_createUniqueNumberedSaveDir != null ) if( computerCraft_createUniqueNumberedSaveDir != null )
@ -100,7 +104,8 @@ public final class ComputerCraftAPI
* @see IMount * @see IMount
* @see IWritableMount * @see IWritableMount
*/ */
public static IWritableMount createSaveDirMount( World world, String subPath, long capacity ) @Nullable
public static IWritableMount createSaveDirMount( @Nonnull World world, @Nonnull String subPath, long capacity )
{ {
findCC(); findCC();
if( computerCraft_createSaveDirMount != null ) if( computerCraft_createSaveDirMount != null )
@ -132,7 +137,8 @@ public final class ComputerCraftAPI
* @see IComputerAccess#mountWritable(String, IWritableMount) * @see IComputerAccess#mountWritable(String, IWritableMount)
* @see IMount * @see IMount
*/ */
public static IMount createResourceMount( Class modClass, String domain, String subPath ) @Nullable
public static IMount createResourceMount( @Nonnull Class<?> modClass, @Nonnull String domain, @Nonnull String subPath )
{ {
findCC(); findCC();
if( computerCraft_createResourceMount != null ) if( computerCraft_createResourceMount != null )
@ -153,7 +159,7 @@ public final class ComputerCraftAPI
* @see dan200.computercraft.api.peripheral.IPeripheral * @see dan200.computercraft.api.peripheral.IPeripheral
* @see dan200.computercraft.api.peripheral.IPeripheralProvider * @see dan200.computercraft.api.peripheral.IPeripheralProvider
*/ */
public static void registerPeripheralProvider( IPeripheralProvider handler ) public static void registerPeripheralProvider( @Nonnull IPeripheralProvider handler )
{ {
findCC(); findCC();
if ( computerCraft_registerPeripheralProvider != null) if ( computerCraft_registerPeripheralProvider != null)
@ -174,7 +180,7 @@ public final class ComputerCraftAPI
* @param upgrade The turtle upgrade to register. * @param upgrade The turtle upgrade to register.
* @see dan200.computercraft.api.turtle.ITurtleUpgrade * @see dan200.computercraft.api.turtle.ITurtleUpgrade
*/ */
public static void registerTurtleUpgrade( ITurtleUpgrade upgrade ) public static void registerTurtleUpgrade( @Nonnull ITurtleUpgrade upgrade )
{ {
if( upgrade != null ) if( upgrade != null )
{ {
@ -196,7 +202,7 @@ public final class ComputerCraftAPI
* @param handler The bundled redstone provider to register. * @param handler The bundled redstone provider to register.
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider * @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
*/ */
public static void registerBundledRedstoneProvider( IBundledRedstoneProvider handler ) public static void registerBundledRedstoneProvider( @Nonnull IBundledRedstoneProvider handler )
{ {
findCC(); findCC();
if( computerCraft_registerBundledRedstoneProvider != null ) if( computerCraft_registerBundledRedstoneProvider != null )
@ -219,7 +225,7 @@ public final class ComputerCraftAPI
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned. * If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider * @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
*/ */
public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) public static int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
{ {
findCC(); findCC();
if( computerCraft_getDefaultBundledRedstoneOutput != null ) if( computerCraft_getDefaultBundledRedstoneOutput != null )
@ -239,7 +245,7 @@ public final class ComputerCraftAPI
* @param handler The media provider to register. * @param handler The media provider to register.
* @see dan200.computercraft.api.media.IMediaProvider * @see dan200.computercraft.api.media.IMediaProvider
*/ */
public static void registerMediaProvider( IMediaProvider handler ) public static void registerMediaProvider( @Nonnull IMediaProvider handler )
{ {
findCC(); findCC();
if( computerCraft_registerMediaProvider != null ) if( computerCraft_registerMediaProvider != null )
@ -258,7 +264,7 @@ public final class ComputerCraftAPI
* @param handler The turtle permission provider to register. * @param handler The turtle permission provider to register.
* @see dan200.computercraft.api.permissions.ITurtlePermissionProvider * @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
*/ */
public static void registerPermissionProvider( ITurtlePermissionProvider handler ) public static void registerPermissionProvider( @Nonnull ITurtlePermissionProvider handler )
{ {
findCC(); findCC();
if( computerCraft_registerPermissionProvider != null ) if( computerCraft_registerPermissionProvider != null )
@ -271,7 +277,8 @@ public final class ComputerCraftAPI
} }
} }
public static void registerPocketUpgrade(IPocketUpgrade upgrade) { public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
{
findCC(); findCC();
if(computerCraft_registerPocketUpgrade != null) { if(computerCraft_registerPocketUpgrade != null) {
try { try {
@ -331,7 +338,7 @@ public final class ComputerCraftAPI
} }
} }
private static Method findCCMethod( String name, Class[] args ) private static Method findCCMethod( String name, Class<?>[] args )
{ {
try { try {
if( computerCraft != null ) if( computerCraft != null )

View File

@ -10,6 +10,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -36,7 +37,7 @@ public interface IMount
* @return If the file exists. * @return If the file exists.
* @throws IOException If an error occurs when checking the existence of the file. * @throws IOException If an error occurs when checking the existence of the file.
*/ */
public boolean exists( String path ) throws IOException; boolean exists( @Nonnull String path ) throws IOException;
/** /**
* Returns whether a file with a given path is a directory or not. * Returns whether a file with a given path is a directory or not.
@ -45,7 +46,7 @@ public interface IMount
* @return If the file exists and is a directory * @return If the file exists and is a directory
* @throws IOException If an error occurs when checking whether the file is a directory. * @throws IOException If an error occurs when checking whether the file is a directory.
*/ */
public boolean isDirectory( String path ) throws IOException; boolean isDirectory( @Nonnull String path ) throws IOException;
/** /**
* Returns the file names of all the files in a directory. * Returns the file names of all the files in a directory.
@ -54,7 +55,7 @@ public interface IMount
* @param contents A list of strings. Add all the file names to this list. * @param contents A list of strings. Add all the file names to this list.
* @throws IOException If the file was not a directory, or could not be listed. * @throws IOException If the file was not a directory, or could not be listed.
*/ */
public void list( String path, List<String> contents ) throws IOException; void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException;
/** /**
* Returns the size of a file with a given path, in bytes * Returns the size of a file with a given path, in bytes
@ -63,7 +64,7 @@ public interface IMount
* @return The size of the file, in bytes. * @return The size of the file, in bytes.
* @throws IOException If the file does not exist, or its size could not be determined. * @throws IOException If the file does not exist, or its size could not be determined.
*/ */
public long getSize( String path ) throws IOException; long getSize( @Nonnull String path ) throws IOException;
/** /**
* Opens a file with a given path, and returns an {@link InputStream} representing its contents. * Opens a file with a given path, and returns an {@link InputStream} representing its contents.
@ -72,5 +73,6 @@ public interface IMount
* @return A stream representing the contents of the file. * @return A stream representing the contents of the file.
* @throws IOException If the file does not exist, or could not be opened. * @throws IOException If the file does not exist, or could not be opened.
*/ */
public InputStream openForRead( String path ) throws IOException; @Nonnull
InputStream openForRead( @Nonnull String path ) throws IOException;
} }

View File

@ -10,6 +10,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -33,7 +34,7 @@ public interface IWritableMount extends IMount
* @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms". * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms".
* @throws IOException If the directory already exists or could not be created. * @throws IOException If the directory already exists or could not be created.
*/ */
public void makeDirectory( String path ) throws IOException; void makeDirectory( @Nonnull String path ) throws IOException;
/** /**
* Deletes a directory at a given path inside the virtual file system. * Deletes a directory at a given path inside the virtual file system.
@ -41,7 +42,7 @@ public interface IWritableMount extends IMount
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms". * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms".
* @throws IOException If the file does not exist or could not be deleted. * @throws IOException If the file does not exist or could not be deleted.
*/ */
public void delete( String path ) throws IOException; void delete( @Nonnull String path ) throws IOException;
/** /**
* Opens a file with a given path, and returns an {@link OutputStream} for writing to it. * Opens a file with a given path, and returns an {@link OutputStream} for writing to it.
@ -50,7 +51,8 @@ public interface IWritableMount extends IMount
* @return A stream for writing to * @return A stream for writing to
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
public OutputStream openForWrite( String path ) throws IOException; @Nonnull
OutputStream openForWrite( @Nonnull String path ) throws IOException;
/** /**
* Opens a file with a given path, and returns an {@link OutputStream} for appending to it. * Opens a file with a given path, and returns an {@link OutputStream} for appending to it.
@ -59,7 +61,8 @@ public interface IWritableMount extends IMount
* @return A stream for writing to. * @return A stream for writing to.
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
public OutputStream openForAppend( String path ) throws IOException; @Nonnull
OutputStream openForAppend( @Nonnull String path ) throws IOException;
/** /**
* Get the amount of free space on the mount, in bytes. You should decrease this value as the user writes to the * Get the amount of free space on the mount, in bytes. You should decrease this value as the user writes to the
@ -68,5 +71,5 @@ public interface IWritableMount extends IMount
* @return The amount of free space, in bytes. * @return The amount of free space, in bytes.
* @throws IOException If the remaining space could not be computed. * @throws IOException If the remaining space could not be computed.
*/ */
public long getRemainingSpace() throws IOException; long getRemainingSpace() throws IOException;
} }

View File

@ -6,6 +6,9 @@
package dan200.computercraft.api.lua; package dan200.computercraft.api.lua;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* An interface passed to peripherals and {@link ILuaObject}s by computers or turtles, providing methods * An interface passed to peripherals and {@link ILuaObject}s by computers or turtles, providing methods
* that allow the peripheral call to wait for events before returning, just like in lua. This is very useful if you need * that allow the peripheral call to wait for events before returning, just like in lua. This is very useful if you need
@ -28,7 +31,8 @@ public interface ILuaContext
* event, InterruptedException will be thrown. This exception must not be caught or * event, InterruptedException will be thrown. This exception must not be caught or
* intercepted, or the computer will leak memory and end up in a broken state. * intercepted, or the computer will leak memory and end up in a broken state.
*/ */
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException; @Nonnull
Object[] pullEvent( @Nullable String filter ) throws LuaException, InterruptedException;
/** /**
* The same as {@link #pullEvent(String)}, except "terminated" events are ignored. Only use this if you want to * The same as {@link #pullEvent(String)}, except "terminated" events are ignored. Only use this if you want to
@ -42,7 +46,8 @@ public interface ILuaContext
* intercepted, or the computer will leak memory and end up in a broken state. * intercepted, or the computer will leak memory and end up in a broken state.
* @see #pullEvent(String) * @see #pullEvent(String)
*/ */
public Object[] pullEventRaw( String filter ) throws InterruptedException; @Nonnull
Object[] pullEventRaw( @Nullable String filter ) throws InterruptedException;
/** /**
* Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to * Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to
@ -55,7 +60,8 @@ public interface ILuaContext
* intercepted, or the computer will leak memory and end up in a broken state. * intercepted, or the computer will leak memory and end up in a broken state.
* @see #pullEvent(String) * @see #pullEvent(String)
*/ */
public Object[] yield( Object[] arguments ) throws InterruptedException; @Nonnull
Object[] yield( @Nullable Object[] arguments ) throws InterruptedException;
/** /**
* Queue a task to be executed on the main server thread at the beginning of next tick, waiting for it to complete. * Queue a task to be executed on the main server thread at the beginning of next tick, waiting for it to complete.
@ -71,7 +77,8 @@ public interface ILuaContext
* InterruptedException will be thrown. This exception must not be caught or * InterruptedException will be thrown. This exception must not be caught or
* intercepted, or the computer will leak memory and end up in a broken state. * intercepted, or the computer will leak memory and end up in a broken state.
*/ */
public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException; @Nullable
Object[] executeMainThreadTask( @Nonnull ILuaTask task ) throws LuaException, InterruptedException;
/** /**
* Queue a task to be executed on the main server thread at the beginning of next tick, but do not wait for it to * Queue a task to be executed on the main server thread at the beginning of next tick, but do not wait for it to
@ -86,5 +93,5 @@ public interface ILuaContext
* @return The "id" of the task. This will be the first argument to the {@code task_completed} event. * @return The "id" of the task. This will be the first argument to the {@code task_completed} event.
* @throws LuaException If the task could not be queued. * @throws LuaException If the task could not be queued.
*/ */
public long issueMainThreadTask( ILuaTask task ) throws LuaException; long issueMainThreadTask( @Nonnull ILuaTask task ) throws LuaException;
} }

View File

@ -9,6 +9,9 @@ package dan200.computercraft.api.lua;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* An interface for representing custom objects returned by {@link IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])} * An interface for representing custom objects returned by {@link IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}
* calls. * calls.
@ -24,7 +27,8 @@ public interface ILuaObject
* @return The method names this object provides. * @return The method names this object provides.
* @see IPeripheral#getMethodNames() * @see IPeripheral#getMethodNames()
*/ */
public String[] getMethodNames(); @Nonnull
String[] getMethodNames();
/** /**
* Called when a user calls one of the methods that this object implements. This works the same as * Called when a user calls one of the methods that this object implements. This works the same as
@ -47,5 +51,6 @@ public interface ILuaObject
* intercepted, or the computer will leak memory and end up in a broken state.w * intercepted, or the computer will leak memory and end up in a broken state.w
* @see IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[]) * @see IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])
*/ */
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException; @Nullable
Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException;
} }

View File

@ -6,6 +6,8 @@
package dan200.computercraft.api.lua; package dan200.computercraft.api.lua;
import javax.annotation.Nullable;
/** /**
* A task which can be executed via {@link ILuaContext#executeMainThreadTask(ILuaTask)} or * A task which can be executed via {@link ILuaContext#executeMainThreadTask(ILuaTask)} or
* {@link ILuaContext#issueMainThreadTask(ILuaTask)}. This will be run on the main thread, at the beginning of the * {@link ILuaContext#issueMainThreadTask(ILuaTask)}. This will be run on the main thread, at the beginning of the
@ -25,5 +27,6 @@ public interface ILuaTask
* same message as your exception. Use this to throw appropriate errors if the wrong * same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method. * arguments are supplied to your method.
*/ */
public Object[] execute() throws LuaException; @Nullable
Object[] execute() throws LuaException;
} }

View File

@ -6,6 +6,8 @@
package dan200.computercraft.api.lua; package dan200.computercraft.api.lua;
import javax.annotation.Nullable;
/** /**
* An exception representing an error in Lua, like that raised by the {@code error()} function. * An exception representing an error in Lua, like that raised by the {@code error()} function.
*/ */
@ -19,12 +21,12 @@ public class LuaException extends Exception
this( "error", 1 ); this( "error", 1 );
} }
public LuaException( String message ) public LuaException( @Nullable String message )
{ {
this( message, 1 ); this( message, 1 );
} }
public LuaException( String message, int level ) public LuaException( @Nullable String message, int level )
{ {
super( message ); super( message );
m_level = level; m_level = level;

View File

@ -11,6 +11,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* Represents an item that can be placed in a disk drive and used by a Computer. * Represents an item that can be placed in a disk drive and used by a Computer.
* Implement this interface on your Item class to allow it to be used in the drive. * Implement this interface on your Item class to allow it to be used in the drive.
@ -23,7 +26,8 @@ public interface IMedia
* @param stack The itemstack to inspect. * @param stack The itemstack to inspect.
* @return The label. ie: "Dan's Programs". * @return The label. ie: "Dan's Programs".
*/ */
public String getLabel( ItemStack stack ); @Nullable
String getLabel( @Nonnull ItemStack stack );
/** /**
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua. * Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
@ -32,7 +36,7 @@ public interface IMedia
* @param label The string to set the label to. * @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified. * @return true if the label was updated, false if the label may not be modified.
*/ */
public boolean setLabel( ItemStack stack, String label ); boolean setLabel( @Nonnull ItemStack stack, @Nullable String label );
/** /**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: * If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
@ -41,7 +45,8 @@ public interface IMedia
* @param stack The itemstack to inspect. * @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio. * @return The name, or null if this item does not represent an item with audio.
*/ */
public String getAudioTitle( ItemStack stack ); @Nullable
String getAudioTitle( @Nonnull ItemStack stack );
/** /**
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play. * If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
@ -49,7 +54,8 @@ public interface IMedia
* @param stack The itemstack to inspect. * @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio. * @return The name, or null if this item does not represent an item with audio.
*/ */
public SoundEvent getAudio( ItemStack stack ); @Nullable
SoundEvent getAudio( @Nonnull ItemStack stack );
/** /**
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will * If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will
@ -64,5 +70,6 @@ public interface IMedia
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long) * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String) * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/ */
public IMount createDataMount( ItemStack stack, World world ); @Nullable
IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world );
} }

View File

@ -8,6 +8,9 @@ package dan200.computercraft.api.media;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* This interface is used to provide {@link IMedia} implementations for {@link ItemStack}. * This interface is used to provide {@link IMedia} implementations for {@link ItemStack}.
* *
@ -22,5 +25,6 @@ public interface IMediaProvider
* @return An IMedia implementation, or null if the item is not something you wish to handle * @return An IMedia implementation, or null if the item is not something you wish to handle
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider) * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
*/ */
public IMedia getMedia( ItemStack stack ); @Nullable
IMedia getMedia( @Nonnull ItemStack stack );
} }

View File

@ -11,6 +11,9 @@ import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount; import dan200.computercraft.api.filesystem.IWritableMount;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* The interface passed to peripherals by computers or turtles, providing methods * The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact * that they can call. This should not be implemented by your classes. Do not interact
@ -33,7 +36,8 @@ public interface IComputerAccess
* @see #unmount(String) * @see #unmount(String)
* @see IMount * @see IMount
*/ */
public String mount( String desiredLocation, IMount mount ); @Nullable
String mount( @Nonnull String desiredLocation, @Nonnull IMount mount );
/** /**
* Mount a mount onto the computer's file system in a read only mode. * Mount a mount onto the computer's file system in a read only mode.
@ -51,7 +55,8 @@ public interface IComputerAccess
* @see #unmount(String) * @see #unmount(String)
* @see IMount * @see IMount
*/ */
public String mount( String desiredLocation, IMount mount, String driveName ); @Nullable
String mount( @Nonnull String desiredLocation, @Nonnull IMount mount, @Nonnull String driveName );
/** /**
* Mount a mount onto the computer's file system in a writable mode. * Mount a mount onto the computer's file system in a writable mode.
@ -67,7 +72,8 @@ public interface IComputerAccess
* @see #unmount(String) * @see #unmount(String)
* @see IMount * @see IMount
*/ */
public String mountWritable( String desiredLocation, IWritableMount mount ); @Nullable
String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount );
/** /**
* Mount a mount onto the computer's file system in a writable mode. * Mount a mount onto the computer's file system in a writable mode.
@ -84,7 +90,7 @@ public interface IComputerAccess
* @see #unmount(String) * @see #unmount(String)
* @see IMount * @see IMount
*/ */
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName ); String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount, @Nonnull String driveName );
/** /**
* Unmounts a directory previously mounted onto the computers file system by {@link #mount(String, IMount)} * Unmounts a directory previously mounted onto the computers file system by {@link #mount(String, IMount)}
@ -104,7 +110,7 @@ public interface IComputerAccess
* @see #mount(String, IMount) * @see #mount(String, IMount)
* @see #mountWritable(String, IWritableMount) * @see #mountWritable(String, IWritableMount)
*/ */
public void unmount( String location ); void unmount( @Nullable String location );
/** /**
* Returns the numerical ID of this computer. * Returns the numerical ID of this computer.
@ -114,7 +120,7 @@ public interface IComputerAccess
* *
* @return The identifier. * @return The identifier.
*/ */
public int getID(); int getID();
/** /**
* Causes an event to be raised on this computer, which the computer can respond to by calling * Causes an event to be raised on this computer, which the computer can respond to by calling
@ -134,7 +140,7 @@ public interface IComputerAccess
* @throws RuntimeException If the peripheral has been detached. * @throws RuntimeException If the peripheral has been detached.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod * @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
*/ */
public void queueEvent( String event, Object[] arguments ); void queueEvent( @Nonnull String event, @Nullable Object[] arguments );
/** /**
* Get a string, unique to the computer, by which the computer refers to this peripheral. * Get a string, unique to the computer, by which the computer refers to this peripheral.
@ -146,5 +152,6 @@ public interface IComputerAccess
* @return A string unique to the computer, but not globally. * @return A string unique to the computer, but not globally.
* @throws RuntimeException If the peripheral has been detached. * @throws RuntimeException If the peripheral has been detached.
*/ */
public String getAttachmentName(); @Nonnull
String getAttachmentName();
} }

View File

@ -9,6 +9,9 @@ package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* The interface that defines a peripheral. See {@link IPeripheralProvider} for how to associate blocks with peripherals. * The interface that defines a peripheral. See {@link IPeripheralProvider} for how to associate blocks with peripherals.
*/ */
@ -20,7 +23,8 @@ public interface IPeripheral
* *
* @return A string identifying the type of peripheral. * @return A string identifying the type of peripheral.
*/ */
public String getType(); @Nonnull
String getType();
/** /**
* Should return an array of strings that identify the methods that this * Should return an array of strings that identify the methods that this
@ -30,7 +34,8 @@ public interface IPeripheral
* @return An array of strings representing method names. * @return An array of strings representing method names.
* @see #callMethod * @see #callMethod
*/ */
public String[] getMethodNames(); @Nonnull
String[] getMethodNames();
/** /**
* This is called when a lua program on an attached computer calls {@code peripheral.call()} with * This is called when a lua program on an attached computer calls {@code peripheral.call()} with
@ -66,7 +71,8 @@ public interface IPeripheral
* intercepted, or the computer will leak memory and end up in a broken state. * intercepted, or the computer will leak memory and end up in a broken state.
* @see #getMethodNames * @see #getMethodNames
*/ */
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException; @Nullable
Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException;
/** /**
* Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral. * Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral.
@ -85,7 +91,7 @@ public interface IPeripheral
* computers can be attached to a peripheral at once. * computers can be attached to a peripheral at once.
* @see #detach * @see #detach
*/ */
public void attach( IComputerAccess computer ); void attach( @Nonnull IComputerAccess computer );
/** /**
* Is called when a computer is detaching from the peripheral. * Is called when a computer is detaching from the peripheral.
@ -102,7 +108,7 @@ public interface IPeripheral
* computers can be attached to a peripheral at once. * computers can be attached to a peripheral at once.
* @see #detach * @see #detach
*/ */
public void detach( IComputerAccess computer ); void detach( @Nonnull IComputerAccess computer );
/** /**
* Determine whether this peripheral is equivalent to another one. * Determine whether this peripheral is equivalent to another one.
@ -113,5 +119,5 @@ public interface IPeripheral
* @param other The peripheral to compare against. This may be {@code null}. * @param other The peripheral to compare against. This may be {@code null}.
* @return Whether these peripherals are equivalent. * @return Whether these peripherals are equivalent.
*/ */
public boolean equals( IPeripheral other ); boolean equals( @Nullable IPeripheral other );
} }

View File

@ -10,6 +10,9 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* This interface is used to create peripheral implementations for blocks. * This interface is used to create peripheral implementations for blocks.
* *
@ -26,5 +29,6 @@ public interface IPeripheralProvider
* @return A peripheral, or {@code null} if there is not a peripheral here you'd like to handle. * @return A peripheral, or {@code null} if there is not a peripheral here you'd like to handle.
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
*/ */
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side ); @Nullable
IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
} }

View File

@ -9,6 +9,8 @@ package dan200.computercraft.api.permissions;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
/** /**
* This interface is used to restrict where turtles can move or build. * This interface is used to restrict where turtles can move or build.
* *
@ -25,7 +27,7 @@ public interface ITurtlePermissionProvider
* @param pos The location of the block. * @param pos The location of the block.
* @return Whether the turtle can move into this block. * @return Whether the turtle can move into this block.
*/ */
public boolean isBlockEnterable( World world, BlockPos pos ); boolean isBlockEnterable( @Nonnull World world, @Nonnull BlockPos pos );
/** /**
* Determine whether a block can be modified by a turtle. * Determine whether a block can be modified by a turtle.
@ -36,5 +38,5 @@ public interface ITurtlePermissionProvider
* @param pos The location of the block. * @param pos The location of the block.
* @return Whether the turtle can modify this block. * @return Whether the turtle can modify this block.
*/ */
public boolean isBlockEditable( World world, BlockPos pos ); boolean isBlockEditable( @Nonnull World world, @Nonnull BlockPos pos );
} }

View File

@ -10,6 +10,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
/** /**
* This interface is used to provide bundled redstone output for blocks. * This interface is used to provide bundled redstone output for blocks.
* *
@ -27,5 +29,5 @@ public interface IBundledRedstoneProvider
* handle this block. * handle this block.
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider) * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
*/ */
public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ); int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side );
} }

View File

@ -16,6 +16,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* The interface passed to turtle by turtles, providing methods that they can call. * The interface passed to turtle by turtles, providing methods that they can call.
* *
@ -29,14 +32,16 @@ public interface ITurtleAccess
* *
* @return the world in which the turtle resides. * @return the world in which the turtle resides.
*/ */
public World getWorld(); @Nonnull
World getWorld();
/** /**
* Returns a vector containing the integer co-ordinates at which the turtle resides. * Returns a vector containing the integer co-ordinates at which the turtle resides.
* *
* @return a vector containing the integer co-ordinates at which the turtle resides. * @return a vector containing the integer co-ordinates at which the turtle resides.
*/ */
public BlockPos getPosition(); @Nonnull
BlockPos getPosition();
/** /**
* Attempt to move this turtle to a new position. * Attempt to move this turtle to a new position.
@ -51,7 +56,7 @@ public interface ITurtleAccess
* {@link dan200.computercraft.api.permissions.ITurtlePermissionProvider#isBlockEnterable(World, BlockPos)}. * {@link dan200.computercraft.api.permissions.ITurtlePermissionProvider#isBlockEnterable(World, BlockPos)}.
* @throws UnsupportedOperationException When attempting to teleport on the client side. * @throws UnsupportedOperationException When attempting to teleport on the client side.
*/ */
public boolean teleportTo( World world, BlockPos pos ); boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos );
/** /**
* Returns a vector containing the floating point co-ordinates at which the turtle is rendered. * Returns a vector containing the floating point co-ordinates at which the turtle is rendered.
@ -61,7 +66,8 @@ public interface ITurtleAccess
* @return A vector containing the floating point co-ordinates at which the turtle resides. * @return A vector containing the floating point co-ordinates at which the turtle resides.
* @see #getVisualYaw(float) * @see #getVisualYaw(float)
*/ */
public Vec3d getVisualPosition( float f ); @Nonnull
Vec3d getVisualPosition( float f );
/** /**
* Returns the yaw the turtle is facing when it is rendered. * Returns the yaw the turtle is facing when it is rendered.
@ -70,7 +76,7 @@ public interface ITurtleAccess
* @return The yaw the turtle is facing. * @return The yaw the turtle is facing.
* @see #getVisualPosition(float) * @see #getVisualPosition(float)
*/ */
public float getVisualYaw( float f ); float getVisualYaw( float f );
/** /**
* Returns the world direction the turtle is currently facing. * Returns the world direction the turtle is currently facing.
@ -78,7 +84,8 @@ public interface ITurtleAccess
* @return The world direction the turtle is currently facing. * @return The world direction the turtle is currently facing.
* @see #setDirection(EnumFacing) * @see #setDirection(EnumFacing)
*/ */
public EnumFacing getDirection(); @Nonnull
EnumFacing getDirection();
/** /**
* Set the direction the turtle is facing. Note that this will not play a rotation animation, you will also need to * Set the direction the turtle is facing. Note that this will not play a rotation animation, you will also need to
@ -87,7 +94,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). * @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() * @see #getDirection()
*/ */
public void setDirection( EnumFacing dir ); void setDirection( @Nonnull EnumFacing dir );
/** /**
* Get the currently selected slot in the turtle's inventory. * Get the currently selected slot in the turtle's inventory.
@ -96,7 +103,7 @@ public interface ITurtleAccess
* @see #getInventory() * @see #getInventory()
* @see #setSelectedSlot(int) * @see #setSelectedSlot(int)
*/ */
public int getSelectedSlot(); int getSelectedSlot();
/** /**
* Set the currently selected slot in the turtle's inventory. * Set the currently selected slot in the turtle's inventory.
@ -107,7 +114,7 @@ public interface ITurtleAccess
* @see #getInventory() * @see #getInventory()
* @see #getSelectedSlot() * @see #getSelectedSlot()
*/ */
public void setSelectedSlot( int slot ); void setSelectedSlot( int slot );
/** /**
* Sets the colour of the turtle, as if the player had dyed it with a dye item. * Sets the colour of the turtle, as if the player had dyed it with a dye item.
@ -116,7 +123,7 @@ public interface ITurtleAccess
* the dye from the turtle. * the dye from the turtle.
* @see #getDyeColour() * @see #getDyeColour()
*/ */
public void setDyeColour( int dyeColour ); void setDyeColour( int dyeColour );
/** /**
* Gets the colour the turtle has been dyed. * Gets the colour the turtle has been dyed.
@ -125,14 +132,15 @@ public interface ITurtleAccess
* is clean. * is clean.
* @see #getDyeColour() * @see #getDyeColour()
*/ */
public int getDyeColour(); int getDyeColour();
/** /**
* Get the inventory of this turtle * Get the inventory of this turtle
* *
* @return This turtle's inventory * @return This turtle's inventory
*/ */
public IInventory getInventory(); @Nonnull
IInventory getInventory();
/** /**
* Determine whether this turtle will require fuel when performing actions. * Determine whether this turtle will require fuel when performing actions.
@ -141,7 +149,7 @@ public interface ITurtleAccess
* @see #getFuelLevel() * @see #getFuelLevel()
* @see #setFuelLevel(int) * @see #setFuelLevel(int)
*/ */
public boolean isFuelNeeded(); boolean isFuelNeeded();
/** /**
* Get the current fuel level of this turtle. * Get the current fuel level of this turtle.
@ -150,7 +158,7 @@ public interface ITurtleAccess
* @see #isFuelNeeded() * @see #isFuelNeeded()
* @see #setFuelLevel(int) * @see #setFuelLevel(int)
*/ */
public int getFuelLevel(); int getFuelLevel();
/** /**
* Set the fuel level to a new value. It is generally preferred to use {@link #consumeFuel(int)}} or {@link #addFuel(int)} * Set the fuel level to a new value. It is generally preferred to use {@link #consumeFuel(int)}} or {@link #addFuel(int)}
@ -162,14 +170,14 @@ public interface ITurtleAccess
* @see #addFuel(int) * @see #addFuel(int)
* @see #consumeFuel(int) * @see #consumeFuel(int)
*/ */
public void setFuelLevel( int fuel ); void setFuelLevel( int fuel );
/** /**
* Get the maximum amount of fuel a turtle can hold. * Get the maximum amount of fuel a turtle can hold.
* *
* @return The turtle's fuel limit. * @return The turtle's fuel limit.
*/ */
public int getFuelLimit(); int getFuelLimit();
/** /**
* Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle. * Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.
@ -179,7 +187,7 @@ public interface ITurtleAccess
* greater than the current fuel level of the turtle. No fuel will be consumed if {@code false} is returned. * greater than the current fuel level of the turtle. No fuel will be consumed if {@code false} is returned.
* @throws UnsupportedOperationException When attempting to consume fuel on the client side. * @throws UnsupportedOperationException When attempting to consume fuel on the client side.
*/ */
public boolean consumeFuel( int fuel ); boolean consumeFuel( int fuel );
/** /**
* Increase the turtle's fuel level by the given amount. * Increase the turtle's fuel level by the given amount.
@ -187,7 +195,7 @@ public interface ITurtleAccess
* @param fuel The amount to refuel with. * @param fuel The amount to refuel with.
* @throws UnsupportedOperationException When attempting to refuel on the client side. * @throws UnsupportedOperationException When attempting to refuel on the client side.
*/ */
public void addFuel( int fuel ); void addFuel( int fuel );
/** /**
* Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed * Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed
@ -209,7 +217,8 @@ public interface ITurtleAccess
* @see ITurtleCommand * @see ITurtleCommand
* @see ILuaContext#pullEvent(String) * @see ILuaContext#pullEvent(String)
*/ */
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException; @Nonnull
Object[] executeCommand( @Nonnull ILuaContext context, @Nonnull ITurtleCommand command ) throws LuaException, InterruptedException;
/** /**
* Start playing a specific animation. This will prevent other turtle commands from executing until * Start playing a specific animation. This will prevent other turtle commands from executing until
@ -219,7 +228,7 @@ public interface ITurtleAccess
* @throws UnsupportedOperationException When attempting to execute play an animation on the client side. * @throws UnsupportedOperationException When attempting to execute play an animation on the client side.
* @see TurtleAnimation * @see TurtleAnimation
*/ */
public void playAnimation( TurtleAnimation animation ); void playAnimation( @Nonnull TurtleAnimation animation );
/** /**
* Returns the turtle on the specified side of the turtle, if there is one. * Returns the turtle on the specified side of the turtle, if there is one.
@ -228,7 +237,8 @@ public interface ITurtleAccess
* @return The upgrade on the specified side of the turtle, if there is one. * @return The upgrade on the specified side of the turtle, if there is one.
* @see #setUpgrade(TurtleSide, ITurtleUpgrade) * @see #setUpgrade(TurtleSide, ITurtleUpgrade)
*/ */
public ITurtleUpgrade getUpgrade( TurtleSide side ); @Nullable
ITurtleUpgrade getUpgrade( @Nonnull TurtleSide side );
/** /**
* Set the upgrade for a given side, resetting peripherals and clearing upgrade specific data. * Set the upgrade for a given side, resetting peripherals and clearing upgrade specific data.
@ -237,7 +247,7 @@ public interface ITurtleAccess
* @param upgrade The upgrade to set, may be {@code null} to clear. * @param upgrade The upgrade to set, may be {@code null} to clear.
* @see #getUpgrade(TurtleSide) * @see #getUpgrade(TurtleSide)
*/ */
public void setUpgrade( TurtleSide side, ITurtleUpgrade upgrade ); void setUpgrade( @Nonnull TurtleSide side, @Nullable ITurtleUpgrade upgrade );
/** /**
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one. * Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
@ -245,7 +255,8 @@ public interface ITurtleAccess
* @param side The side to get the peripheral from. * @param side The side to get the peripheral from.
* @return The peripheral created by the upgrade on the specified side of the turtle, {@code null} if none exists. * @return The peripheral created by the upgrade on the specified side of the turtle, {@code null} if none exists.
*/ */
public IPeripheral getPeripheral( TurtleSide side ); @Nullable
IPeripheral getPeripheral( @Nonnull TurtleSide side );
/** /**
* Get an upgrade-specific NBT compound, which can be used to store arbitrary data. * Get an upgrade-specific NBT compound, which can be used to store arbitrary data.
@ -257,7 +268,8 @@ public interface ITurtleAccess
* @return The upgrade-specific data. * @return The upgrade-specific data.
* @see #updateUpgradeNBTData(TurtleSide) * @see #updateUpgradeNBTData(TurtleSide)
*/ */
public NBTTagCompound getUpgradeNBTData( TurtleSide side ); @Nonnull
NBTTagCompound getUpgradeNBTData( @Nullable TurtleSide side );
/** /**
* Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the * Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the
@ -266,5 +278,5 @@ public interface ITurtleAccess
* @param side The side to mark dirty. * @param side The side to mark dirty.
* @see #updateUpgradeNBTData(TurtleSide) * @see #updateUpgradeNBTData(TurtleSide)
*/ */
public void updateUpgradeNBTData( TurtleSide side ); void updateUpgradeNBTData( @Nonnull TurtleSide side );
} }

View File

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

View File

@ -17,6 +17,8 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
@ -36,7 +38,8 @@ public interface ITurtleUpgrade
* @return The unique ID for this upgrade. * @return The unique ID for this upgrade.
* @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade) * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
*/ */
public ResourceLocation getUpgradeID(); @Nonnull
ResourceLocation getUpgradeID();
/** /**
* Gets a numerical identifier representing this type of turtle upgrade, * Gets a numerical identifier representing this type of turtle upgrade,
@ -47,7 +50,7 @@ public interface ITurtleUpgrade
* @return The legacy ID, or -1 if is needed. * @return The legacy ID, or -1 if is needed.
* @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade) * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade)
*/ */
public int getLegacyUpgradeID(); int getLegacyUpgradeID();
/** /**
* Return an unlocalised string to describe this type of turtle in turtle item names. * Return an unlocalised string to describe this type of turtle in turtle item names.
@ -56,7 +59,8 @@ public interface ITurtleUpgrade
* *
* @return The localisation key for this upgrade's adjective. * @return The localisation key for this upgrade's adjective.
*/ */
public String getUnlocalisedAdjective(); @Nonnull
String getUnlocalisedAdjective();
/** /**
* Return whether this turtle adds a tool or a peripheral to the turtle. * Return whether this turtle adds a tool or a peripheral to the turtle.
@ -64,7 +68,8 @@ public interface ITurtleUpgrade
* @return The type of upgrade this is. * @return The type of upgrade this is.
* @see TurtleUpgradeType for the differences between them. * @see TurtleUpgradeType for the differences between them.
*/ */
public TurtleUpgradeType getType(); @Nonnull
TurtleUpgradeType getType();
/** /**
* Return an item stack representing the type of item that a turtle must be crafted * Return an item stack representing the type of item that a turtle must be crafted
@ -73,7 +78,8 @@ public interface ITurtleUpgrade
* *
* @return The item stack to craft with, or {@code null} if it cannot be crafted. * @return The item stack to craft with, or {@code null} if it cannot be crafted.
*/ */
public ItemStack getCraftingItem(); @Nullable
ItemStack getCraftingItem();
/** /**
* Will only be called for peripheral upgrades. Creates a peripheral for a turtle being placed using this upgrade. * Will only be called for peripheral upgrades. Creates a peripheral for a turtle being placed using this upgrade.
@ -87,7 +93,8 @@ public interface ITurtleUpgrade
* @return The newly created peripheral. You may return {@code null} if this upgrade is a Tool * @return The newly created peripheral. You may return {@code null} if this upgrade is a Tool
* and this method is not expected to be called. * and this method is not expected to be called.
*/ */
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side ); @Nullable
IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side );
/** /**
* Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called * Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
@ -104,7 +111,8 @@ public interface ITurtleUpgrade
* a swinging animation. You may return {@code null} if this turtle is a Peripheral and this method is not expected * a swinging animation. You may return {@code null} if this turtle is a Peripheral and this method is not expected
* to be called. * to be called.
*/ */
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing direction ); @Nonnull
TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction );
/** /**
* Called to obtain the model to be used when rendering a turtle peripheral. * Called to obtain the model to be used when rendering a turtle peripheral.
@ -119,7 +127,8 @@ public interface ITurtleUpgrade
* a transformation of {@code null} has the same effect as the identify matrix. * a transformation of {@code null} has the same effect as the identify matrix.
*/ */
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Pair<IBakedModel, Matrix4f> getModel( ITurtleAccess turtle, TurtleSide side ); @Nonnull
Pair<IBakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side );
/** /**
* Called once per tick for each turtle which has the upgrade equipped. * Called once per tick for each turtle which has the upgrade equipped.
@ -127,5 +136,5 @@ public interface ITurtleUpgrade
* @param turtle Access to the turtle that the upgrade resides on. * @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. * @param side Which side of the turtle (left or right) the upgrade resides on.
*/ */
public void update( ITurtleAccess turtle, TurtleSide side ); void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side );
} }

View File

@ -8,6 +8,9 @@ package dan200.computercraft.api.turtle;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* Used to indicate the result of executing a turtle command. * Used to indicate the result of executing a turtle command.
* *
@ -24,6 +27,7 @@ public final class TurtleCommandResult
* *
* @return A successful command result with no values. * @return A successful command result with no values.
*/ */
@Nonnull
public static TurtleCommandResult success() public static TurtleCommandResult success()
{ {
return success( null ); return success( null );
@ -35,7 +39,8 @@ public final class TurtleCommandResult
* @param results The results of executing this command. * @param results The results of executing this command.
* @return A successful command result with the given values. * @return A successful command result with the given values.
*/ */
public static TurtleCommandResult success( Object[] results ) @Nonnull
public static TurtleCommandResult success( @Nullable Object[] results )
{ {
if( results == null || results.length == 0 ) if( results == null || results.length == 0 )
{ {
@ -52,6 +57,7 @@ public final class TurtleCommandResult
* *
* @return A failed command result with no message. * @return A failed command result with no message.
*/ */
@Nonnull
public static TurtleCommandResult failure() public static TurtleCommandResult failure()
{ {
return failure( null ); return failure( null );
@ -63,7 +69,8 @@ public final class TurtleCommandResult
* @param errorMessage The error message to provide. * @param errorMessage The error message to provide.
* @return A failed command result with a message. * @return A failed command result with a message.
*/ */
public static TurtleCommandResult failure( String errorMessage ) @Nonnull
public static TurtleCommandResult failure( @Nullable String errorMessage )
{ {
if( errorMessage == null ) if( errorMessage == null )
{ {
@ -101,6 +108,7 @@ public final class TurtleCommandResult
* *
* @return The command's error message, or {@code null} if it was a success. * @return The command's error message, or {@code null} if it was a success.
*/ */
@Nullable
public String getErrorMessage() public String getErrorMessage()
{ {
return m_errorMessage; return m_errorMessage;
@ -111,6 +119,7 @@ public final class TurtleCommandResult
* *
* @return The command's result, or {@code null} if it was a failure. * @return The command's result, or {@code null} if it was a failure.
*/ */
@Nullable
public Object[] getResults() public Object[] getResults()
{ {
return m_results; return m_results;

View File

@ -38,6 +38,8 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent;
import javax.annotation.Nonnull;
public class CCTurtleProxyClient extends CCTurtleProxyCommon public class CCTurtleProxyClient extends CCTurtleProxyCommon
{ {
public CCTurtleProxyClient() public CCTurtleProxyClient()
@ -56,8 +58,9 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
{ {
private ModelResourceLocation turtle_dynamic = new ModelResourceLocation( "computercraft:turtle_dynamic", "inventory" ); private ModelResourceLocation turtle_dynamic = new ModelResourceLocation( "computercraft:turtle_dynamic", "inventory" );
@Nonnull
@Override @Override
public ModelResourceLocation getModelLocation( ItemStack stack ) public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
{ {
return turtle_dynamic; return turtle_dynamic;
} }
@ -188,7 +191,7 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
private static class TurtleItemColour implements IItemColor private static class TurtleItemColour implements IItemColor
{ {
@Override @Override
public int getColorFromItemstack( ItemStack stack, int tintIndex ) public int getColorFromItemstack( @Nonnull ItemStack stack, int tintIndex )
{ {
if( tintIndex == 0 ) if( tintIndex == 0 )
{ {

View File

@ -55,6 +55,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -88,8 +89,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
private ModelResourceLocation computer = new ModelResourceLocation( "computercraft:CC-Computer", "inventory" ); private ModelResourceLocation computer = new ModelResourceLocation( "computercraft:CC-Computer", "inventory" );
private ModelResourceLocation advanced_computer = new ModelResourceLocation( "computercraft:advanced_computer", "inventory" ); private ModelResourceLocation advanced_computer = new ModelResourceLocation( "computercraft:advanced_computer", "inventory" );
@Nonnull
@Override @Override
public ModelResourceLocation getModelLocation( ItemStack stack ) public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
{ {
ItemComputer itemComputer = (ItemComputer) stack.getItem(); ItemComputer itemComputer = (ItemComputer) stack.getItem();
ComputerFamily family = itemComputer.getFamily( stack.getItemDamage() ); ComputerFamily family = itemComputer.getFamily( stack.getItemDamage() );
@ -121,8 +123,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
private ModelResourceLocation advanced_pocket_computer_on = new ModelResourceLocation( "computercraft:advanced_pocket_computer_on", "inventory" ); private ModelResourceLocation advanced_pocket_computer_on = new ModelResourceLocation( "computercraft:advanced_pocket_computer_on", "inventory" );
private ModelResourceLocation advanced_pocket_computer_blinking = new ModelResourceLocation( "computercraft:advanced_pocket_computer_blinking", "inventory" ); private ModelResourceLocation advanced_pocket_computer_blinking = new ModelResourceLocation( "computercraft:advanced_pocket_computer_blinking", "inventory" );
@Nonnull
@Override @Override
public ModelResourceLocation getModelLocation( ItemStack stack ) public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
{ {
ItemPocketComputer itemPocketComputer = (ItemPocketComputer)stack.getItem(); ItemPocketComputer itemPocketComputer = (ItemPocketComputer)stack.getItem();
switch( itemPocketComputer.getFamily( stack ) ) switch( itemPocketComputer.getFamily( stack ) )
@ -180,7 +183,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
mc.getItemColors().registerItemColorHandler( new IItemColor() mc.getItemColors().registerItemColorHandler( new IItemColor()
{ {
@Override @Override
public int getColorFromItemstack( ItemStack stack, int layout ) public int getColorFromItemstack( @Nonnull ItemStack stack, int layout )
{ {
if( layout != 1 ) return 0xFFFFFF; if( layout != 1 ) return 0xFFFFFF;
@ -219,8 +222,9 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
ModelBakery.registerItemVariants( item, new ResourceLocation( "computercraft", name ) ); ModelBakery.registerItemVariants( item, new ResourceLocation( "computercraft", name ) );
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, new ItemMeshDefinition() Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, new ItemMeshDefinition()
{ {
@Nonnull
@Override @Override
public ModelResourceLocation getModelLocation( ItemStack stack ) public ModelResourceLocation getModelLocation( @Nonnull ItemStack stack )
{ {
return res; return res;
} }
@ -519,7 +523,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
} }
@Override @Override
public int getColorFromItemstack(ItemStack stack, int layer) public int getColorFromItemstack( @Nonnull ItemStack stack, int layer)
{ {
return layer == 0 ? 0xFFFFFF : disk.getColor(stack); return layer == 0 ? 0xFFFFFF : disk.getColor(stack);
} }

View File

@ -24,6 +24,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import javax.annotation.Nonnull;
public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor> public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMonitor>
{ {
public TileEntityMonitorRenderer() public TileEntityMonitorRenderer()
@ -31,7 +33,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
} }
@Override @Override
public void renderTileEntityAt( TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i ) public void renderTileEntityAt( @Nonnull TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i )
{ {
if( tileEntity != null ) if( tileEntity != null )
{ {

View File

@ -41,6 +41,7 @@ import net.minecraftforge.client.model.pipeline.LightUtil;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
import java.util.List; import java.util.List;
@ -75,7 +76,7 @@ public class TileEntityTurtleRenderer extends TileEntitySpecialRenderer<TileTurt
} }
@Override @Override
public void renderTileEntityAt( TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i ) public void renderTileEntityAt( @Nonnull TileTurtle tileEntity, double posX, double posY, double posZ, float f, int i )
{ {
if( tileEntity != null ) if( tileEntity != null )
{ {

View File

@ -10,6 +10,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
import javax.vecmath.Point3f; import javax.vecmath.Point3f;
import java.util.ArrayList; import java.util.ArrayList;
@ -39,6 +40,7 @@ public class TurtleMultiModel implements IBakedModel
m_faceQuads = new List[6]; m_faceQuads = new List[6];
} }
@Nonnull
@Override @Override
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand ) public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
{ {
@ -107,18 +109,21 @@ public class TurtleMultiModel implements IBakedModel
return m_baseModel.isBuiltInRenderer(); return m_baseModel.isBuiltInRenderer();
} }
@Nonnull
@Override @Override
public TextureAtlasSprite getParticleTexture() public TextureAtlasSprite getParticleTexture()
{ {
return m_baseModel.getParticleTexture(); return m_baseModel.getParticleTexture();
} }
@Nonnull
@Override @Override
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms()
{ {
return m_baseModel.getItemCameraTransforms(); return m_baseModel.getItemCameraTransforms();
} }
@Nonnull
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {

View File

@ -30,6 +30,7 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ISmartVariant; import net.minecraftforge.client.model.ISmartVariant;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -102,8 +103,9 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
m_cachedModels = new HashMap<TurtleModelCombination, IBakedModel>(); m_cachedModels = new HashMap<TurtleModelCombination, IBakedModel>();
m_overrides = new ItemOverrideList( new ArrayList<ItemOverride>() ) m_overrides = new ItemOverrideList( new ArrayList<ItemOverride>() )
{ {
@Nonnull
@Override @Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) public IBakedModel handleItemState( @Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity)
{ {
ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem(); ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem();
ComputerFamily family = turtle.getFamily( stack ); ComputerFamily family = turtle.getFamily( stack );
@ -127,6 +129,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
}; };
} }
@Nonnull
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
@ -134,7 +137,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
} }
@Override @Override
public void onResourceManagerReload( IResourceManager resourceManager ) public void onResourceManagerReload( @Nonnull IResourceManager resourceManager )
{ {
m_cachedModels.clear(); m_cachedModels.clear();
} }
@ -173,6 +176,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
// These should not be called: // These should not be called:
@Nonnull
@Override @Override
public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, long rand ) public List<BakedQuad> getQuads( IBlockState state, EnumFacing facing, long rand )
{ {
@ -197,12 +201,14 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
return getDefaultModel().isBuiltInRenderer(); return getDefaultModel().isBuiltInRenderer();
} }
@Nonnull
@Override @Override
public TextureAtlasSprite getParticleTexture() public TextureAtlasSprite getParticleTexture()
{ {
return getDefaultModel().getParticleTexture(); return getDefaultModel().getParticleTexture();
} }
@Nonnull
@Override @Override
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms()
{ {

View File

@ -9,6 +9,8 @@ package dan200.computercraft.core.apis;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import javax.annotation.Nonnull;
// Contributed by Nia // Contributed by Nia
// Based on LuaBit (http://luaforge.net/projects/bit) // Based on LuaBit (http://luaforge.net/projects/bit)
@ -68,6 +70,7 @@ public class BitAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() { public String[] getMethodNames() {
return new String[] { return new String[] {
@ -77,7 +80,7 @@ public class BitAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
Object a = args.length>0?args[0]:null; Object a = args.length>0?args[0]:null;
Object b = args.length>1?args[1]:null; Object b = args.length>1?args[1]:null;

View File

@ -11,6 +11,8 @@ import dan200.computercraft.api.lua.ILuaObject;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.core.terminal.TextBuffer;
import javax.annotation.Nonnull;
public class BufferAPI implements ILuaAPI public class BufferAPI implements ILuaAPI
{ {
private static class BufferLuaObject implements ILuaObject private static class BufferLuaObject implements ILuaObject
@ -22,6 +24,7 @@ public class BufferAPI implements ILuaAPI
m_buffer = buffer; m_buffer = buffer;
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -35,7 +38,7 @@ public class BufferAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {
@ -165,6 +168,7 @@ public class BufferAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -174,7 +178,7 @@ public class BufferAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {

View File

@ -14,6 +14,7 @@ import dan200.computercraft.core.filesystem.FileSystemException;
import dan200.computercraft.core.filesystem.IMountedFileBinary; import dan200.computercraft.core.filesystem.IMountedFileBinary;
import dan200.computercraft.core.filesystem.IMountedFileNormal; import dan200.computercraft.core.filesystem.IMountedFileNormal;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -54,6 +55,7 @@ public class FSAPI implements ILuaAPI
m_fileSystem = null; m_fileSystem = null;
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -78,7 +80,7 @@ public class FSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -370,6 +372,7 @@ public class FSAPI implements ILuaAPI
private static Object[] wrapBufferedReader( final IMountedFileNormal reader ) private static Object[] wrapBufferedReader( final IMountedFileNormal reader )
{ {
return new Object[] { new ILuaObject() { return new Object[] { new ILuaObject() {
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -381,7 +384,7 @@ public class FSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -439,6 +442,7 @@ public class FSAPI implements ILuaAPI
private static Object[] wrapBufferedWriter( final IMountedFileNormal writer ) private static Object[] wrapBufferedWriter( final IMountedFileNormal writer )
{ {
return new Object[] { new ILuaObject() { return new Object[] { new ILuaObject() {
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -451,7 +455,7 @@ public class FSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -521,6 +525,7 @@ public class FSAPI implements ILuaAPI
return new Object[] { new ILuaObject() { return new Object[] { new ILuaObject() {
@Nonnull
@Override @Override
public String[] getMethodNames() { public String[] getMethodNames() {
return new String[] { return new String[] {
@ -530,7 +535,7 @@ public class FSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args) throws LuaException { public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args) throws LuaException {
switch( method ) switch( method )
{ {
case 0: case 0:
@ -572,6 +577,7 @@ public class FSAPI implements ILuaAPI
return new Object[] { new ILuaObject() { return new Object[] { new ILuaObject() {
@Nonnull
@Override @Override
public String[] getMethodNames() { public String[] getMethodNames() {
return new String[] { return new String[] {
@ -582,7 +588,7 @@ public class FSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args) throws LuaException { public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args) throws LuaException {
switch( method ) switch( method )
{ {
case 0: case 0:

View File

@ -10,6 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.ILuaObject; import dan200.computercraft.api.lua.ILuaObject;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import javax.annotation.Nonnull;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -72,6 +73,7 @@ public class HTTPAPI implements ILuaAPI
private static ILuaObject wrapBufferedReader( final BufferedReader reader, final int responseCode, final Map<String, String> responseHeaders ) private static ILuaObject wrapBufferedReader( final BufferedReader reader, final int responseCode, final Map<String, String> responseHeaders )
{ {
return new ILuaObject() { return new ILuaObject() {
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -85,7 +87,7 @@ public class HTTPAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -164,6 +166,7 @@ public class HTTPAPI implements ILuaAPI
} }
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -174,7 +177,7 @@ public class HTTPAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {

View File

@ -10,6 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.shared.util.StringUtil; import dan200.computercraft.shared.util.StringUtil;
import javax.annotation.Nonnull;
import java.util.*; import java.util.*;
public class OSAPI implements ILuaAPI public class OSAPI implements ILuaAPI
@ -47,7 +48,7 @@ public class OSAPI implements ILuaAPI
} }
@Override @Override
public int compareTo( Alarm o ) public int compareTo( @Nonnull Alarm o )
{ {
double t = (double)m_day * 24.0 + m_time; double t = (double)m_day * 24.0 + m_time;
double ot = (double)m_day * 24.0 + m_time; double ot = (double)m_day * 24.0 + m_time;
@ -166,6 +167,7 @@ public class OSAPI implements ILuaAPI
} }
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -216,7 +218,7 @@ public class OSAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {

View File

@ -18,6 +18,7 @@ import dan200.computercraft.core.computer.ITask;
import dan200.computercraft.core.filesystem.FileSystem; import dan200.computercraft.core.filesystem.FileSystem;
import dan200.computercraft.core.filesystem.FileSystemException; import dan200.computercraft.core.filesystem.FileSystemException;
import javax.annotation.Nonnull;
import java.util.*; import java.util.*;
public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChangeListener public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChangeListener
@ -118,13 +119,13 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
// IComputerAccess implementation // IComputerAccess implementation
@Override @Override
public String mount( String desiredLoc, IMount mount ) public String mount( @Nonnull String desiredLoc, @Nonnull IMount mount )
{ {
return mount( desiredLoc, mount, m_side ); return mount( desiredLoc, mount, m_side );
} }
@Override @Override
public synchronized String mount( String desiredLoc, IMount mount, String driveName ) public synchronized String mount( @Nonnull String desiredLoc, @Nonnull IMount mount, @Nonnull String driveName )
{ {
if( !m_attached ) if( !m_attached )
{ {
@ -153,13 +154,13 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
@Override @Override
public String mountWritable( String desiredLoc, IWritableMount mount ) public String mountWritable( @Nonnull String desiredLoc, @Nonnull IWritableMount mount )
{ {
return mountWritable( desiredLoc, mount, m_side ); return mountWritable( desiredLoc, mount, m_side );
} }
@Override @Override
public synchronized String mountWritable( String desiredLoc, IWritableMount mount, String driveName ) public synchronized String mountWritable( @Nonnull String desiredLoc, @Nonnull IWritableMount mount, @Nonnull String driveName )
{ {
if( !m_attached ) if( !m_attached )
{ {
@ -215,7 +216,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
@Override @Override
public synchronized void queueEvent( final String event, final Object[] arguments ) public synchronized void queueEvent( @Nonnull final String event, final Object[] arguments )
{ {
if( !m_attached ) { if( !m_attached ) {
throw new RuntimeException( "You are not attached to this Computer" ); throw new RuntimeException( "You are not attached to this Computer" );
@ -223,6 +224,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
m_environment.queueEvent( event, arguments ); m_environment.queueEvent( event, arguments );
} }
@Nonnull
@Override @Override
public synchronized String getAttachmentName() public synchronized String getAttachmentName()
{ {
@ -372,6 +374,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -384,7 +387,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {

View File

@ -10,6 +10,7 @@ import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.core.computer.Computer; import dan200.computercraft.core.computer.Computer;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -45,6 +46,7 @@ public class RedstoneAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -67,7 +69,7 @@ public class RedstoneAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {

View File

@ -11,6 +11,8 @@ import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.core.computer.IComputerEnvironment; import dan200.computercraft.core.computer.IComputerEnvironment;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import javax.annotation.Nonnull;
public class TermAPI implements ILuaAPI public class TermAPI implements ILuaAPI
{ {
private Terminal m_terminal; private Terminal m_terminal;
@ -45,6 +47,7 @@ public class TermAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -102,7 +105,7 @@ public class TermAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {

View File

@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,7 +28,7 @@ public class ComboMount implements IMount
// IMount implementation // IMount implementation
@Override @Override
public boolean exists( String path ) throws IOException public boolean exists( @Nonnull String path ) throws IOException
{ {
for( int i=m_parts.length-1; i>=0; --i ) for( int i=m_parts.length-1; i>=0; --i )
{ {
@ -41,7 +42,7 @@ public class ComboMount implements IMount
} }
@Override @Override
public boolean isDirectory( String path ) throws IOException public boolean isDirectory( @Nonnull String path ) throws IOException
{ {
for( int i=m_parts.length-1; i>=0; --i ) for( int i=m_parts.length-1; i>=0; --i )
{ {
@ -55,7 +56,7 @@ public class ComboMount implements IMount
} }
@Override @Override
public void list( String path, List<String> contents ) throws IOException public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
{ {
// Combine the lists from all the mounts // Combine the lists from all the mounts
List<String> foundFiles = null; List<String> foundFiles = null;
@ -99,7 +100,7 @@ public class ComboMount implements IMount
} }
@Override @Override
public long getSize( String path ) throws IOException public long getSize( @Nonnull String path ) throws IOException
{ {
for( int i=m_parts.length-1; i>=0; --i ) for( int i=m_parts.length-1; i>=0; --i )
{ {
@ -112,8 +113,9 @@ public class ComboMount implements IMount
throw new IOException( "No such file" ); throw new IOException( "No such file" );
} }
@Nonnull
@Override @Override
public InputStream openForRead( String path ) throws IOException public InputStream openForRead( @Nonnull String path ) throws IOException
{ {
for( int i=m_parts.length-1; i>=0; --i ) for( int i=m_parts.length-1; i>=0; --i )
{ {

View File

@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -21,30 +22,31 @@ public class EmptyMount implements IMount
// IMount implementation // IMount implementation
@Override @Override
public boolean exists( String path ) throws IOException public boolean exists( @Nonnull String path ) throws IOException
{ {
return path.isEmpty(); return path.isEmpty();
} }
@Override @Override
public boolean isDirectory( String path ) throws IOException public boolean isDirectory( @Nonnull String path ) throws IOException
{ {
return path.isEmpty(); return path.isEmpty();
} }
@Override @Override
public void list( String path, List<String> contents ) throws IOException public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
{ {
} }
@Override @Override
public long getSize( String path ) throws IOException public long getSize( @Nonnull String path ) throws IOException
{ {
return 0; return 0;
} }
@Nonnull
@Override @Override
public InputStream openForRead( String path ) throws IOException public InputStream openForRead( @Nonnull String path ) throws IOException
{ {
return null; return null;
} }

View File

@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IWritableMount; import dan200.computercraft.api.filesystem.IWritableMount;
import javax.annotation.Nonnull;
import java.io.*; import java.io.*;
import java.util.List; import java.util.List;
@ -39,14 +40,14 @@ public class FileMount implements IWritableMount
} }
@Override @Override
public void write( byte[] b ) throws IOException public void write( @Nonnull byte[] b ) throws IOException
{ {
count( b.length ); count( b.length );
m_innerStream.write( b ); m_innerStream.write( b );
} }
@Override @Override
public void write( byte[] b, int off, int len ) throws IOException public void write( @Nonnull byte[] b, int off, int len ) throws IOException
{ {
count( len ); count( len );
m_innerStream.write( b, off, len ); m_innerStream.write( b, off, len );
@ -94,7 +95,7 @@ public class FileMount implements IWritableMount
// IMount implementation // IMount implementation
@Override @Override
public boolean exists( String path ) throws IOException public boolean exists( @Nonnull String path ) throws IOException
{ {
if( !created() ) if( !created() )
{ {
@ -108,7 +109,7 @@ public class FileMount implements IWritableMount
} }
@Override @Override
public boolean isDirectory( String path ) throws IOException public boolean isDirectory( @Nonnull String path ) throws IOException
{ {
if( !created() ) if( !created() )
{ {
@ -122,7 +123,7 @@ public class FileMount implements IWritableMount
} }
@Override @Override
public void list( String path, List<String> contents ) throws IOException public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
{ {
if( !created() ) if( !created() )
{ {
@ -153,7 +154,7 @@ public class FileMount implements IWritableMount
} }
@Override @Override
public long getSize( String path ) throws IOException public long getSize( @Nonnull String path ) throws IOException
{ {
if( !created() ) if( !created() )
{ {
@ -180,8 +181,9 @@ public class FileMount implements IWritableMount
throw new IOException( "No such file" ); throw new IOException( "No such file" );
} }
@Nonnull
@Override @Override
public InputStream openForRead( String path ) throws IOException public InputStream openForRead( @Nonnull String path ) throws IOException
{ {
if( created() ) if( created() )
{ {
@ -197,7 +199,7 @@ public class FileMount implements IWritableMount
// IWritableMount implementation // IWritableMount implementation
@Override @Override
public void makeDirectory( String path ) throws IOException public void makeDirectory( @Nonnull String path ) throws IOException
{ {
create(); create();
File file = getRealPath( path ); File file = getRealPath( path );
@ -236,7 +238,7 @@ public class FileMount implements IWritableMount
} }
@Override @Override
public void delete( String path ) throws IOException public void delete( @Nonnull String path ) throws IOException
{ {
if( path.length() == 0 ) if( path.length() == 0 )
{ {
@ -278,8 +280,9 @@ public class FileMount implements IWritableMount
} }
} }
@Nonnull
@Override @Override
public OutputStream openForWrite( String path ) throws IOException public OutputStream openForWrite( @Nonnull String path ) throws IOException
{ {
create(); create();
File file = getRealPath( path ); File file = getRealPath( path );
@ -309,8 +312,9 @@ public class FileMount implements IWritableMount
} }
} }
@Nonnull
@Override @Override
public OutputStream openForAppend( String path ) throws IOException public OutputStream openForAppend( @Nonnull String path ) throws IOException
{ {
if( created() ) if( created() )
{ {

View File

@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -178,14 +179,14 @@ public class JarMount implements IMount
// IMount implementation // IMount implementation
@Override @Override
public boolean exists( String path ) throws IOException public boolean exists( @Nonnull String path ) throws IOException
{ {
FileInZip file = m_root.getFile( path ); FileInZip file = m_root.getFile( path );
return file != null; return file != null;
} }
@Override @Override
public boolean isDirectory( String path ) throws IOException public boolean isDirectory( @Nonnull String path ) throws IOException
{ {
FileInZip file = m_root.getFile( path ); FileInZip file = m_root.getFile( path );
if( file != null ) if( file != null )
@ -196,7 +197,7 @@ public class JarMount implements IMount
} }
@Override @Override
public void list( String path, List<String> contents ) throws IOException public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
{ {
FileInZip file = m_root.getFile( path ); FileInZip file = m_root.getFile( path );
if( file != null && file.isDirectory() ) if( file != null && file.isDirectory() )
@ -210,7 +211,7 @@ public class JarMount implements IMount
} }
@Override @Override
public long getSize( String path ) throws IOException public long getSize( @Nonnull String path ) throws IOException
{ {
FileInZip file = m_root.getFile( path ); FileInZip file = m_root.getFile( path );
if( file != null ) if( file != null )
@ -220,8 +221,9 @@ public class JarMount implements IMount
throw new IOException( "No such file" ); throw new IOException( "No such file" );
} }
@Nonnull
@Override @Override
public InputStream openForRead( String path ) throws IOException public InputStream openForRead( @Nonnull String path ) throws IOException
{ {
FileInZip file = m_root.getFile( path ); FileInZip file = m_root.getFile( path );
if( file != null && !file.isDirectory() ) if( file != null && !file.isDirectory() )

View File

@ -8,6 +8,7 @@ package dan200.computercraft.core.filesystem;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -26,31 +27,32 @@ public class SubMount implements IMount
// IMount implementation // IMount implementation
@Override @Override
public boolean exists( String path ) throws IOException public boolean exists( @Nonnull String path ) throws IOException
{ {
return m_parent.exists( getFullPath( path ) ); return m_parent.exists( getFullPath( path ) );
} }
@Override @Override
public boolean isDirectory( String path ) throws IOException public boolean isDirectory( @Nonnull String path ) throws IOException
{ {
return m_parent.isDirectory( getFullPath( path ) ); return m_parent.isDirectory( getFullPath( path ) );
} }
@Override @Override
public void list( String path, List<String> contents ) throws IOException public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
{ {
m_parent.list( getFullPath( path ), contents ); m_parent.list( getFullPath( path ), contents );
} }
@Override @Override
public long getSize( String path ) throws IOException public long getSize( @Nonnull String path ) throws IOException
{ {
return m_parent.getSize( getFullPath( path ) ); return m_parent.getSize( getFullPath( path ) );
} }
@Nonnull
@Override @Override
public InputStream openForRead( String path ) throws IOException public InputStream openForRead( @Nonnull String path ) throws IOException
{ {
return m_parent.openForRead( getFullPath( path ) ); return m_parent.openForRead( getFullPath( path ) );
} }

View File

@ -21,6 +21,7 @@ import org.luaj.vm2.lib.VarArgFunction;
import org.luaj.vm2.lib.ZeroArgFunction; import org.luaj.vm2.lib.ZeroArgFunction;
import org.luaj.vm2.lib.jse.JsePlatform; import org.luaj.vm2.lib.jse.JsePlatform;
import javax.annotation.Nonnull;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
@ -339,6 +340,7 @@ public class LuaJLuaMachine implements ILuaMachine
try try
{ {
results = apiObject.callMethod( new ILuaContext() { results = apiObject.callMethod( new ILuaContext() {
@Nonnull
@Override @Override
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException public Object[] pullEvent( String filter ) throws LuaException, InterruptedException
{ {
@ -350,12 +352,14 @@ public class LuaJLuaMachine implements ILuaMachine
return results; return results;
} }
@Nonnull
@Override @Override
public Object[] pullEventRaw( String filter ) throws InterruptedException public Object[] pullEventRaw( String filter ) throws InterruptedException
{ {
return yield( new Object[] { filter } ); return yield( new Object[] { filter } );
} }
@Nonnull
@Override @Override
public Object[] yield( Object[] yieldArgs ) throws InterruptedException public Object[] yield( Object[] yieldArgs ) throws InterruptedException
{ {
@ -372,7 +376,7 @@ public class LuaJLuaMachine implements ILuaMachine
} }
@Override @Override
public long issueMainThreadTask( final ILuaTask task ) throws LuaException public long issueMainThreadTask( @Nonnull final ILuaTask task ) throws LuaException
{ {
// Issue command // Issue command
final long taskID = MainThread.getUniqueTaskID(); final long taskID = MainThread.getUniqueTaskID();
@ -431,7 +435,7 @@ public class LuaJLuaMachine implements ILuaMachine
} }
@Override @Override
public Object[] executeMainThreadTask( final ILuaTask task ) throws LuaException, InterruptedException public Object[] executeMainThreadTask( @Nonnull final ILuaTask task ) throws LuaException, InterruptedException
{ {
// Issue task // Issue task
final long taskID = issueMainThreadTask( task ); final long taskID = issueMainThreadTask( task );

View File

@ -25,6 +25,7 @@ import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -43,12 +44,13 @@ public abstract class BlockGeneric extends Block implements
protected abstract TileGeneric createTile( int damage ); protected abstract TileGeneric createTile( int damage );
@Override @Override
public final void dropBlockAsItemWithChance( World world, BlockPos pos, IBlockState state, float chance, int fortune ) public final void dropBlockAsItemWithChance( World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, float chance, int fortune )
{ {
} }
@Nonnull
@Override @Override
public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, IBlockState state, int fortune ) public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune )
{ {
ArrayList<ItemStack> drops = new ArrayList<ItemStack>( 1 ); ArrayList<ItemStack> drops = new ArrayList<ItemStack>( 1 );
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
@ -60,6 +62,7 @@ public abstract class BlockGeneric extends Block implements
return drops; return drops;
} }
@Nonnull
@Override @Override
public final IBlockState onBlockPlaced( World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int damage, EntityLivingBase placer ) public final IBlockState onBlockPlaced( World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int damage, EntityLivingBase placer )
{ {
@ -67,7 +70,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
public final boolean removedByPlayer( IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest ) public final boolean removedByPlayer( @Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest )
{ {
if( !world.isRemote ) if( !world.isRemote )
{ {
@ -109,7 +112,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
public final void breakBlock( World world, BlockPos pos, IBlockState newState ) public final void breakBlock( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric ) if( tile != null && tile instanceof TileGeneric )
@ -121,8 +124,9 @@ public abstract class BlockGeneric extends Block implements
world.removeTileEntity( pos ); world.removeTileEntity( pos );
} }
@Nonnull
@Override @Override
public final ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player ) public final ItemStack getPickBlock( @Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric ) if( tile != null && tile instanceof TileGeneric )
@ -134,7 +138,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
protected final ItemStack createStackedBlock( IBlockState state ) protected final ItemStack createStackedBlock( @Nonnull IBlockState state )
{ {
return null; return null;
} }
@ -174,7 +178,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
public final boolean isSideSolid( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side ) public final boolean isSideSolid( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric ) if( tile != null && tile instanceof TileGeneric )
@ -192,7 +196,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
public float getExplosionResistance( World world, BlockPos pos, Entity exploder, Explosion explosion ) public float getExplosionResistance( World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
@ -206,6 +210,7 @@ public abstract class BlockGeneric extends Block implements
return super.getExplosionResistance( exploder ); return super.getExplosionResistance( exploder );
} }
@Nonnull
@Override @Override
public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos ) public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos )
{ {
@ -218,14 +223,15 @@ public abstract class BlockGeneric extends Block implements
return FULL_BLOCK_AABB; return FULL_BLOCK_AABB;
} }
@Nonnull
@Override @Override
public AxisAlignedBB getSelectedBoundingBox( IBlockState state, World worldIn, BlockPos pos ) public final AxisAlignedBB getSelectedBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos )
{ {
return getBoundingBox( state, worldIn, pos ).offset( pos ); return getBoundingBox( state, world, pos ).offset( pos );
} }
@Override @Override
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos ) public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
@ -252,7 +258,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
public final void addCollisionBoxToList( IBlockState state, World world, BlockPos pos, AxisAlignedBB bigBox, List<AxisAlignedBB> list, Entity entity ) public final void addCollisionBoxToList( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB bigBox, @Nonnull List<AxisAlignedBB> list, Entity entity )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() )
@ -349,14 +355,16 @@ public abstract class BlockGeneric extends Block implements
return true; return true;
} }
@Nonnull
@Override @Override
public final TileEntity createTileEntity( World world, IBlockState state ) public final TileEntity createTileEntity( @Nonnull World world, @Nonnull IBlockState state )
{ {
return createTile( state ); return createTile( state );
} }
@Nonnull
@Override @Override
public final TileEntity createNewTileEntity( World world, int damage ) public final TileEntity createNewTileEntity( @Nonnull World world, int damage )
{ {
return createTile( damage ); return createTile( damage );
} }

View File

@ -12,6 +12,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
{ {
public DefaultBundledRedstoneProvider() public DefaultBundledRedstoneProvider()
@ -19,7 +21,7 @@ public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
} }
@Override @Override
public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
{ {
return getDefaultBundledRedstoneOutput( world, pos, side ); return getDefaultBundledRedstoneOutput( world, pos, side );
} }

View File

@ -23,6 +23,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public abstract class TileGeneric extends TileEntity public abstract class TileGeneric extends TileEntity
@ -48,6 +50,7 @@ public abstract class TileGeneric extends TileEntity
{ {
} }
@Nullable
public BlockGeneric getBlock() public BlockGeneric getBlock()
{ {
Block block = worldObj.getBlockState( getPos() ).getBlock(); Block block = worldObj.getBlockState( getPos() ).getBlock();
@ -77,7 +80,7 @@ public abstract class TileGeneric extends TileEntity
worldObj.setBlockState( getPos(), newState, 3 ); worldObj.setBlockState( getPos(), newState, 3 );
} }
public void getDroppedItems( List<ItemStack> drops, boolean creative ) public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
{ {
} }
@ -95,7 +98,7 @@ public abstract class TileGeneric extends TileEntity
{ {
} }
public void onNeighbourTileEntityChange( BlockPos neighbour ) public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
{ {
} }
@ -109,12 +112,13 @@ public abstract class TileGeneric extends TileEntity
return false; return false;
} }
@Nonnull
public AxisAlignedBB getBounds() public AxisAlignedBB getBounds()
{ {
return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ); return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
} }
public void getCollisionBounds( List<AxisAlignedBB> bounds ) public void getCollisionBounds( @Nonnull List<AxisAlignedBB> bounds )
{ {
bounds.add( getBounds() ); bounds.add( getBounds() );
} }
@ -129,12 +133,12 @@ public abstract class TileGeneric extends TileEntity
return 0; return 0;
} }
public boolean getBundledRedstoneConnectivity( EnumFacing side ) public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side )
{ {
return false; return false;
} }
public int getBundledRedstoneOutput( EnumFacing side ) public int getBundledRedstoneOutput( @Nonnull EnumFacing side )
{ {
return 0; return 0;
} }
@ -163,11 +167,11 @@ public abstract class TileGeneric extends TileEntity
return false; return false;
} }
protected void writeDescription( NBTTagCompound nbttagcompound ) protected void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
} }
protected void readDescription( NBTTagCompound nbttagcompound ) protected void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
} }
@ -186,7 +190,7 @@ public abstract class TileGeneric extends TileEntity
} }
@Override @Override
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState ) public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{ {
return newState.getBlock() != oldState.getBlock(); return newState.getBlock() != oldState.getBlock();
} }
@ -215,6 +219,7 @@ public abstract class TileGeneric extends TileEntity
} }
} }
@Nonnull
@Override @Override
public NBTTagCompound getUpdateTag () public NBTTagCompound getUpdateTag ()
{ {
@ -224,7 +229,7 @@ public abstract class TileGeneric extends TileEntity
} }
@Override @Override
public void handleUpdateTag (NBTTagCompound tag) public void handleUpdateTag ( @Nonnull NBTTagCompound tag)
{ {
super.handleUpdateTag(tag); super.handleUpdateTag(tag);
readDescription( tag ); readDescription( tag );

View File

@ -24,6 +24,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -61,6 +62,7 @@ public class CommandAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -139,7 +141,7 @@ public class CommandAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {

View File

@ -25,6 +25,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockCommandComputer extends BlockComputerBase public class BlockCommandComputer extends BlockComputerBase
{ {
// Statics // Statics
@ -50,6 +52,7 @@ public class BlockCommandComputer extends BlockComputerBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
@ -59,6 +62,7 @@ public class BlockCommandComputer extends BlockComputerBase
}); });
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -76,8 +80,9 @@ public class BlockCommandComputer extends BlockComputerBase
return ((EnumFacing)state.getValue( Properties.FACING )).getIndex(); return ((EnumFacing)state.getValue( Properties.FACING )).getIndex();
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof IComputerTile ) if( tile != null && tile instanceof IComputerTile )

View File

@ -27,6 +27,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockComputer extends BlockComputerBase public class BlockComputer extends BlockComputerBase
{ {
// Statics // Statics
@ -52,6 +54,7 @@ public class BlockComputer extends BlockComputerBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
@ -62,6 +65,7 @@ public class BlockComputer extends BlockComputerBase
}); });
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -117,8 +121,9 @@ public class BlockComputer extends BlockComputerBase
} }
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof IComputerTile ) if( tile != null && tile instanceof IComputerTile )

View File

@ -12,6 +12,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import javax.annotation.Nonnull;
public class ComputerPeripheral public class ComputerPeripheral
implements IPeripheral implements IPeripheral
{ {
@ -26,12 +28,14 @@ public class ComputerPeripheral
// IPeripheral implementation // IPeripheral implementation
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return m_type; return m_type;
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -45,7 +49,7 @@ public class ComputerPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -87,12 +91,12 @@ public class ComputerPeripheral
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
} }
@Override @Override
public void detach( IComputerAccess computer ) public void detach( @Nonnull IComputerAccess computer )
{ {
} }

View File

@ -8,6 +8,8 @@ package dan200.computercraft.shared.computer.blocks;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import javax.annotation.Nonnull;
public enum ComputerState implements IStringSerializable public enum ComputerState implements IStringSerializable
{ {
Off( "off" ), Off( "off" ),
@ -21,6 +23,7 @@ public enum ComputerState implements IStringSerializable
m_name = name; m_name = name;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {

View File

@ -21,6 +21,7 @@ import net.minecraft.util.text.*;
import net.minecraft.util.*; import net.minecraft.util.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -53,6 +54,7 @@ public class TileCommandComputer extends TileComputer
// ICommandSender // ICommandSender
@Nonnull
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName()
{ {
@ -69,7 +71,7 @@ public class TileCommandComputer extends TileComputer
} }
@Override @Override
public void addChatMessage( ITextComponent chatComponent ) public void addChatMessage( @Nonnull ITextComponent chatComponent )
{ {
m_outputTable.put( m_outputTable.size() + 1, chatComponent.getUnformattedText() ); m_outputTable.put( m_outputTable.size() + 1, chatComponent.getUnformattedText() );
} }
@ -80,12 +82,14 @@ public class TileCommandComputer extends TileComputer
return level <= 2; return level <= 2;
} }
@Nonnull
@Override @Override
public BlockPos getPosition() public BlockPos getPosition()
{ {
return TileCommandComputer.this.getPos(); return TileCommandComputer.this.getPos();
} }
@Nonnull
@Override @Override
public Vec3d getPositionVector() public Vec3d getPositionVector()
{ {
@ -93,6 +97,7 @@ public class TileCommandComputer extends TileComputer
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
} }
@Nonnull
@Override @Override
public World getEntityWorld() public World getEntityWorld()
{ {
@ -126,7 +131,7 @@ public class TileCommandComputer extends TileComputer
} }
@Override @Override
public void fillInInfo( ByteBuf buf ) public void fillInInfo( @Nonnull ByteBuf buf )
{ {
} }
} }

View File

@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class TileComputer extends TileComputerBase public class TileComputer extends TileComputerBase
@ -47,7 +48,7 @@ public class TileComputer extends TileComputerBase
} }
@Override @Override
public void getDroppedItems( List<ItemStack> drops, boolean creative ) public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
{ {
IComputer computer = getComputer(); IComputer computer = getComputer();
if( !creative || (computer != null && computer.getLabel() != null) ) if( !creative || (computer != null && computer.getLabel() != null) )
@ -69,7 +70,7 @@ public class TileComputer extends TileComputerBase
} }
@Override @Override
public final void readDescription( NBTTagCompound nbttagcompound ) public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
updateBlock(); updateBlock();

View File

@ -27,6 +27,8 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import javax.annotation.Nonnull;
public abstract class TileComputerBase extends TileGeneric public abstract class TileComputerBase extends TileGeneric
implements IComputerTile, IDirectionalTile, ITickable implements IComputerTile, IDirectionalTile, ITickable
{ {
@ -167,14 +169,14 @@ public abstract class TileComputerBase extends TileGeneric
} }
@Override @Override
public boolean getBundledRedstoneConnectivity( EnumFacing side ) public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side )
{ {
int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) ); int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) );
return !isRedstoneBlockedOnSide( localDir ); return !isRedstoneBlockedOnSide( localDir );
} }
@Override @Override
public int getBundledRedstoneOutput( EnumFacing side ) public int getBundledRedstoneOutput( @Nonnull EnumFacing side )
{ {
int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) ); int localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) );
if( !isRedstoneBlockedOnSide( localDir ) ) if( !isRedstoneBlockedOnSide( localDir ) )
@ -198,7 +200,7 @@ public abstract class TileComputerBase extends TileGeneric
} }
@Override @Override
public void onNeighbourTileEntityChange( BlockPos neighbour ) public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
{ {
updateInput( neighbour ); updateInput( neighbour );
} }
@ -239,6 +241,7 @@ public abstract class TileComputerBase extends TileGeneric
} }
} }
@Nonnull
@Override @Override
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound ) public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
{ {
@ -517,14 +520,14 @@ public abstract class TileComputerBase extends TileGeneric
// Networking stuff // Networking stuff
@Override @Override
public void writeDescription( NBTTagCompound nbttagcompound ) public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.writeDescription( nbttagcompound ); super.writeDescription( nbttagcompound );
nbttagcompound.setInteger( "instanceID", createServerComputer().getInstanceID() ); nbttagcompound.setInteger( "instanceID", createServerComputer().getInstanceID() );
} }
@Override @Override
public void readDescription( NBTTagCompound nbttagcompound ) public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
m_instanceID = nbttagcompound.getInteger( "instanceID" ); m_instanceID = nbttagcompound.getInteger( "instanceID" );

View File

@ -12,6 +12,7 @@ import dan200.computercraft.shared.computer.core.IContainerComputer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class ContainerComputer extends Container public class ContainerComputer extends Container
@ -25,7 +26,7 @@ public class ContainerComputer extends Container
} }
@Override @Override
public boolean canInteractWith( EntityPlayer player ) public boolean canInteractWith( @Nonnull EntityPlayer player )
{ {
return m_computer.isUseableByPlayer( player ); return m_computer.isUseableByPlayer( player );
} }

View File

@ -14,6 +14,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemCommandComputer extends ItemComputer public class ItemCommandComputer extends ItemComputer
@ -51,7 +52,7 @@ public class ItemCommandComputer extends ItemComputer
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list )
{ {
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Command ) ); list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Command ) );
} }

View File

@ -21,6 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemComputer extends ItemComputerBase public class ItemComputer extends ItemComputerBase
@ -71,14 +72,14 @@ public class ItemComputer extends ItemComputerBase
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list )
{ {
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Normal ) ); list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Normal ) );
list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ) ); list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ) );
} }
@Override @Override
public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState ) public boolean placeBlockAt( @Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState newState )
{ {
if( super.placeBlockAt( stack, player, world, pos, side, hitX, hitY, hitZ, newState ) ) if( super.placeBlockAt( stack, player, world, pos, side, hitX, hitY, hitZ, newState ) )
{ {
@ -110,6 +111,7 @@ public class ItemComputer extends ItemComputerBase
} }
} }
@Nonnull
@Override @Override
public String getUnlocalizedName( ItemStack stack ) public String getUnlocalizedName( ItemStack stack )
{ {

View File

@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public abstract class ItemComputerBase extends ItemBlock implements IComputerItem, IMedia public abstract class ItemComputerBase extends ItemBlock implements IComputerItem, IMedia
@ -36,7 +37,7 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
} }
@Override @Override
public void addInformation( ItemStack stack, EntityPlayer player, List list, boolean debug ) public void addInformation( @Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull List list, boolean debug )
{ {
if( debug ) if( debug )
{ {
@ -54,7 +55,7 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
public abstract int getComputerID( ItemStack stack ); public abstract int getComputerID( ItemStack stack );
@Override @Override
public String getLabel( ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
if( stack.hasDisplayName() ) if( stack.hasDisplayName() )
{ {
@ -73,7 +74,7 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
// IMedia implementation // IMedia implementation
@Override @Override
public boolean setLabel( ItemStack stack, String label ) public boolean setLabel( @Nonnull ItemStack stack, String label )
{ {
if( label != null ) if( label != null )
{ {
@ -87,19 +88,19 @@ public abstract class ItemComputerBase extends ItemBlock implements IComputerIte
} }
@Override @Override
public String getAudioTitle( ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public SoundEvent getAudio( ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public IMount createDataMount( ItemStack stack, World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
ComputerFamily family = getFamily( stack ); ComputerFamily family = getFamily( stack );
if( family != ComputerFamily.Command ) if( family != ComputerFamily.Command )

View File

@ -7,6 +7,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord; import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class DefaultMediaProvider implements IMediaProvider public class DefaultMediaProvider implements IMediaProvider
{ {
public DefaultMediaProvider() public DefaultMediaProvider()
@ -14,7 +16,7 @@ public class DefaultMediaProvider implements IMediaProvider
} }
@Override @Override
public IMedia getMedia( ItemStack stack ) public IMedia getMedia( @Nonnull ItemStack stack )
{ {
Item item = stack.getItem(); Item item = stack.getItem();
if( item instanceof IMedia ) if( item instanceof IMedia )

View File

@ -12,6 +12,8 @@ import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
public class ContainerHeldItem extends Container public class ContainerHeldItem extends Container
{ {
private final ItemStack m_stack; private final ItemStack m_stack;
@ -29,7 +31,7 @@ public class ContainerHeldItem extends Container
} }
@Override @Override
public boolean canInteractWith( EntityPlayer player ) public boolean canInteractWith( @Nonnull EntityPlayer player )
{ {
if( player != null && player.isEntityAlive() ) if( player != null && player.isEntityAlive() )
{ {

View File

@ -20,6 +20,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemDiskLegacy extends Item public class ItemDiskLegacy extends Item
@ -34,7 +35,7 @@ public class ItemDiskLegacy extends Item
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, List list )
{ {
for( int colour=0; colour<16; ++colour ) for( int colour=0; colour<16; ++colour )
{ {
@ -94,7 +95,7 @@ public class ItemDiskLegacy extends Item
// IMedia implementation // IMedia implementation
@Override @Override
public String getLabel( ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
if( stack.hasDisplayName() ) if( stack.hasDisplayName() )
{ {
@ -104,7 +105,7 @@ public class ItemDiskLegacy extends Item
} }
@Override @Override
public boolean setLabel( ItemStack stack, String label ) public boolean setLabel( @Nonnull ItemStack stack, String label )
{ {
if( label != null ) if( label != null )
{ {
@ -118,19 +119,19 @@ public class ItemDiskLegacy extends Item
} }
@Override @Override
public String getAudioTitle( ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public SoundEvent getAudio( ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public IMount createDataMount( ItemStack stack, World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
int diskID = getDiskID( stack ); int diskID = getDiskID( stack );
if( diskID < 0 ) if( diskID < 0 )

View File

@ -17,6 +17,7 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemPrintout extends Item public class ItemPrintout extends Item
@ -41,7 +42,7 @@ public class ItemPrintout extends Item
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, List list )
{ {
list.add( createSingleFromTitleAndText( null, new String[ LINES_PER_PAGE ], new String[ LINES_PER_PAGE ] ) ); list.add( createSingleFromTitleAndText( null, new String[ LINES_PER_PAGE ], new String[ LINES_PER_PAGE ] ) );
list.add( createMultipleFromTitleAndText( null, new String[ 2*LINES_PER_PAGE ], new String[ 2*LINES_PER_PAGE ] ) ); list.add( createMultipleFromTitleAndText( null, new String[ 2*LINES_PER_PAGE ], new String[ 2*LINES_PER_PAGE ] ) );
@ -58,6 +59,7 @@ public class ItemPrintout extends Item
} }
} }
@Nonnull
@Override @Override
public String getUnlocalizedName( ItemStack stack ) public String getUnlocalizedName( ItemStack stack )
{ {
@ -80,8 +82,9 @@ public class ItemPrintout extends Item
} }
} }
@Nonnull
@Override @Override
public ActionResult<ItemStack> onItemRightClick( ItemStack stack, World world, EntityPlayer player, EnumHand hand ) public ActionResult<ItemStack> onItemRightClick( @Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand )
{ {
if( !world.isRemote ) if( !world.isRemote )
{ {

View File

@ -21,6 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -38,7 +39,7 @@ public class ItemTreasureDisk extends Item
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, List list )
{ {
} }
@ -61,31 +62,31 @@ public class ItemTreasureDisk extends Item
// IMedia implementation // IMedia implementation
@Override @Override
public String getLabel( ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
return getTitle( stack ); return getTitle( stack );
} }
@Override @Override
public boolean setLabel( ItemStack stack, String label ) public boolean setLabel( @Nonnull ItemStack stack, String label )
{ {
return false; return false;
} }
@Override @Override
public String getAudioTitle( ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public SoundEvent getAudio( ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public IMount createDataMount( ItemStack stack, World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
IMount rootTreasure = getTreasureMount(); IMount rootTreasure = getTreasureMount();
String subPath = getSubPath( stack ); String subPath = getSubPath( stack );

View File

@ -15,6 +15,8 @@ import net.minecraft.util.SoundEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import javax.annotation.Nonnull;
// An implementation of IMedia for ItemRecord's // An implementation of IMedia for ItemRecord's
public class RecordMedia implements IMedia public class RecordMedia implements IMedia
{ {
@ -23,32 +25,32 @@ public class RecordMedia implements IMedia
} }
@Override @Override
public String getLabel( ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
return getAudioTitle( stack ); return getAudioTitle( stack );
} }
@Override @Override
public boolean setLabel( ItemStack stack, String label ) public boolean setLabel( @Nonnull ItemStack stack, String label )
{ {
return false; return false;
} }
@Override @Override
public String getAudioTitle( ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
return ComputerCraft.getRecordInfo( stack ); return ComputerCraft.getRecordInfo( stack );
} }
@Override @Override
public SoundEvent getAudio( ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
ItemRecord itemRecord = (ItemRecord)stack.getItem(); ItemRecord itemRecord = (ItemRecord)stack.getItem();
return ObfuscationReflectionHelper.getPrivateValue(ItemRecord.class, itemRecord, "field_185076_b"); return ObfuscationReflectionHelper.getPrivateValue(ItemRecord.class, itemRecord, "field_185076_b");
} }
@Override @Override
public IMount createDataMount( ItemStack stack, World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
return null; return null;
} }

View File

@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class DiskRecipe implements IRecipe public class DiskRecipe implements IRecipe
{ {
public DiskRecipe() public DiskRecipe()
@ -21,7 +23,7 @@ public class DiskRecipe implements IRecipe
} }
@Override @Override
public boolean matches( InventoryCrafting inventory, World world ) public boolean matches( @Nonnull InventoryCrafting inventory, @Nonnull World world )
{ {
boolean diskFound = false; boolean diskFound = false;
boolean paperFound = false; boolean paperFound = false;
@ -75,7 +77,7 @@ public class DiskRecipe implements IRecipe
} }
@Override @Override
public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) public ItemStack getCraftingResult( @Nonnull InventoryCrafting par1InventoryCrafting)
{ {
int diskID = -1; int diskID = -1;
String diskLabel = null; String diskLabel = null;
@ -153,8 +155,9 @@ public class DiskRecipe implements IRecipe
return ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() ); return ItemDiskLegacy.createFromIDAndColour( -1, null, Colour.Blue.getHex() );
} }
@Nonnull
@Override @Override
public ItemStack[] getRemainingItems( InventoryCrafting inventoryCrafting ) public ItemStack[] getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
{ {
ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ]; ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ];
for (int i = 0; i < results.length; ++i) for (int i = 0; i < results.length; ++i)

View File

@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class PrintoutRecipe implements IRecipe public class PrintoutRecipe implements IRecipe
{ {
public PrintoutRecipe( ) public PrintoutRecipe( )
@ -33,13 +35,13 @@ public class PrintoutRecipe implements IRecipe
} }
@Override @Override
public boolean matches( InventoryCrafting _inventory, World world ) public boolean matches( @Nonnull InventoryCrafting _inventory, @Nonnull World world )
{ {
return (getCraftingResult( _inventory ) != null); return (getCraftingResult( _inventory ) != null);
} }
@Override @Override
public ItemStack getCraftingResult( InventoryCrafting inventory ) public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
{ {
// See if we match the recipe, and extract the input disk ID and dye colour // See if we match the recipe, and extract the input disk ID and dye colour
int numPages = 0; int numPages = 0;
@ -146,8 +148,9 @@ public class PrintoutRecipe implements IRecipe
return null; return null;
} }
@Nonnull
@Override @Override
public ItemStack[] getRemainingItems( InventoryCrafting inventoryCrafting ) public ItemStack[] getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
{ {
ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ]; ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ];
for (int i = 0; i < results.length; ++i) for (int i = 0; i < results.length; ++i)

View File

@ -8,6 +8,8 @@ package dan200.computercraft.shared.peripheral;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import javax.annotation.Nonnull;
public enum PeripheralType implements IStringSerializable public enum PeripheralType implements IStringSerializable
{ {
DiskDrive( "disk_drive" ), DiskDrive( "disk_drive" ),
@ -27,6 +29,7 @@ public enum PeripheralType implements IStringSerializable
m_name = name; m_name = name;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {

View File

@ -14,6 +14,8 @@ import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.tileentity.TileEntityCommandBlock; import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import javax.annotation.Nonnull;
public class CommandBlockPeripheral implements IPeripheral public class CommandBlockPeripheral implements IPeripheral
{ {
private final TileEntityCommandBlock m_commandBlock; private final TileEntityCommandBlock m_commandBlock;
@ -25,12 +27,14 @@ public class CommandBlockPeripheral implements IPeripheral
// IPeripheral methods // IPeripheral methods
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return "command"; return "command";
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -42,7 +46,7 @@ public class CommandBlockPeripheral implements IPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, final Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull final Object[] arguments ) throws LuaException, InterruptedException
{ {
switch (method) switch (method)
{ {
@ -108,12 +112,12 @@ public class CommandBlockPeripheral implements IPeripheral
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
} }
@Override @Override
public void detach( IComputerAccess computer ) public void detach( @Nonnull IComputerAccess computer )
{ {
} }

View File

@ -14,10 +14,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class CommandBlockPeripheralProvider implements IPeripheralProvider public class CommandBlockPeripheralProvider implements IPeripheralProvider
{ {
@Override @Override
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side ) public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileEntityCommandBlock ) if( tile != null && tile instanceof TileEntityCommandBlock )

View File

@ -21,6 +21,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import javax.annotation.Nonnull;
public class BlockCable extends BlockPeripheralBase public class BlockCable extends BlockPeripheralBase
{ {
// Statics // Statics
@ -73,6 +75,7 @@ public class BlockCable extends BlockPeripheralBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
@ -88,6 +91,7 @@ public class BlockCable extends BlockPeripheralBase
}); });
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -174,8 +178,9 @@ public class BlockCable extends BlockPeripheralBase
} }
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
state = state.withProperty( Properties.NORTH, doesConnect( state, world, pos, EnumFacing.NORTH ) ); state = state.withProperty( Properties.NORTH, doesConnect( state, world, pos, EnumFacing.NORTH ) );
state = state.withProperty( Properties.SOUTH, doesConnect( state, world, pos, EnumFacing.SOUTH ) ); state = state.withProperty( Properties.SOUTH, doesConnect( state, world, pos, EnumFacing.SOUTH ) );
@ -209,7 +214,7 @@ public class BlockCable extends BlockPeripheralBase
} }
@Override @Override
public boolean shouldSideBeRendered( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side ) public boolean shouldSideBeRendered( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
{ {
return true; return true;
} }

View File

@ -9,6 +9,8 @@ package dan200.computercraft.shared.peripheral.common;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import javax.annotation.Nonnull;
public enum BlockCableModemVariant implements IStringSerializable public enum BlockCableModemVariant implements IStringSerializable
{ {
None( "none", null ), None( "none", null ),
@ -60,6 +62,7 @@ public enum BlockCableModemVariant implements IStringSerializable
m_facing = facing; m_facing = facing;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {

View File

@ -30,6 +30,8 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
public class BlockPeripheral extends BlockPeripheralBase public class BlockPeripheral extends BlockPeripheralBase
{ {
public static class Properties public static class Properties
@ -49,12 +51,14 @@ public class BlockPeripheral extends BlockPeripheralBase
); );
} }
@Nonnull
@SideOnly( Side.CLIENT) @SideOnly( Side.CLIENT)
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer()
{ {
return BlockRenderLayer.CUTOUT; return BlockRenderLayer.CUTOUT;
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
@ -64,6 +68,7 @@ public class BlockPeripheral extends BlockPeripheralBase
}); });
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -166,8 +171,9 @@ public class BlockPeripheral extends BlockPeripheralBase
return meta; return meta;
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
int anim; int anim;
EnumFacing dir; EnumFacing dir;

View File

@ -17,6 +17,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public abstract class BlockPeripheralBase extends BlockDirectional public abstract class BlockPeripheralBase extends BlockDirectional
{ {
public BlockPeripheralBase() public BlockPeripheralBase()
@ -42,7 +44,7 @@ public abstract class BlockPeripheralBase extends BlockDirectional
} }
@Override @Override
public final boolean canPlaceBlockOnSide( World world, BlockPos pos, EnumFacing side ) public final boolean canPlaceBlockOnSide( @Nonnull World world, @Nonnull BlockPos pos, EnumFacing side )
{ {
return true; // ItemPeripheralBase handles this return true; // ItemPeripheralBase handles this
} }

View File

@ -9,6 +9,8 @@ package dan200.computercraft.shared.peripheral.common;
import dan200.computercraft.shared.peripheral.PeripheralType; import dan200.computercraft.shared.peripheral.PeripheralType;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import javax.annotation.Nonnull;
public enum BlockPeripheralVariant implements IStringSerializable public enum BlockPeripheralVariant implements IStringSerializable
{ {
DiskDriveEmpty( "disk_drive_empty", PeripheralType.DiskDrive ), DiskDriveEmpty( "disk_drive_empty", PeripheralType.DiskDrive ),
@ -130,6 +132,7 @@ public enum BlockPeripheralVariant implements IStringSerializable
m_peripheralType = peripheralType; m_peripheralType = peripheralType;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {

View File

@ -16,6 +16,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class DefaultPeripheralProvider implements IPeripheralProvider public class DefaultPeripheralProvider implements IPeripheralProvider
{ {
public DefaultPeripheralProvider() public DefaultPeripheralProvider()
@ -23,7 +25,7 @@ public class DefaultPeripheralProvider implements IPeripheralProvider
} }
@Override @Override
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side ) public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
if( tile != null ) if( tile != null )

View File

@ -13,6 +13,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemAdvancedModem extends ItemPeripheralBase public class ItemAdvancedModem extends ItemPeripheralBase
@ -48,7 +49,7 @@ public class ItemAdvancedModem extends ItemPeripheralBase
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list )
{ {
list.add( PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) );
} }

View File

@ -24,6 +24,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemCable extends ItemPeripheralBase public class ItemCable extends ItemPeripheralBase
@ -63,14 +64,15 @@ public class ItemCable extends ItemPeripheralBase
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list )
{ {
list.add( PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 ) );
list.add( PeripheralItemFactory.create( PeripheralType.Cable, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.Cable, null, 1 ) );
} }
@Nonnull
@Override @Override
public EnumActionResult onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float fx, float fy, float fz ) public EnumActionResult onItemUse( ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumHand hand, @Nonnull EnumFacing side, float fx, float fy, float fz )
{ {
if( !canPlaceBlockOnSide( world, pos, side, player, stack ) ) if( !canPlaceBlockOnSide( world, pos, side, player, stack ) )
{ {

View File

@ -13,6 +13,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemPeripheral extends ItemPeripheralBase public class ItemPeripheral extends ItemPeripheralBase
@ -68,7 +69,7 @@ public class ItemPeripheral extends ItemPeripheralBase
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List list ) public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list )
{ {
list.add( PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 ) );
list.add( PeripheralItemFactory.create( PeripheralType.Printer, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.Printer, null, 1 ) );

View File

@ -15,6 +15,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public abstract class ItemPeripheralBase extends ItemBlock implements IPeripheralItem public abstract class ItemPeripheralBase extends ItemBlock implements IPeripheralItem
{ {
protected ItemPeripheralBase( Block block ) protected ItemPeripheralBase( Block block )
@ -33,7 +35,7 @@ public abstract class ItemPeripheralBase extends ItemBlock implements IPeriphera
} }
@Override @Override
public boolean canPlaceBlockOnSide( World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack ) // canPlaceItemBlockOnSide public boolean canPlaceBlockOnSide( World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, EntityPlayer player, @Nonnull ItemStack stack ) // canPlaceItemBlockOnSide
{ {
PeripheralType type = getPeripheralType( stack ); PeripheralType type = getPeripheralType( stack );
switch( type ) switch( type )
@ -55,6 +57,7 @@ public abstract class ItemPeripheralBase extends ItemBlock implements IPeriphera
} }
} }
@Nonnull
@Override @Override
public String getUnlocalizedName( ItemStack stack ) public String getUnlocalizedName( ItemStack stack )
{ {

View File

@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public abstract class TilePeripheralBase extends TileGeneric public abstract class TilePeripheralBase extends TileGeneric
@ -45,7 +46,7 @@ public abstract class TilePeripheralBase extends TileGeneric
} }
@Override @Override
public void getDroppedItems( List<ItemStack> drops, boolean creative ) public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
{ {
if( !creative ) if( !creative )
{ {
@ -149,7 +150,8 @@ public abstract class TilePeripheralBase extends TileGeneric
} }
} }
@Override @Nonnull
@Override
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound ) public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
{ {
// Write properties // Write properties
@ -164,7 +166,7 @@ public abstract class TilePeripheralBase extends TileGeneric
} }
@Override @Override
public void readDescription( NBTTagCompound nbttagcompound ) public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
m_dir = EnumFacing.getFront( nbttagcompound.getInteger( "dir" ) ); m_dir = EnumFacing.getFront( nbttagcompound.getInteger( "dir" ) );
@ -180,7 +182,7 @@ public abstract class TilePeripheralBase extends TileGeneric
} }
@Override @Override
public void writeDescription( NBTTagCompound nbttagcompound ) public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.writeDescription( nbttagcompound ); super.writeDescription( nbttagcompound );
nbttagcompound.setInteger( "dir", m_dir.getIndex() ); nbttagcompound.setInteger( "dir", m_dir.getIndex() );

View File

@ -12,6 +12,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class ContainerDiskDrive extends Container public class ContainerDiskDrive extends Container
{ {
private final TileDiskDrive m_diskDrive; private final TileDiskDrive m_diskDrive;
@ -36,7 +38,7 @@ public class ContainerDiskDrive extends Container
} }
@Override @Override
public boolean canInteractWith( EntityPlayer player ) public boolean canInteractWith( @Nonnull EntityPlayer player )
{ {
return m_diskDrive.isUseableByPlayer( player ); return m_diskDrive.isUseableByPlayer( player );
} }

View File

@ -16,6 +16,8 @@ import dan200.computercraft.shared.util.StringUtil;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class DiskDrivePeripheral implements IPeripheral public class DiskDrivePeripheral implements IPeripheral
{ {
private final TileDiskDrive m_diskDrive; private final TileDiskDrive m_diskDrive;
@ -25,12 +27,14 @@ public class DiskDrivePeripheral implements IPeripheral
m_diskDrive = diskDrive; m_diskDrive = diskDrive;
} }
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return "drive"; return "drive";
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -50,7 +54,7 @@ public class DiskDrivePeripheral implements IPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -174,13 +178,13 @@ public class DiskDrivePeripheral implements IPeripheral
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
m_diskDrive.mount( computer ); m_diskDrive.mount( computer );
} }
@Override @Override
public void detach( IComputerAccess computer ) public void detach( @Nonnull IComputerAccess computer )
{ {
m_diskDrive.unmount( computer ); m_diskDrive.unmount( computer );
} }

View File

@ -29,6 +29,7 @@ import net.minecraft.util.math.*;
import net.minecraft.util.text.*; import net.minecraft.util.text.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -145,6 +146,7 @@ public class TileDiskDrive extends TilePeripheralBase
} }
} }
@Nonnull
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
{ {
@ -320,6 +322,7 @@ public class TileDiskDrive extends TilePeripheralBase
return getLabel() != null; return getLabel() != null;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {
@ -334,6 +337,7 @@ public class TileDiskDrive extends TilePeripheralBase
} }
} }
@Nonnull
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName()
{ {
@ -354,23 +358,23 @@ public class TileDiskDrive extends TilePeripheralBase
} }
@Override @Override
public void openInventory( EntityPlayer player ) public void openInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public void closeInventory( EntityPlayer player ) public void closeInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) public boolean isItemValidForSlot( int i, @Nonnull ItemStack itemstack)
{ {
return true; return true;
} }
@Override @Override
public boolean isUseableByPlayer( EntityPlayer player ) public boolean isUseableByPlayer( @Nonnull EntityPlayer player )
{ {
return isUsable( player, false ); return isUsable( player, false );
} }
@ -613,7 +617,7 @@ public class TileDiskDrive extends TilePeripheralBase
} }
@Override @Override
public final void readDescription( NBTTagCompound nbttagcompound ) public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
if( nbttagcompound.hasKey( "item" ) ) if( nbttagcompound.hasKey( "item" ) )
@ -628,7 +632,7 @@ public class TileDiskDrive extends TilePeripheralBase
} }
@Override @Override
public void writeDescription( NBTTagCompound nbttagcompound ) public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.writeDescription( nbttagcompound ); super.writeDescription( nbttagcompound );
if( m_diskStack != null ) if( m_diskStack != null )
@ -659,7 +663,7 @@ public class TileDiskDrive extends TilePeripheralBase
} }
@Override @Override
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState ) public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{ {
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.DiskDrive; return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.DiskDrive;
} }

View File

@ -23,6 +23,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockAdvancedModem extends BlockPeripheralBase public class BlockAdvancedModem extends BlockPeripheralBase
{ {
public static class Properties public static class Properties
@ -42,6 +44,7 @@ public class BlockAdvancedModem extends BlockPeripheralBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
@ -51,6 +54,7 @@ public class BlockAdvancedModem extends BlockPeripheralBase
}); });
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -63,12 +67,13 @@ public class BlockAdvancedModem extends BlockPeripheralBase
@Override @Override
public int getMetaFromState( IBlockState state ) public int getMetaFromState( IBlockState state )
{ {
EnumFacing dir = (EnumFacing) state.getValue( Properties.FACING ); EnumFacing dir = state.getValue( Properties.FACING );
return dir.getIndex(); return dir.getIndex();
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
int anim; int anim;
EnumFacing dir; EnumFacing dir;

View File

@ -13,6 +13,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -203,12 +204,14 @@ public abstract class ModemPeripheral
// IPeripheral implementation // IPeripheral implementation
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return "modem"; return "modem";
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -237,7 +240,7 @@ public abstract class ModemPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {
@ -366,7 +369,7 @@ public abstract class ModemPeripheral
} }
@Override @Override
public synchronized void attach( IComputerAccess computer ) public synchronized void attach( @Nonnull IComputerAccess computer )
{ {
m_computer = computer; m_computer = computer;
setNetwork( getNetwork() ); setNetwork( getNetwork() );
@ -374,7 +377,7 @@ public abstract class ModemPeripheral
} }
@Override @Override
public synchronized void detach( IComputerAccess computer ) public synchronized void detach( @Nonnull IComputerAccess computer )
{ {
if( m_network != null ) if( m_network != null )
{ {

View File

@ -31,6 +31,7 @@ import net.minecraft.util.math.*;
import net.minecraft.util.text.*; import net.minecraft.util.text.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -93,6 +94,7 @@ public class TileCable extends TileModemBase
return new Vec3d( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 ); return new Vec3d( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 );
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -117,7 +119,7 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
String[] methods = super.getMethodNames(); String[] methods = super.getMethodNames();
switch( method - methods.length ) switch( method - methods.length )
@ -186,7 +188,7 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
super.attach( computer ); super.attach( computer );
synchronized( m_entity.m_peripheralsByName ) synchronized( m_entity.m_peripheralsByName )
@ -205,7 +207,7 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public synchronized void detach( IComputerAccess computer ) public synchronized void detach( @Nonnull IComputerAccess computer )
{ {
synchronized( m_entity.m_peripheralsByName ) synchronized( m_entity.m_peripheralsByName )
{ {
@ -302,7 +304,7 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public void getDroppedItems( List<ItemStack> drops, boolean creative ) public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
{ {
if( !creative ) if( !creative )
{ {
@ -409,6 +411,7 @@ public class TileCable extends TileModemBase
return new AxisAlignedBB( xMin, yMin, zMin, xMax, yMax, zMax ); return new AxisAlignedBB( xMin, yMin, zMin, xMax, yMax, zMax );
} }
@Nonnull
@Override @Override
public AxisAlignedBB getBounds() public AxisAlignedBB getBounds()
{ {
@ -434,7 +437,7 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public void getCollisionBounds( List<AxisAlignedBB> bounds ) public void getCollisionBounds( @Nonnull List<AxisAlignedBB> bounds )
{ {
PeripheralType type = getPeripheralType(); PeripheralType type = getPeripheralType();
if( type == PeripheralType.WiredModem || type == PeripheralType.WiredModemWithCable ) if( type == PeripheralType.WiredModem || type == PeripheralType.WiredModemWithCable )
@ -503,7 +506,8 @@ public class TileCable extends TileModemBase
m_attachedPeripheralID = nbttagcompound.getInteger( "peripheralID" ); m_attachedPeripheralID = nbttagcompound.getInteger( "peripheralID" );
} }
@Override @Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
{ {
// Write properties // Write properties
@ -828,25 +832,25 @@ public class TileCable extends TileModemBase
// IComputerAccess implementation // IComputerAccess implementation
@Override @Override
public String mount( String desiredLocation, IMount mount ) public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount )
{ {
return m_computer.mount( desiredLocation, mount, m_name ); return m_computer.mount( desiredLocation, mount, m_name );
} }
@Override @Override
public String mount( String desiredLocation, IMount mount, String driveName ) public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount, @Nonnull String driveName )
{ {
return m_computer.mount( desiredLocation, mount, driveName ); return m_computer.mount( desiredLocation, mount, driveName );
} }
@Override @Override
public String mountWritable( String desiredLocation, IWritableMount mount ) public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount )
{ {
return m_computer.mountWritable( desiredLocation, mount, m_name ); return m_computer.mountWritable( desiredLocation, mount, m_name );
} }
@Override @Override
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName ) public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount, @Nonnull String driveName )
{ {
return m_computer.mountWritable( desiredLocation, mount, driveName ); return m_computer.mountWritable( desiredLocation, mount, driveName );
} }
@ -864,11 +868,12 @@ public class TileCable extends TileModemBase
} }
@Override @Override
public void queueEvent( String event, Object[] arguments ) public void queueEvent( @Nonnull String event, Object[] arguments )
{ {
m_computer.queueEvent( event, arguments ); m_computer.queueEvent( event, arguments );
} }
@Nonnull
@Override @Override
public String getAttachmentName() public String getAttachmentName()
{ {

View File

@ -14,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import javax.annotation.Nonnull;
public abstract class TileModemBase extends TilePeripheralBase public abstract class TileModemBase extends TilePeripheralBase
{ {
private static final AxisAlignedBB[] BOXES = new AxisAlignedBB[] { private static final AxisAlignedBB[] BOXES = new AxisAlignedBB[] {
@ -65,6 +67,7 @@ public abstract class TileModemBase extends TilePeripheralBase
} }
} }
@Nonnull
@Override @Override
public AxisAlignedBB getBounds() public AxisAlignedBB getBounds()
{ {
@ -95,7 +98,7 @@ public abstract class TileModemBase extends TilePeripheralBase
} }
@Override @Override
public final void readDescription( NBTTagCompound nbttagcompound ) public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
updateBlock(); updateBlock();

View File

@ -17,6 +17,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TileWirelessModem extends TileModemBase public class TileWirelessModem extends TileModemBase
{ {
// Statics // Statics
@ -120,7 +122,7 @@ public class TileWirelessModem extends TileModemBase
} }
@Override @Override
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState ) public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{ {
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.WirelessModem; return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.WirelessModem;
} }

View File

@ -12,6 +12,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import javax.annotation.Nonnull;
public class MonitorPeripheral implements IPeripheral public class MonitorPeripheral implements IPeripheral
{ {
private final TileMonitor m_monitor; private final TileMonitor m_monitor;
@ -23,12 +25,14 @@ public class MonitorPeripheral implements IPeripheral
// IPeripheral implementation // IPeripheral implementation
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return "monitor"; return "monitor";
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -57,7 +61,7 @@ public class MonitorPeripheral implements IPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object args[] ) throws LuaException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object args[] ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -223,13 +227,13 @@ public class MonitorPeripheral implements IPeripheral
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
m_monitor.addComputer( computer ); m_monitor.addComputer( computer );
} }
@Override @Override
public void detach( IComputerAccess computer ) public void detach( @Nonnull IComputerAccess computer )
{ {
m_monitor.removeComputer( computer ); m_monitor.removeComputer( computer );
} }

View File

@ -25,6 +25,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -111,6 +112,7 @@ public class TileMonitor extends TilePeripheralBase
return false; return false;
} }
@Nonnull
@Override @Override
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound ) public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
{ {
@ -206,7 +208,7 @@ public class TileMonitor extends TilePeripheralBase
// Networking stuff // Networking stuff
@Override @Override
public void writeDescription( NBTTagCompound nbttagcompound ) public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.writeDescription( nbttagcompound ); super.writeDescription( nbttagcompound );
nbttagcompound.setInteger( "xIndex", m_xIndex ); nbttagcompound.setInteger( "xIndex", m_xIndex );
@ -219,7 +221,7 @@ public class TileMonitor extends TilePeripheralBase
} }
@Override @Override
public final void readDescription( NBTTagCompound nbttagcompound ) public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
@ -815,6 +817,7 @@ public class TileMonitor extends TilePeripheralBase
} }
} }
@Nonnull
@Override @Override
public AxisAlignedBB getRenderBoundingBox() public AxisAlignedBB getRenderBoundingBox()
{ {
@ -840,7 +843,7 @@ public class TileMonitor extends TilePeripheralBase
} }
@Override @Override
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState ) public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{ {
if( super.shouldRefresh( world, pos, oldState, newState ) ) if( super.shouldRefresh( world, pos, oldState, newState ) )
{ {

View File

@ -14,6 +14,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class ContainerPrinter extends Container public class ContainerPrinter extends Container
{ {
private TilePrinter m_printer; private TilePrinter m_printer;
@ -97,7 +99,7 @@ public class ContainerPrinter extends Container
} }
@Override @Override
public boolean canInteractWith( EntityPlayer player ) public boolean canInteractWith( @Nonnull EntityPlayer player )
{ {
return m_printer.isUseableByPlayer( player ); return m_printer.isUseableByPlayer( player );
} }

View File

@ -12,6 +12,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import javax.annotation.Nonnull;
public class PrinterPeripheral implements IPeripheral public class PrinterPeripheral implements IPeripheral
{ {
private final TilePrinter m_printer; private final TilePrinter m_printer;
@ -21,12 +23,14 @@ public class PrinterPeripheral implements IPeripheral
m_printer = printer; m_printer = printer;
} }
@Nonnull
@Override @Override
public String getType() public String getType()
{ {
return "printer"; return "printer";
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -44,7 +48,7 @@ public class PrinterPeripheral implements IPeripheral
} }
@Override @Override
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] args ) throws LuaException public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
{ {
@ -139,12 +143,12 @@ public class PrinterPeripheral implements IPeripheral
} }
@Override @Override
public void attach( IComputerAccess computer ) public void attach( @Nonnull IComputerAccess computer )
{ {
} }
@Override @Override
public void detach( IComputerAccess computer ) public void detach( @Nonnull IComputerAccess computer )
{ {
} }

View File

@ -29,6 +29,8 @@ import net.minecraft.util.text.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
public class TilePrinter extends TilePeripheralBase public class TilePrinter extends TilePeripheralBase
implements IInventory, ISidedInventory implements IInventory, ISidedInventory
{ {
@ -102,7 +104,8 @@ public class TilePrinter extends TilePeripheralBase
} }
} }
@Override @Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
{ {
nbttagcompound = super.writeToNBT(nbttagcompound); nbttagcompound = super.writeToNBT(nbttagcompound);
@ -136,14 +139,14 @@ public class TilePrinter extends TilePeripheralBase
} }
@Override @Override
public final void readDescription( NBTTagCompound nbttagcompound ) public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
updateBlock(); updateBlock();
} }
@Override @Override
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState ) public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{ {
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.Printer; return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.Printer;
} }
@ -243,6 +246,7 @@ public class TilePrinter extends TilePeripheralBase
return getLabel() != null; return getLabel() != null;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {
@ -257,6 +261,7 @@ public class TilePrinter extends TilePeripheralBase
} }
} }
@Nonnull
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName()
{ {
@ -277,23 +282,23 @@ public class TilePrinter extends TilePeripheralBase
} }
@Override @Override
public void openInventory( EntityPlayer player ) public void openInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public void closeInventory( EntityPlayer player ) public void closeInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack itemstack ) public boolean isItemValidForSlot( int slot, @Nonnull ItemStack itemstack )
{ {
return true; return true;
} }
@Override @Override
public boolean isUseableByPlayer( EntityPlayer player ) public boolean isUseableByPlayer( @Nonnull EntityPlayer player )
{ {
return isUsable( player, false ); return isUsable( player, false );
} }
@ -317,8 +322,9 @@ public class TilePrinter extends TilePeripheralBase
// ISidedInventory implementation // ISidedInventory implementation
@Override @Nonnull
public int[] getSlotsForFace( EnumFacing side ) @Override
public int[] getSlotsForFace( @Nonnull EnumFacing side )
{ {
switch( side ) switch( side )
{ {
@ -329,13 +335,13 @@ public class TilePrinter extends TilePeripheralBase
} }
@Override @Override
public boolean canInsertItem( int slot, ItemStack itemstack, EnumFacing face ) public boolean canInsertItem( int slot, @Nonnull ItemStack itemstack, @Nonnull EnumFacing face )
{ {
return isItemValidForSlot( slot, itemstack ); return isItemValidForSlot( slot, itemstack );
} }
@Override @Override
public boolean canExtractItem( int slot, ItemStack itemstack, EnumFacing face ) public boolean canExtractItem( int slot, @Nonnull ItemStack itemstack, @Nonnull EnumFacing face )
{ {
return true; return true;
} }

View File

@ -19,6 +19,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class PocketAPI implements ILuaAPI public class PocketAPI implements ILuaAPI
{ {
private final PocketServerComputer m_computer; private final PocketServerComputer m_computer;
@ -51,6 +53,7 @@ public class PocketAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -61,7 +64,7 @@ public class PocketAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {

View File

@ -35,6 +35,7 @@ import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class ItemPocketComputer extends Item implements IComputerItem, IMedia public class ItemPocketComputer extends Item implements IComputerItem, IMedia
@ -79,7 +80,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
} }
@Override @Override
public void getSubItems( Item itemID, CreativeTabs tabs, List<ItemStack> list ) public void getSubItems( @Nonnull Item itemID, CreativeTabs tabs, List list )
{ {
getSubItems( list, ComputerFamily.Normal ); getSubItems( list, ComputerFamily.Normal );
getSubItems( list, ComputerFamily.Advanced ); getSubItems( list, ComputerFamily.Advanced );
@ -151,8 +152,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
} }
} }
@Nonnull
@Override @Override
public ActionResult<ItemStack> onItemRightClick( ItemStack stack, World world, EntityPlayer player, EnumHand hand ) public ActionResult<ItemStack> onItemRightClick( @Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand )
{ {
if( !world.isRemote ) if( !world.isRemote )
{ {
@ -176,6 +178,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, stack ); return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, stack );
} }
@Nonnull
@Override @Override
public String getUnlocalizedName( ItemStack stack ) public String getUnlocalizedName( ItemStack stack )
{ {
@ -193,8 +196,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
} }
} }
@Nonnull
@Override @Override
public String getItemStackDisplayName( ItemStack stack ) public String getItemStackDisplayName( @Nonnull ItemStack stack )
{ {
String baseString = getUnlocalizedName( stack ); String baseString = getUnlocalizedName( stack );
IPocketUpgrade upgrade = getUpgrade( stack ); IPocketUpgrade upgrade = getUpgrade( stack );
@ -331,7 +335,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
} }
@Override @Override
public String getLabel( ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
if( stack.hasDisplayName() ) if( stack.hasDisplayName() )
{ {
@ -361,7 +365,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
// IMedia // IMedia
@Override @Override
public boolean setLabel( ItemStack stack, String label ) public boolean setLabel( @Nonnull ItemStack stack, String label )
{ {
if( label != null ) if( label != null )
{ {
@ -375,19 +379,19 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia
} }
@Override @Override
public String getAudioTitle( ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public SoundEvent getAudio( ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
return null; return null;
} }
@Override @Override
public IMount createDataMount( ItemStack stack, World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
ServerComputer computer = createServerComputer( world, null, null, stack ); ServerComputer computer = createServerComputer( world, null, null, stack );
if( computer != null ) if( computer != null )

View File

@ -16,6 +16,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class PocketComputerUpgradeRecipe implements IRecipe public class PocketComputerUpgradeRecipe implements IRecipe
{ {
public PocketComputerUpgradeRecipe() public PocketComputerUpgradeRecipe()
@ -35,13 +37,13 @@ public class PocketComputerUpgradeRecipe implements IRecipe
} }
@Override @Override
public boolean matches( InventoryCrafting inventory, World world ) public boolean matches( @Nonnull InventoryCrafting inventory, @Nonnull World world )
{ {
return (getCraftingResult( inventory ) != null); return (getCraftingResult( inventory ) != null);
} }
@Override @Override
public ItemStack getCraftingResult( InventoryCrafting inventory ) public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
{ {
// Scan the grid for a pocket computer // Scan the grid for a pocket computer
ItemStack computer = null; ItemStack computer = null;
@ -112,8 +114,9 @@ public class PocketComputerUpgradeRecipe implements IRecipe
return PocketComputerItemFactory.create( computerID, label, family, upgrade ); return PocketComputerItemFactory.create( computerID, label, family, upgrade );
} }
@Nonnull
@Override @Override
public ItemStack[] getRemainingItems( InventoryCrafting inventoryCrafting ) public ItemStack[] getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
{ {
ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ]; ItemStack[] results = new ItemStack[ inventoryCrafting.getSizeInventory() ];
for (int i = 0; i < results.length; ++i) for (int i = 0; i < results.length; ++i)

View File

@ -19,6 +19,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -58,6 +59,7 @@ public class TurtleAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -181,7 +183,7 @@ public class TurtleAPI implements ILuaAPI
} }
@Override @Override
public Object[] callMethod( ILuaContext context, int method, Object[] args ) throws LuaException, InterruptedException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException, InterruptedException
{ {
switch( method ) switch( method )
{ {

View File

@ -27,6 +27,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockTurtle extends BlockComputerBase public class BlockTurtle extends BlockComputerBase
{ {
// Statics // Statics
@ -54,6 +56,7 @@ public class BlockTurtle extends BlockComputerBase
); );
} }
@Nonnull
@Override @Override
public EnumBlockRenderType getRenderType( IBlockState state ) public EnumBlockRenderType getRenderType( IBlockState state )
{ {
@ -72,12 +75,14 @@ public class BlockTurtle extends BlockComputerBase
return false; return false;
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
return new BlockStateContainer(this, Properties.FACING ); return new BlockStateContainer(this, Properties.FACING );
} }
@Nonnull
@Override @Override
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
@ -90,8 +95,9 @@ public class BlockTurtle extends BlockComputerBase
return 0; return 0;
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
{ {
return state.withProperty( Properties.FACING, getDirection( world, pos ) ); return state.withProperty( Properties.FACING, getDirection( world, pos ) );
} }

View File

@ -34,6 +34,7 @@ import net.minecraft.util.math.*;
import net.minecraft.util.text.*; import net.minecraft.util.text.*;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class TileTurtle extends TileComputerBase public class TileTurtle extends TileComputerBase
@ -144,7 +145,7 @@ public class TileTurtle extends TileComputerBase
} }
@Override @Override
public void getDroppedItems( List<ItemStack> drops, boolean creative ) public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
{ {
IComputer computer = getComputer(); IComputer computer = getComputer();
if( !creative || (computer != null && computer.getLabel() != null) ) if( !creative || (computer != null && computer.getLabel() != null) )
@ -243,6 +244,7 @@ public class TileTurtle extends TileComputerBase
} }
} }
@Nonnull
@Override @Override
public AxisAlignedBB getBounds() public AxisAlignedBB getBounds()
{ {
@ -293,7 +295,7 @@ public class TileTurtle extends TileComputerBase
} }
@Override @Override
public void onNeighbourTileEntityChange(BlockPos neighbour) public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour)
{ {
if ( m_moveState == MoveState.NOT_MOVED ) if ( m_moveState == MoveState.NOT_MOVED )
{ {
@ -342,6 +344,7 @@ public class TileTurtle extends TileComputerBase
m_brain.readFromNBT( nbttagcompound ); m_brain.readFromNBT( nbttagcompound );
} }
@Nonnull
@Override @Override
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound ) public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
{ {
@ -539,6 +542,7 @@ public class TileTurtle extends TileComputerBase
} }
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {
@ -569,6 +573,7 @@ public class TileTurtle extends TileComputerBase
return false; return false;
} }
@Nonnull
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName()
{ {
@ -589,17 +594,17 @@ public class TileTurtle extends TileComputerBase
} }
@Override @Override
public void openInventory( EntityPlayer player ) public void openInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public void closeInventory( EntityPlayer player ) public void closeInventory( @Nonnull EntityPlayer player )
{ {
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValidForSlot( int slot, @Nonnull ItemStack stack )
{ {
return true; return true;
} }
@ -625,7 +630,7 @@ public class TileTurtle extends TileComputerBase
} }
@Override @Override
public boolean isUseableByPlayer( EntityPlayer player ) public boolean isUseableByPlayer( @Nonnull EntityPlayer player )
{ {
return isUsable( player, false ); return isUsable( player, false );
} }
@ -666,14 +671,14 @@ public class TileTurtle extends TileComputerBase
// Networking stuff // Networking stuff
@Override @Override
public void writeDescription( NBTTagCompound nbttagcompound ) public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.writeDescription( nbttagcompound ); super.writeDescription( nbttagcompound );
m_brain.writeDescription( nbttagcompound ); m_brain.writeDescription( nbttagcompound );
} }
@Override @Override
public void readDescription( NBTTagCompound nbttagcompound ) public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
{ {
super.readDescription( nbttagcompound ); super.readDescription( nbttagcompound );
m_brain.readDescription( nbttagcompound ); m_brain.readDescription( nbttagcompound );

View File

@ -32,6 +32,7 @@ import net.minecraft.util.text.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import javax.annotation.Nonnull;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.*; import java.util.*;
@ -473,12 +474,14 @@ public class TurtleBrain implements ITurtleAccess
m_fuelLevel = nbttagcompound.getInteger( "fuelLevel" ); m_fuelLevel = nbttagcompound.getInteger( "fuelLevel" );
} }
@Nonnull
@Override @Override
public World getWorld() public World getWorld()
{ {
return m_owner.getWorld(); return m_owner.getWorld();
} }
@Nonnull
@Override @Override
public BlockPos getPosition() public BlockPos getPosition()
{ {
@ -486,7 +489,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public boolean teleportTo( World world, BlockPos pos ) public boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos )
{ {
if( world.isRemote || getWorld().isRemote ) if( world.isRemote || getWorld().isRemote )
{ {
@ -555,6 +558,7 @@ public class TurtleBrain implements ITurtleAccess
return false; return false;
} }
@Nonnull
@Override @Override
public Vec3d getVisualPosition( float f ) public Vec3d getVisualPosition( float f )
{ {
@ -596,6 +600,7 @@ public class TurtleBrain implements ITurtleAccess
return yaw; return yaw;
} }
@Nonnull
@Override @Override
public EnumFacing getDirection() public EnumFacing getDirection()
{ {
@ -603,7 +608,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public void setDirection( EnumFacing dir ) public void setDirection( @Nonnull EnumFacing dir )
{ {
if( dir.getAxis() == EnumFacing.Axis.Y ) if( dir.getAxis() == EnumFacing.Axis.Y )
{ {
@ -635,6 +640,7 @@ public class TurtleBrain implements ITurtleAccess
} }
} }
@Nonnull
@Override @Override
public IInventory getInventory() public IInventory getInventory()
{ {
@ -711,8 +717,9 @@ public class TurtleBrain implements ITurtleAccess
return m_commandsIssued; return m_commandsIssued;
} }
@Nonnull
@Override @Override
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException public Object[] executeCommand( @Nonnull ILuaContext context, @Nonnull ITurtleCommand command ) throws LuaException, InterruptedException
{ {
if( getWorld().isRemote ) if( getWorld().isRemote )
{ {
@ -742,7 +749,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public void playAnimation( TurtleAnimation animation ) public void playAnimation( @Nonnull TurtleAnimation animation )
{ {
if( getWorld().isRemote ) if( getWorld().isRemote )
{ {
@ -798,7 +805,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public ITurtleUpgrade getUpgrade( TurtleSide side ) public ITurtleUpgrade getUpgrade( @Nonnull TurtleSide side )
{ {
if( m_upgrades.containsKey( side ) ) if( m_upgrades.containsKey( side ) )
{ {
@ -808,7 +815,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public void setUpgrade( TurtleSide side, ITurtleUpgrade upgrade ) public void setUpgrade( @Nonnull TurtleSide side, ITurtleUpgrade upgrade )
{ {
// Remove old upgrade // Remove old upgrade
if( m_upgrades.containsKey( side ) ) if( m_upgrades.containsKey( side ) )
@ -846,7 +853,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public IPeripheral getPeripheral( TurtleSide side ) public IPeripheral getPeripheral( @Nonnull TurtleSide side )
{ {
if( m_peripherals.containsKey( side ) ) if( m_peripherals.containsKey( side ) )
{ {
@ -855,6 +862,7 @@ public class TurtleBrain implements ITurtleAccess
return null; return null;
} }
@Nonnull
@Override @Override
public NBTTagCompound getUpgradeNBTData( TurtleSide side ) public NBTTagCompound getUpgradeNBTData( TurtleSide side )
{ {
@ -866,7 +874,7 @@ public class TurtleBrain implements ITurtleAccess
} }
@Override @Override
public void updateUpgradeNBTData( TurtleSide side ) public void updateUpgradeNBTData( @Nonnull TurtleSide side )
{ {
m_owner.updateBlock(); m_owner.updateBlock();
} }

View File

@ -11,6 +11,8 @@ import dan200.computercraft.api.turtle.ITurtleCommand;
import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.core.apis.IAPIEnvironment; import dan200.computercraft.core.apis.IAPIEnvironment;
import javax.annotation.Nonnull;
public class TurtleCheckRedstoneCommand implements ITurtleCommand public class TurtleCheckRedstoneCommand implements ITurtleCommand
{ {
private final IAPIEnvironment m_environment; private final IAPIEnvironment m_environment;
@ -22,8 +24,9 @@ public class TurtleCheckRedstoneCommand implements ITurtleCommand
m_direction = direction; m_direction = direction;
} }
@Nonnull
@Override @Override
public TurtleCommandResult execute( ITurtleAccess turtle ) public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
{ {
// Do the checking // Do the checking
int redstoneSide; int redstoneSide;

View File

@ -19,6 +19,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.ReflectionHelper;
import javax.annotation.Nonnull;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Iterator; import java.util.Iterator;
@ -31,8 +32,9 @@ public class TurtleCompareCommand implements ITurtleCommand
m_direction = direction; m_direction = direction;
} }
@Nonnull
@Override @Override
public TurtleCommandResult execute( ITurtleAccess turtle ) public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
{ {
// Get world direction from direction // Get world direction from direction
EnumFacing direction = m_direction.toWorldDir( turtle ); EnumFacing direction = m_direction.toWorldDir( turtle );

View File

@ -12,6 +12,8 @@ import dan200.computercraft.api.turtle.TurtleCommandResult;
import dan200.computercraft.shared.util.InventoryUtil; import dan200.computercraft.shared.util.InventoryUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class TurtleCompareToCommand implements ITurtleCommand public class TurtleCompareToCommand implements ITurtleCommand
{ {
private final int m_slot; private final int m_slot;
@ -21,8 +23,9 @@ public class TurtleCompareToCommand implements ITurtleCommand
m_slot = slot; m_slot = slot;
} }
@Nonnull
@Override @Override
public TurtleCommandResult execute( ITurtleAccess turtle ) public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
{ {
ItemStack selectedStack = turtle.getInventory().getStackInSlot( turtle.getSelectedSlot() ); ItemStack selectedStack = turtle.getInventory().getStackInSlot( turtle.getSelectedSlot() );
ItemStack stack = turtle.getInventory().getStackInSlot( m_slot ); ItemStack stack = turtle.getInventory().getStackInSlot( m_slot );

View File

@ -16,6 +16,7 @@ import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
public class TurtleCraftCommand implements ITurtleCommand public class TurtleCraftCommand implements ITurtleCommand
@ -27,8 +28,9 @@ public class TurtleCraftCommand implements ITurtleCommand
m_limit = limit; m_limit = limit;
} }
@Nonnull
@Override @Override
public TurtleCommandResult execute( ITurtleAccess turtle ) public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
{ {
// Craft the item // Craft the item
TurtleInventoryCrafting crafting = new TurtleInventoryCrafting( turtle ); TurtleInventoryCrafting crafting = new TurtleInventoryCrafting( turtle );

Some files were not shown because too many files have changed in this diff Show More