1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 04:00:30 +00:00

Merge pull request #207 from SquidDev-CC/feature/cleanup

Fix a couple of warnings
This commit is contained in:
Daniel Ratcliffe 2017-05-07 18:26:07 +01:00 committed by GitHub
commit 0308ec555a
225 changed files with 1656 additions and 1317 deletions

View File

@ -83,3 +83,8 @@ processResources
} }
} }
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint"
}
}

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -74,18 +74,23 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/////////////// ///////////////
// UNIVERSAL // // UNIVERSAL //
/////////////// ///////////////
@Mod( @Mod(
modid = "ComputerCraft", name = "ComputerCraft", version = "${version}", modid = ComputerCraft.MOD_ID, name = "ComputerCraft", version = "${version}",
guiFactory = "dan200.computercraft.client.gui.GuiConfigCC$Factory" guiFactory = "dan200.computercraft.client.gui.GuiConfigCC$Factory"
) )
public class ComputerCraft public class ComputerCraft
{ {
public static final String MOD_ID = "ComputerCraft";
// GUI IDs // GUI IDs
public static final int diskDriveGUIID = 100; public static final int diskDriveGUIID = 100;
public static final int computerGUIID = 101; public static final int computerGUIID = 101;
@ -209,7 +214,7 @@ public class ComputerCraft
private static final Map<String, IPocketUpgrade> pocketUpgrades = new HashMap<String, IPocketUpgrade>(); private static final Map<String, IPocketUpgrade> pocketUpgrades = new HashMap<String, IPocketUpgrade>();
// Implementation // Implementation
@Mod.Instance( value = "ComputerCraft" ) @Mod.Instance( value = ComputerCraft.MOD_ID )
public static ComputerCraft instance; public static ComputerCraft instance;
@SidedProxy( clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient", serverSide = "dan200.computercraft.server.proxy.ComputerCraftProxyServer" ) @SidedProxy( clientSide = "dan200.computercraft.client.proxy.ComputerCraftProxyClient", serverSide = "dan200.computercraft.server.proxy.ComputerCraftProxyServer" )
@ -509,9 +514,8 @@ public class ComputerCraft
} }
} }
for( int i=0; i<permissionProviders.size(); ++i ) for( ITurtlePermissionProvider provider : permissionProviders )
{ {
ITurtlePermissionProvider provider = permissionProviders.get( i );
if( !provider.isBlockEnterable( world, pos ) ) if( !provider.isBlockEnterable( world, pos ) )
{ {
return false; return false;
@ -531,9 +535,8 @@ public class ComputerCraft
} }
} }
for( int i=0; i<permissionProviders.size(); ++i ) for( ITurtlePermissionProvider provider : permissionProviders )
{ {
ITurtlePermissionProvider provider = permissionProviders.get( i );
if( !provider.isBlockEditable( world, pos ) ) if( !provider.isBlockEditable( world, pos ) )
{ {
return false; return false;
@ -581,13 +584,11 @@ public class ComputerCraft
public static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side ) public static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side )
{ {
// Try the handlers in order: // Try the handlers in order:
Iterator<IPeripheralProvider> it = peripheralProviders.iterator(); for( IPeripheralProvider peripheralProvider : peripheralProviders )
while( it.hasNext() )
{ {
try try
{ {
IPeripheralProvider handler = it.next(); IPeripheral peripheral = peripheralProvider.getPeripheral( world, pos, side );
IPeripheral peripheral = handler.getPeripheral( world, pos, side );
if( peripheral != null ) if( peripheral != null )
{ {
return peripheral; return peripheral;
@ -620,13 +621,11 @@ public class ComputerCraft
// Try the handlers in order: // Try the handlers in order:
int combinedSignal = -1; int combinedSignal = -1;
Iterator<IBundledRedstoneProvider> it = bundledRedstoneProviders.iterator(); for( IBundledRedstoneProvider bundledRedstoneProvider : bundledRedstoneProviders )
while( it.hasNext() )
{ {
try try
{ {
IBundledRedstoneProvider handler = it.next(); int signal = bundledRedstoneProvider.getBundledRedstoneOutput( world, pos, side );
int signal = handler.getBundledRedstoneOutput( world, pos, side );
if( signal >= 0 ) if( signal >= 0 )
{ {
if( combinedSignal < 0 ) if( combinedSignal < 0 )
@ -652,13 +651,11 @@ public class ComputerCraft
if( stack != null ) if( stack != null )
{ {
// Try the handlers in order: // Try the handlers in order:
Iterator<IMediaProvider> it = mediaProviders.iterator(); for( IMediaProvider mediaProvider : mediaProviders )
while( it.hasNext() )
{ {
try try
{ {
IMediaProvider handler = it.next(); IMedia media = mediaProvider.getMedia( stack );
IMedia media = handler.getMedia( stack );
if( media != null ) if( media != null )
{ {
return media; return media;
@ -722,7 +719,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>();
@ -760,11 +757,11 @@ public class ComputerCraft
if( resourcePackDir.exists() && resourcePackDir.isDirectory() ) if( resourcePackDir.exists() && resourcePackDir.isDirectory() )
{ {
String[] resourcePacks = resourcePackDir.list(); String[] resourcePacks = resourcePackDir.list();
for( int i=0; i<resourcePacks.length; ++i ) for( String resourcePack1 : resourcePacks )
{ {
try try
{ {
File resourcePack = new File( resourcePackDir, resourcePacks[i] ); File resourcePack = new File( resourcePackDir, resourcePack1 );
if( !resourcePack.isDirectory() ) if( !resourcePack.isDirectory() )
{ {
// Mount a resource pack from a jar // Mount a resource pack from a jar
@ -806,7 +803,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 +828,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 {
@ -291,36 +298,36 @@ public final class ComputerCraftAPI
if( !ccSearched ) { if( !ccSearched ) {
try { try {
computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" ); computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
computerCraft_getVersion = findCCMethod( "getVersion", new Class[]{ computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[]{
} ); } );
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{ computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class<?>[]{
World.class, String.class World.class, String.class
} ); } );
computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] { computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class<?>[] {
World.class, String.class, Long.TYPE World.class, String.class, Long.TYPE
} ); } );
computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] { computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class<?>[] {
Class.class, String.class, String.class Class.class, String.class, String.class
} ); } );
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] { computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class<?>[] {
IPeripheralProvider.class IPeripheralProvider.class
} ); } );
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] { computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class<?>[] {
ITurtleUpgrade.class ITurtleUpgrade.class
} ); } );
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] { computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class<?>[] {
IBundledRedstoneProvider.class IBundledRedstoneProvider.class
} ); } );
computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] { computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class<?>[] {
World.class, BlockPos.class, EnumFacing.class World.class, BlockPos.class, EnumFacing.class
} ); } );
computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] { computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class<?>[] {
IMediaProvider.class IMediaProvider.class
} ); } );
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class[] { computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class<?>[] {
ITurtlePermissionProvider.class ITurtlePermissionProvider.class
} ); } );
computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class[] { computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class<?>[] {
IPocketUpgrade.class IPocketUpgrade.class
} ); } );
} catch( Exception e ) { } catch( Exception e ) {
@ -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 )
@ -346,7 +353,7 @@ public final class ComputerCraftAPI
} }
private static boolean ccSearched = false; private static boolean ccSearched = false;
private static Class computerCraft = null; private static Class<?> computerCraft = null;
private static Method computerCraft_getVersion = null; private static Method computerCraft_getVersion = null;
private static Method computerCraft_createUniqueNumberedSaveDir = null; private static Method computerCraft_createUniqueNumberedSaveDir = null;
private static Method computerCraft_createSaveDirMount = null; private static Method computerCraft_createSaveDirMount = 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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -18,7 +18,7 @@ public class GuiConfigCC extends GuiConfig
{ {
public GuiConfigCC( GuiScreen parentScreen ) public GuiConfigCC( GuiScreen parentScreen )
{ {
super( parentScreen, getConfigElements(), "ComputerCraft", false, false, "ComputerCraft" ); super( parentScreen, getConfigElements(), ComputerCraft.MOD_ID, false, false, "ComputerCraft" );
} }
private static List<IConfigElement> getConfigElements() private static List<IConfigElement> getConfigElements()

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -15,7 +15,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -11,13 +11,10 @@ import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public abstract class Widget extends Gui public abstract class Widget extends Gui
{ {
@ -269,9 +266,8 @@ public abstract class Widget extends Gui
FontRenderer fontRenderer = mc.fontRendererObj; FontRenderer fontRenderer = mc.fontRendererObj;
int width = 0; int width = 0;
for( int i=0; i<lines.length; ++i ) for( String line : lines )
{ {
String line = lines[i];
width = Math.max( fontRenderer.getStringWidth( line ), width ); width = Math.max( fontRenderer.getStringWidth( line ), width );
} }
int startX = x + 12; int startX = x + 12;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -48,10 +48,10 @@ public class WidgetContainer extends Widget
@Override @Override
public void update() public void update()
{ {
for( int i=0; i<m_widgets.size(); ++i ) for( Widget m_widget : m_widgets )
{ {
m_widgets.get( i ).update(); m_widget.update();
} }
if( m_modalWidget != null ) if( m_modalWidget != null )
{ {
m_modalWidget.update(); m_modalWidget.update();
@ -61,20 +61,19 @@ public class WidgetContainer extends Widget
@Override @Override
public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
{ {
for( int i=0; i<m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.draw(
widget.draw( mc,
mc, xOrigin + getXPosition(),
xOrigin + getXPosition(), yOrigin + getYPosition(),
yOrigin + getYPosition(), (m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99, (m_modalWidget == null) ? (mouseY - getYPosition()) : -99
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99 );
); }
} }
}
if( m_modalWidget != null ) if( m_modalWidget != null )
{ {
if( m_modalWidget.isVisible() ) if( m_modalWidget.isVisible() )
@ -102,20 +101,19 @@ public class WidgetContainer extends Widget
@Override @Override
public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
{ {
for( int i=0; i<m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.drawForeground(
widget.drawForeground( mc,
mc, xOrigin + getXPosition(),
xOrigin + getXPosition(), yOrigin + getYPosition(),
yOrigin + getYPosition(), (m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99, (m_modalWidget == null) ? (mouseY - getYPosition()) : -99
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99 );
); }
} }
}
if( m_modalWidget != null ) if( m_modalWidget != null )
{ {
@ -148,14 +146,13 @@ public class WidgetContainer extends Widget
pos.y -= getYPosition(); pos.y -= getYPosition();
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.modifyMousePosition( pos );
widget.modifyMousePosition( pos ); }
} }
}
} }
else else
{ {
@ -173,23 +170,22 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ if( widget.suppressItemTooltips(
if( widget.suppressItemTooltips( mc,
mc, xOrigin + getXPosition(),
xOrigin + getXPosition(), yOrigin + getYPosition(),
yOrigin + getYPosition(), mouseX - getXPosition(),
mouseX - getXPosition(), mouseY - getYPosition()
mouseY - getYPosition() ) )
) ) {
{ return true;
return true; }
} }
} }
}
} }
else else
{ {
@ -211,17 +207,16 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ if( widget.suppressKeyPress( c, k ) )
if( widget.suppressKeyPress( c, k ) ) {
{ return true;
return true; }
} }
} }
}
} }
else else
{ {
@ -241,17 +236,16 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.handleMouseInput(
widget.handleMouseInput( mouseX - getXPosition(),
mouseX - getXPosition(), mouseY - getYPosition()
mouseY - getYPosition() );
); }
} }
}
} }
else else
{ {
@ -270,14 +264,13 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.handleKeyboardInput();
widget.handleKeyboardInput(); }
} }
}
} }
else else
{ {
@ -293,18 +286,17 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.mouseClicked(
widget.mouseClicked( mouseX - getXPosition(),
mouseX - getXPosition(), mouseY - getYPosition(),
mouseY - getYPosition(), mouseButton
mouseButton );
); }
} }
}
} }
else else
{ {
@ -324,14 +316,13 @@ public class WidgetContainer extends Widget
{ {
if( m_modalWidget == null ) if( m_modalWidget == null )
{ {
for( int i = 0; i < m_widgets.size(); ++i ) for( Widget widget : m_widgets )
{ {
Widget widget = m_widgets.get( i ); if( widget.isVisible() )
if( widget.isVisible() ) {
{ widget.keyTyped( c, k );
widget.keyTyped( c, k ); }
} }
}
} }
else else
{ {

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -49,12 +49,12 @@ import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
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 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 +88,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 +122,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 +182,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 +221,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;
} }
@ -276,10 +279,10 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
@Override @Override
public String getRecordInfo( ItemStack recordStack ) public String getRecordInfo( ItemStack recordStack )
{ {
List info = new ArrayList(1); List<String> info = new ArrayList<String>( 1 );
recordStack.getItem().addInformation( recordStack, null, info, false ); recordStack.getItem().addInformation( recordStack, null, info, false );
if( info.size() > 0 ) { if( info.size() > 0 ) {
return info.get(0).toString(); return info.get( 0 );
} else { } else {
return super.getRecordInfo( recordStack ); return super.getRecordInfo( recordStack );
} }
@ -401,7 +404,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
{ {
ComputerCraft.clientComputerRegistry.add( instanceID, new ClientComputer( instanceID ) ); ComputerCraft.clientComputerRegistry.add( instanceID, new ClientComputer( instanceID ) );
} }
ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, (EntityPlayer) player ); ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, player );
break; break;
} }
case ComputerCraftPacket.ComputerDeleted: case ComputerCraftPacket.ComputerDeleted:
@ -519,7 +522,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -25,6 +25,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()
@ -32,7 +34,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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;
@ -24,7 +25,7 @@ public class TurtleMultiModel implements IBakedModel
private IBakedModel m_rightUpgradeModel; private IBakedModel m_rightUpgradeModel;
private Matrix4f m_rightUpgradeTransform; private Matrix4f m_rightUpgradeTransform;
private List<BakedQuad> m_generalQuads; private List<BakedQuad> m_generalQuads;
private List<BakedQuad> m_faceQuads[]; private List<BakedQuad>[] m_faceQuads;
public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform ) public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform )
{ {
@ -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,22 @@ 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
@Deprecated
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms()
{ {
return m_baseModel.getItemCameraTransforms(); return m_baseModel.getItemCameraTransforms();
} }
@Nonnull
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
@ -134,9 +140,8 @@ public class TurtleMultiModel implements IBakedModel
else else
{ {
List<BakedQuad> output = new ArrayList<BakedQuad>( input.size() ); List<BakedQuad> output = new ArrayList<BakedQuad>( input.size() );
for( int i=0; i<input.size(); ++i ) for( BakedQuad quad : input )
{ {
BakedQuad quad = input.get( i );
output.add( transformQuad( quad, transform ) ); output.add( transformQuad( quad, transform ) );
} }
return output; return output;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -26,10 +26,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.model.IModel;
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 +101,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 +127,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload
}; };
} }
@Nonnull
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
@ -134,7 +135,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 +174,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,13 +199,16 @@ 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
@Deprecated
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms()
{ {
return getDefaultModel().getItemCameraTransforms(); return getDefaultModel().getItemCameraTransforms();

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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 )
{ {
@ -122,7 +124,7 @@ public class FSAPI implements ILuaAPI
throw new LuaException( "Expected string" ); throw new LuaException( "Expected string" );
} }
String path = (String)args[0]; String path = (String)args[0];
return new Object[]{ m_fileSystem.getName( path ) }; return new Object[]{ FileSystem.getName( path ) };
} }
case 3: case 3:
{ {
@ -357,7 +359,7 @@ public class FSAPI implements ILuaAPI
throw new LuaException( "Expected string" ); throw new LuaException( "Expected string" );
} }
String path = (String)args[0]; String path = (String)args[0];
return new Object[]{ m_fileSystem.getDirectory( path ) }; return new Object[]{ FileSystem.getDirectory( path ) };
} }
default: default:
{ {
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,14 +10,15 @@ 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.*;
public class HTTPAPI implements ILuaAPI public class HTTPAPI implements ILuaAPI
{ {
private IAPIEnvironment m_apiEnvironment; private final IAPIEnvironment m_apiEnvironment;
private List<HTTPRequest> m_httpRequests; private final List<HTTPRequest> m_httpRequests;
public HTTPAPI( IAPIEnvironment environment ) public HTTPAPI( IAPIEnvironment environment )
{ {
@ -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 )
{ {
@ -155,15 +157,15 @@ public class HTTPAPI implements ILuaAPI
{ {
synchronized( m_httpRequests ) synchronized( m_httpRequests )
{ {
Iterator<HTTPRequest> it = m_httpRequests.iterator(); for( HTTPRequest r : m_httpRequests )
while( it.hasNext() ) { {
HTTPRequest r = it.next();
r.cancel(); r.cancel();
} }
m_httpRequests.clear(); m_httpRequests.clear();
} }
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -174,7 +176,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 )
{ {
@ -199,7 +201,7 @@ public class HTTPAPI implements ILuaAPI
Map<String, String> headers = null; Map<String, String> headers = null;
if( args.length >= 3 && args[2] instanceof Map ) if( args.length >= 3 && args[2] instanceof Map )
{ {
Map table = (Map)args[2]; Map<?, ?> table = (Map<?, ?>)args[2];
headers = new HashMap<String, String>( table.size() ); headers = new HashMap<String, String>( table.size() );
for( Object key : table.keySet() ) for( Object key : table.keySet() )
{ {

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -18,12 +18,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
class HTTPRequestException extends Exception {
public HTTPRequestException( String s ) {
super( s );
}
}
public class HTTPRequest public class HTTPRequest
{ {
public static URL checkURL( String urlString ) throws HTTPRequestException public static URL checkURL( String urlString ) throws HTTPRequestException
@ -49,9 +43,8 @@ public class HTTPRequest
boolean allowed = false; boolean allowed = false;
String whitelistString = ComputerCraft.http_whitelist; String whitelistString = ComputerCraft.http_whitelist;
String[] allowedURLs = whitelistString.split( ";" ); String[] allowedURLs = whitelistString.split( ";" );
for( int i=0; i<allowedURLs.length; ++i ) for( String allowedURL : allowedURLs )
{ {
String allowedURL = allowedURLs[i];
Pattern allowedURLPattern = Pattern.compile( "^\\Q" + allowedURL.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$" ); Pattern allowedURLPattern = Pattern.compile( "^\\Q" + allowedURL.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$" );
if( allowedURLPattern.matcher( url.getHost() ).matches() ) if( allowedURLPattern.matcher( url.getHost() ).matches() )
{ {
@ -274,7 +267,7 @@ public class HTTPRequest
public BufferedReader getContents() public BufferedReader getContents()
{ {
String result = null; String result;
synchronized(m_lock) { synchronized(m_lock) {
result = m_result; result = m_result;
} }
@ -285,8 +278,8 @@ public class HTTPRequest
return null; return null;
} }
private Object m_lock = new Object(); private final Object m_lock = new Object();
private URL m_url; private final URL m_url;
private final String m_urlString; private final String m_urlString;
private boolean m_complete; private boolean m_complete;

View File

@ -0,0 +1,11 @@
package dan200.computercraft.core.apis;
public class HTTPRequestException extends Exception
{
private static final long serialVersionUID = 7591208619422744652L;
public HTTPRequestException( String s )
{
super( s );
}
}

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -14,32 +14,32 @@ import dan200.computercraft.core.terminal.Terminal;
public interface IAPIEnvironment public interface IAPIEnvironment
{ {
public static interface IPeripheralChangeListener interface IPeripheralChangeListener
{ {
public void onPeripheralChanged( int side, IPeripheral newPeripheral ); void onPeripheralChanged( int side, IPeripheral newPeripheral );
} }
public Computer getComputer(); Computer getComputer();
public int getComputerID(); int getComputerID();
public IComputerEnvironment getComputerEnvironment(); IComputerEnvironment getComputerEnvironment();
public Terminal getTerminal(); Terminal getTerminal();
public FileSystem getFileSystem(); FileSystem getFileSystem();
public void shutdown(); void shutdown();
public void reboot(); void reboot();
public void queueEvent( String event, Object[] args ); void queueEvent( String event, Object[] args );
public void setOutput( int side, int output ); void setOutput( int side, int output );
public int getOutput( int side ); int getOutput( int side );
public int getInput( int side ); int getInput( int side );
public void setBundledOutput( int side, int output ); void setBundledOutput( int side, int output );
public int getBundledOutput( int side ); int getBundledOutput( int side );
public int getBundledInput( int side ); int getBundledInput( int side );
public void setPeripheralChangeListener( IPeripheralChangeListener listener ); void setPeripheralChangeListener( IPeripheralChangeListener listener );
public IPeripheral getPeripheral( int side ); IPeripheral getPeripheral( int side );
public String getLabel(); String getLabel();
public void setLabel( String label ); void setLabel( String label );
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -9,9 +9,9 @@ import dan200.computercraft.api.lua.ILuaObject;
public interface ILuaAPI extends ILuaObject public interface ILuaAPI extends ILuaObject
{ {
public String[] getNames(); String[] getNames();
public void startup(); // LT void startup(); // LT
public void advance( double _dt ); // MT void advance( double _dt ); // MT
public void shutdown(); // LT void shutdown(); // LT
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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
@ -88,9 +89,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
m_attached = false; m_attached = false;
// Unmount everything the detach function forgot to do // Unmount everything the detach function forgot to do
Iterator<String> it = m_mounts.iterator(); for( String m_mount : m_mounts )
while( it.hasNext() ) { {
m_fileSystem.unmount( it.next() ); m_fileSystem.unmount( m_mount );
} }
m_mounts.clear(); m_mounts.clear();
} }
@ -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 )
{ {
@ -132,7 +133,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
// Mount the location // Mount the location
String location = null; String location;
synchronized( m_fileSystem ) synchronized( m_fileSystem )
{ {
location = findFreeLocation( desiredLoc ); location = findFreeLocation( desiredLoc );
@ -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 )
{ {
@ -167,7 +168,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
// Mount the location // Mount the location
String location = null; String location;
synchronized( m_fileSystem ) synchronized( m_fileSystem )
{ {
location = findFreeLocation( desiredLoc ); location = findFreeLocation( desiredLoc );
@ -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()
{ {
@ -233,9 +235,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
} }
} }
private IAPIEnvironment m_environment; private final IAPIEnvironment m_environment;
private FileSystem m_fileSystem; private FileSystem m_fileSystem;
private PeripheralWrapper[] m_peripherals; private final PeripheralWrapper[] m_peripherals;
private boolean m_running; private boolean m_running;
public PeripheralAPI( IAPIEnvironment _environment ) public PeripheralAPI( IAPIEnvironment _environment )
@ -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 )
{ {
@ -467,15 +470,14 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
int side = parseSide( args ); int side = parseSide( args );
if( side >= 0 ) if( side >= 0 )
{ {
PeripheralWrapper p = null; PeripheralWrapper p;
synchronized( m_peripherals ) synchronized( m_peripherals )
{ {
p = m_peripherals[ side ]; p = m_peripherals[ side ];
} }
if( p != null ) if( p != null )
{ {
Object[] results = p.call( context, methodName, methodArgs ); return p.call( context, methodName, methodArgs );
return results;
} }
} }
throw new LuaException( "No peripheral attached" ); throw new LuaException( "No peripheral attached" );

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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 )
{ {
@ -89,7 +91,7 @@ public class RedstoneAPI implements ILuaAPI
throw new LuaException( "Expected string, boolean" ); throw new LuaException( "Expected string, boolean" );
} }
int side = parseSide( args ); int side = parseSide( args );
boolean output = ((Boolean)args[1]).booleanValue(); boolean output = (Boolean) args[ 1 ];
m_environment.setOutput( side, output ? 15 : 0 ); m_environment.setOutput( side, output ? 15 : 0 );
return null; return null;
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -17,6 +17,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.Nonnull;
public class TermAPI implements ILuaAPI public class TermAPI implements ILuaAPI
{ {
private final Terminal m_terminal; private final Terminal m_terminal;
@ -51,6 +53,7 @@ public class TermAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -117,7 +120,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -21,7 +21,6 @@ import dan200.computercraft.core.terminal.Terminal;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class Computer public class Computer
@ -30,7 +29,7 @@ public class Computer
"bottom", "top", "back", "front", "right", "left", "bottom", "top", "back", "front", "right", "left",
}; };
private static enum State private enum State
{ {
Off, Off,
Starting, Starting,
@ -187,26 +186,26 @@ public class Computer
private boolean m_blinking; private boolean m_blinking;
private ILuaMachine m_machine; private ILuaMachine m_machine;
private List<ILuaAPI> m_apis; private final List<ILuaAPI> m_apis;
private APIEnvironment m_apiEnvironment; private final APIEnvironment m_apiEnvironment;
private Terminal m_terminal; private final Terminal m_terminal;
private FileSystem m_fileSystem; private FileSystem m_fileSystem;
private IWritableMount m_rootMount; private IWritableMount m_rootMount;
private int[] m_internalOutput; private final int[] m_internalOutput;
private int[] m_internalBundledOutput; private final int[] m_internalBundledOutput;
private boolean m_internalOutputChanged; private boolean m_internalOutputChanged;
private int[] m_externalOutput; private final int[] m_externalOutput;
private int[] m_externalBundledOutput; private final int[] m_externalBundledOutput;
private boolean m_externalOutputChanged; private boolean m_externalOutputChanged;
private int[] m_input; private final int[] m_input;
private int[] m_bundledInput; private final int[] m_bundledInput;
private boolean m_inputChanged; private boolean m_inputChanged;
private IPeripheral[] m_peripherals; private final IPeripheral[] m_peripherals;
public Computer( IComputerEnvironment environment, Terminal terminal, int id ) public Computer( IComputerEnvironment environment, Terminal terminal, int id )
{ {
@ -370,10 +369,8 @@ public class Computer
// Advance our APIs // Advance our APIs
synchronized( m_apis ) synchronized( m_apis )
{ {
Iterator<ILuaAPI> it = m_apis.iterator(); for(ILuaAPI api : m_apis)
while( it.hasNext() )
{ {
ILuaAPI api = it.next();
api.advance( _dt ); api.advance( _dt );
} }
} }
@ -628,10 +625,8 @@ public class Computer
ILuaMachine machine = new LuaJLuaMachine( this ); ILuaMachine machine = new LuaJLuaMachine( this );
// Add the APIs // Add the APIs
Iterator<ILuaAPI> it = m_apis.iterator(); for(ILuaAPI api : m_apis)
while( it.hasNext() )
{ {
ILuaAPI api = it.next();
machine.addAPI( api ); machine.addAPI( api );
api.startup(); api.startup();
} }
@ -794,10 +789,8 @@ public class Computer
// Shutdown our APIs // Shutdown our APIs
synchronized( m_apis ) synchronized( m_apis )
{ {
Iterator<ILuaAPI> it = m_apis.iterator(); for(ILuaAPI api : m_apis)
while( it.hasNext() )
{ {
ILuaAPI api = it.next();
api.shutdown(); api.shutdown();
} }
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -13,14 +13,14 @@ import java.util.concurrent.LinkedBlockingQueue;
public class ComputerThread public class ComputerThread
{ {
private static Object m_lock; private static final Object m_lock;
private static Thread m_thread; private static Thread m_thread;
private static WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks; private static final WeakHashMap <Object, LinkedBlockingQueue<ITask>> m_computerTasks;
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive; private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksActive;
private static ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending; private static final ArrayList <LinkedBlockingQueue<ITask>> m_computerTasksPending;
private static Object m_defaultQueue; private static final Object m_defaultQueue;
private static Object m_monitor; private static final Object m_monitor;
private static boolean m_running; private static boolean m_running;
private static boolean m_stopped; private static boolean m_stopped;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,13 +10,13 @@ import dan200.computercraft.api.filesystem.IWritableMount;
public interface IComputerEnvironment public interface IComputerEnvironment
{ {
public int getDay(); int getDay();
public double getTimeOfDay(); double getTimeOfDay();
public boolean isColour(); boolean isColour();
public long getComputerSpaceLimit(); long getComputerSpaceLimit();
public String getHostString(); String getHostString();
public int assignNewID(); int assignNewID();
public IWritableMount createSaveDirMount( String subPath, long capacity ); IWritableMount createSaveDirMount( String subPath, long capacity );
public IMount createResourceMount( String domain, String subPath ); IMount createResourceMount( String domain, String subPath );
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -8,6 +8,6 @@ package dan200.computercraft.core.computer;
public interface ITask public interface ITask
{ {
public Computer getOwner(); Computer getOwner();
public void execute(); void execute();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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;
@ -83,9 +84,8 @@ public class ComboMount implements IMount
{ {
// We found multiple directories, so filter for duplicates // We found multiple directories, so filter for duplicates
Set<String> seen = new HashSet<String>(); Set<String> seen = new HashSet<String>();
for( int i=0; i<foundFiles.size(); ++i ) for(String file : foundFiles)
{ {
String file = foundFiles.get(i);
if( seen.add( file ) ) if( seen.add( file ) )
{ {
contents.add( file ); contents.add( file );
@ -99,7 +99,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 +112,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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 )
{ {
@ -259,9 +261,9 @@ public class FileMount implements IWritableMount
if( file.isDirectory() ) if( file.isDirectory() )
{ {
String[] children = file.list(); String[] children = file.list();
for( int i=0; i<children.length; i++ ) for( String aChildren : children )
{ {
deleteRecursively( new File( file, children[i] ) ); deleteRecursively( new File( file, aChildren ) );
} }
} }
@ -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() )
{ {
@ -372,9 +376,9 @@ public class FileMount implements IWritableMount
{ {
long size = MINIMUM_FILE_SIZE; long size = MINIMUM_FILE_SIZE;
String[] contents = file.list(); String[] contents = file.list();
for( int i=0; i<contents.length; ++i ) for( String content : contents )
{ {
size += measureUsedSpace( new File( file, contents[i] ) ); size += measureUsedSpace( new File( file, content ) );
} }
return size; return size;
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -327,7 +327,7 @@ public class FileSystem
throw new NullPointerException(); throw new NullPointerException();
} }
location = sanitizePath( location ); location = sanitizePath( location );
if( location.indexOf( ".." ) != -1 ) { if( location.contains( ".." ) ) {
throw new FileSystemException( "Cannot mount below the root" ); throw new FileSystemException( "Cannot mount below the root" );
} }
mount( new MountWrapper( label, location, mount ) ); mount( new MountWrapper( label, location, mount ) );
@ -427,10 +427,10 @@ public class FileSystem
mount.list( path, list ); mount.list( path, list );
// Add any mounts that are mounted at this location // Add any mounts that are mounted at this location
Iterator<MountWrapper> it = m_mounts.values().iterator(); for( MountWrapper otherMount : m_mounts.values() )
while( it.hasNext() ) { {
MountWrapper otherMount = it.next(); if( getDirectory( otherMount.getLocation() ).equals( path ) )
if( getDirectory( otherMount.getLocation() ).equals( path ) ) { {
list.add( getName( otherMount.getLocation() ) ); list.add( getName( otherMount.getLocation() ) );
} }
} }
@ -445,9 +445,8 @@ public class FileSystem
private void findIn( String dir, List<String> matches, Pattern wildPattern ) throws FileSystemException private void findIn( String dir, List<String> matches, Pattern wildPattern ) throws FileSystemException
{ {
String[] list = list( dir ); String[] list = list( dir );
for( int i=0; i<list.length; ++i ) for( String entry : list )
{ {
String entry = list[i];
String entryPath = dir.isEmpty() ? entry : (dir + "/" + entry); String entryPath = dir.isEmpty() ? entry : (dir + "/" + entry);
if( wildPattern.matcher( entryPath ).matches() ) if( wildPattern.matcher( entryPath ).matches() )
{ {
@ -910,7 +909,7 @@ public class FileSystem
char c = path.charAt(i); char c = path.charAt(i);
if( c >= 32 && Arrays.binarySearch( specialChars, c ) < 0 && (allowWildcards || c != '*') ) if( c >= 32 && Arrays.binarySearch( specialChars, c ) < 0 && (allowWildcards || c != '*') )
{ {
cleanName.append((char)c); cleanName.append( c );
} }
} }
path = cleanName.toString(); path = cleanName.toString();
@ -918,30 +917,42 @@ public class FileSystem
// Collapse the string into its component parts, removing ..'s // Collapse the string into its component parts, removing ..'s
String[] parts = path.split("/"); String[] parts = path.split("/");
Stack<String> outputParts = new Stack<String>(); Stack<String> outputParts = new Stack<String>();
for( int n=0; n<parts.length; ++n ) { for( String part : parts )
String part = parts[n]; {
if( part.length() == 0 || part.equals(".") ) if( part.length() == 0 || part.equals( "." ) )
{ {
// . is redundant // . is redundant
continue; continue;
} else if( part.equals("..") || part.equals( "..." ) ) { }
else if( part.equals( ".." ) || part.equals( "..." ) )
{
// .. or ... can cancel out the last folder entered // .. or ... can cancel out the last folder entered
if( !outputParts.empty() ) { if( !outputParts.empty() )
{
String top = outputParts.peek(); String top = outputParts.peek();
if( !top.equals("..") ) { if( !top.equals( ".." ) )
{
outputParts.pop(); outputParts.pop();
} else {
outputParts.push("..");
} }
} else { else
outputParts.push(".."); {
outputParts.push( ".." );
}
} }
} else if (part.length() >= 255) { else
{
outputParts.push( ".." );
}
}
else if( part.length() >= 255 )
{
// If part length > 255 and it is the last part // If part length > 255 and it is the last part
outputParts.push( part.substring(0, 255) ); outputParts.push( part.substring( 0, 255 ) );
} else { }
else
{
// Anything else we add to the stack // Anything else we add to the stack
outputParts.push(part); outputParts.push( part );
} }
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -7,6 +7,8 @@
package dan200.computercraft.core.filesystem; package dan200.computercraft.core.filesystem;
public class FileSystemException extends Exception { public class FileSystemException extends Exception {
private static final long serialVersionUID = -2500631644868104029L;
FileSystemException( String s ) { FileSystemException( String s ) {
super( s ); super( s );
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -9,5 +9,5 @@ package dan200.computercraft.core.filesystem;
import java.io.IOException; import java.io.IOException;
public interface IMountedFile { public interface IMountedFile {
public void close() throws IOException; void close() throws IOException;
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -9,8 +9,8 @@ package dan200.computercraft.core.filesystem;
import java.io.IOException; import java.io.IOException;
public interface IMountedFileBinary extends IMountedFile { public interface IMountedFileBinary extends IMountedFile {
public int read() throws IOException; int read() throws IOException;
public void write(int i) throws IOException; void write( int i ) throws IOException;
public void close() throws IOException; void close() throws IOException;
public void flush() throws IOException; void flush() throws IOException;
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -9,8 +9,8 @@ package dan200.computercraft.core.filesystem;
import java.io.IOException; import java.io.IOException;
public interface IMountedFileNormal extends IMountedFile { public interface IMountedFileNormal extends IMountedFile {
public String readLine() throws IOException; String readLine() throws IOException;
public void write(String s, int off, int len, boolean newLine) throws IOException; void write( String s, int off, int len, boolean newLine ) throws IOException;
public void close() throws IOException; void close() throws IOException;
public void flush() throws IOException; void flush() throws IOException;
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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;
@ -53,10 +54,7 @@ public class JarMount implements IMount
public void list( List<String> contents ) public void list( List<String> contents )
{ {
for( String child : m_children.keySet() ) contents.addAll( m_children.keySet() );
{
contents.add( child );
}
} }
public void insertChild( FileInZip child ) public void insertChild( FileInZip child )
@ -178,14 +176,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 +194,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 +208,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 +218,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -12,17 +12,17 @@ import java.io.OutputStream;
public interface ILuaMachine public interface ILuaMachine
{ {
public void addAPI( ILuaAPI api ); void addAPI( ILuaAPI api );
public void loadBios( InputStream bios ); void loadBios( InputStream bios );
public void handleEvent( String eventName, Object[] arguments ); void handleEvent( String eventName, Object[] arguments );
public void softAbort( String abortMessage ); void softAbort( String abortMessage );
public void hardAbort( String abortMessage ); void hardAbort( String abortMessage );
public boolean saveState( OutputStream output ); boolean saveState( OutputStream output );
public boolean restoreState( InputStream input ); boolean restoreState( InputStream input );
public boolean isFinished(); boolean isFinished();
public void unload(); void unload();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -21,10 +21,10 @@ 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;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
public class LuaJLuaMachine implements ILuaMachine public class LuaJLuaMachine implements ILuaMachine
@ -128,9 +128,9 @@ public class LuaJLuaMachine implements ILuaMachine
// Add the methods of an API to the global table // Add the methods of an API to the global table
LuaTable table = wrapLuaObject( api ); LuaTable table = wrapLuaObject( api );
String[] names = api.getNames(); String[] names = api.getNames();
for( int i=0; i<names.length; ++i ) for( String name : names )
{ {
m_globals.set( names[i], table ); m_globals.set( name, table );
} }
} }
@ -146,7 +146,7 @@ public class LuaJLuaMachine implements ILuaMachine
try try
{ {
// Read the whole bios into a string // Read the whole bios into a string
String biosText = null; String biosText;
try try
{ {
InputStreamReader isr; InputStreamReader isr;
@ -316,8 +316,6 @@ public class LuaJLuaMachine implements ILuaMachine
throw new LuaError( abortMessage ); throw new LuaError( abortMessage );
} }
} }
private static long s_nextUnusedTaskID = 0;
private LuaTable wrapLuaObject( ILuaObject object ) private LuaTable wrapLuaObject( ILuaObject object )
{ {
@ -335,10 +333,11 @@ public class LuaJLuaMachine implements ILuaMachine
{ {
tryAbort(); tryAbort();
Object[] arguments = toObjects( _args, 1 ); Object[] arguments = toObjects( _args, 1 );
Object[] results = null; Object[] results;
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 +349,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 +373,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();
@ -395,10 +396,7 @@ public class LuaJLuaMachine implements ILuaMachine
Object[] eventArguments = new Object[ results.length + 2 ]; Object[] eventArguments = new Object[ results.length + 2 ];
eventArguments[ 0 ] = taskID; eventArguments[ 0 ] = taskID;
eventArguments[ 1 ] = true; eventArguments[ 1 ] = true;
for( int i = 0; i < results.length; ++i ) System.arraycopy( results, 0, eventArguments, 2, results.length );
{
eventArguments[ i + 2 ] = results[ i ];
}
m_computer.queueEvent( "task_complete", eventArguments ); m_computer.queueEvent( "task_complete", eventArguments );
} }
else else
@ -431,7 +429,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 );
@ -448,10 +446,7 @@ public class LuaJLuaMachine implements ILuaMachine
if( (Boolean)response[ 2 ] ) if( (Boolean)response[ 2 ] )
{ {
// Extract the return values from the event and return them // Extract the return values from the event and return them
for( int i = 0; i < returnValues.length; ++i ) System.arraycopy( response, 3, returnValues, 0, returnValues.length );
{
returnValues[ i ] = response[ i + 3 ];
}
return returnValues; return returnValues;
} }
else else
@ -506,7 +501,7 @@ public class LuaJLuaMachine implements ILuaMachine
} }
else if( object instanceof Boolean ) else if( object instanceof Boolean )
{ {
boolean b = ((Boolean)object).booleanValue(); boolean b = (Boolean) object;
return LuaValue.valueOf( b ); return LuaValue.valueOf( b );
} }
else if( object instanceof String ) else if( object instanceof String )
@ -534,10 +529,8 @@ public class LuaJLuaMachine implements ILuaMachine
m_valuesInProgress.put( object, table ); m_valuesInProgress.put( object, table );
// Convert all keys // Convert all keys
Iterator it = ((Map)object).entrySet().iterator(); for( Map.Entry<?, ?> pair : ((Map<?, ?>) object).entrySet() )
while( it.hasNext() )
{ {
Map.Entry pair = (Map.Entry)it.next();
LuaValue key = toValue( pair.getKey() ); LuaValue key = toValue( pair.getKey() );
LuaValue value = toValue( pair.getValue() ); LuaValue value = toValue( pair.getValue() );
if( !key.isnil() && !value.isnil() ) if( !key.isnil() && !value.isnil() )
@ -558,8 +551,7 @@ public class LuaJLuaMachine implements ILuaMachine
} }
else if( object instanceof ILuaObject ) else if( object instanceof ILuaObject )
{ {
LuaValue table = wrapLuaObject( (ILuaObject)object ); return wrapLuaObject( (ILuaObject)object );
return table;
} }
else else
{ {
@ -627,7 +619,7 @@ public class LuaJLuaMachine implements ILuaMachine
{ {
return m_objectsInProgress.get( value ); return m_objectsInProgress.get( value );
} }
Map table = new HashMap(); Map<Object, Object> table = new HashMap<Object, Object>();
m_objectsInProgress.put( value, table ); m_objectsInProgress.put( value, table );
// Convert all keys // Convert all keys

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -6,7 +6,6 @@
package dan200.computercraft.server.proxy; package dan200.computercraft.server.proxy;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.blocks.TileComputer; import dan200.computercraft.shared.computer.blocks.TileComputer;
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
import dan200.computercraft.shared.peripheral.printer.TilePrinter; import dan200.computercraft.shared.peripheral.printer.TilePrinter;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,7 +10,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -25,8 +24,8 @@ 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.List; import java.util.List;
public abstract class BlockGeneric extends Block implements public abstract class BlockGeneric extends Block implements
@ -43,12 +42,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 +60,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 +68,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 )
{ {
@ -94,10 +95,8 @@ public abstract class BlockGeneric extends Block implements
// Drop items // Drop items
if( drops.size() > 0 ) if( drops.size() > 0 )
{ {
Iterator<ItemStack> it = drops.iterator(); for (ItemStack item : drops)
while( it.hasNext() )
{ {
ItemStack item = it.next();
dropItem( world, pos, item ); dropItem( world, pos, item );
} }
} }
@ -109,7 +108,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 +120,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 +134,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;
} }
@ -152,6 +152,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
@Deprecated
public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block block ) public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block block )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
@ -174,7 +175,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 +193,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,7 +207,9 @@ public abstract class BlockGeneric extends Block implements
return super.getExplosionResistance( exploder ); return super.getExplosionResistance( exploder );
} }
@Nonnull
@Override @Override
@Deprecated
public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos ) public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
@ -218,14 +221,17 @@ 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 ) @Deprecated
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 ) @Deprecated
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,8 @@ 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 ) @Deprecated
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() )
@ -266,10 +273,8 @@ public abstract class BlockGeneric extends Block implements
// Add collision bounds to list // Add collision bounds to list
if( collision.size() > 0 ) if( collision.size() > 0 )
{ {
Iterator<AxisAlignedBB> it = collision.iterator(); for (AxisAlignedBB localBounds : collision)
while( it.hasNext() )
{ {
AxisAlignedBB localBounds = it.next();
addCollisionBoxToList( pos, bigBox, list, localBounds ); addCollisionBoxToList( pos, bigBox, list, localBounds );
} }
} }
@ -277,6 +282,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
@Deprecated
public final boolean canProvidePower( IBlockState state ) public final boolean canProvidePower( IBlockState state )
{ {
return true; return true;
@ -295,6 +301,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
@Deprecated
public final int getStrongPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide ) public final int getStrongPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );
@ -307,6 +314,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
@Deprecated
public final int getWeakPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide ) public final int getWeakPower( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing oppositeSide )
{ {
return getStrongPower( state, world, pos, oppositeSide ); return getStrongPower( state, world, pos, oppositeSide );
@ -335,6 +343,7 @@ public abstract class BlockGeneric extends Block implements
} }
@Override @Override
@Deprecated
public boolean eventReceived( IBlockState state, World world, BlockPos pos, int eventID, int eventParameter ) public boolean eventReceived( IBlockState state, World world, BlockPos pos, int eventID, int eventParameter )
{ {
if( world.isRemote ) if( world.isRemote )
@ -349,14 +358,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,6 +10,6 @@ import net.minecraft.util.EnumFacing;
public interface IDirectionalTile public interface IDirectionalTile
{ {
public EnumFacing getDirection(); EnumFacing getDirection();
public void setDirection( EnumFacing dir ); void setDirection( EnumFacing dir );
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,6 +10,6 @@ import dan200.computercraft.core.terminal.Terminal;
public interface ITerminal public interface ITerminal
{ {
public Terminal getTerminal(); Terminal getTerminal();
public boolean isColour(); boolean isColour();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -8,5 +8,5 @@ package dan200.computercraft.shared.common;
public interface ITerminalTile public interface ITerminalTile
{ {
public ITerminal getTerminal(); ITerminal getTerminal();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -23,6 +22,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 +49,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 +79,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 +97,7 @@ public abstract class TileGeneric extends TileEntity
{ {
} }
public void onNeighbourTileEntityChange( BlockPos neighbour ) public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
{ {
} }
@ -109,12 +111,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 +132,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 +166,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 +189,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 +218,7 @@ public abstract class TileGeneric extends TileEntity
} }
} }
@Nonnull
@Override @Override
public NBTTagCompound getUpdateTag () public NBTTagCompound getUpdateTag ()
{ {
@ -224,7 +228,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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -21,9 +21,9 @@ import net.minecraft.command.ICommandManager;
import net.minecraft.command.ICommandSender; import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
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 +61,7 @@ public class CommandAPI implements ILuaAPI
{ {
} }
@Nonnull
@Override @Override
public String[] getMethodNames() public String[] getMethodNames()
{ {
@ -111,7 +112,7 @@ public class CommandAPI implements ILuaAPI
// Get the details of the block // Get the details of the block
IBlockState state = world.getBlockState( pos ); IBlockState state = world.getBlockState( pos );
Block block = state.getBlock(); Block block = state.getBlock();
String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString(); String name = Block.REGISTRY.getNameForObject( block ).toString();
int metadata = block.getMetaFromState( state ); int metadata = block.getMetaFromState( state );
Map<Object, Object> table = new HashMap<Object, Object>(); Map<Object, Object> table = new HashMap<Object, Object>();
@ -119,9 +120,8 @@ public class CommandAPI implements ILuaAPI
table.put( "metadata", metadata ); table.put( "metadata", metadata );
Map<Object, Object> stateTable = new HashMap<Object, Object>(); Map<Object, Object> stateTable = new HashMap<Object, Object>();
for( Object o : state.getActualState( world, pos ).getProperties().entrySet() ) for( ImmutableMap.Entry<IProperty<?>, Comparable<?>> entry : state.getActualState( world, pos ).getProperties().entrySet() )
{ {
ImmutableMap.Entry<IProperty, Object> entry = (ImmutableMap.Entry<IProperty, Object>)o;
String propertyName = entry.getKey().getName(); String propertyName = entry.getKey().getName();
Object value = entry.getValue(); Object value = entry.getValue();
if( value instanceof String || value instanceof Number || value instanceof Boolean ) if( value instanceof String || value instanceof Number || value instanceof Boolean )
@ -139,7 +139,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 )
{ {
@ -193,12 +193,11 @@ public class CommandAPI implements ILuaAPI
{ {
ICommandManager commandManager = server.getCommandManager(); ICommandManager commandManager = server.getCommandManager();
ICommandSender commmandSender = m_computer.getCommandSender(); ICommandSender commmandSender = m_computer.getCommandSender();
Map commands = commandManager.getCommands(); Map<String, ICommand> commands = commandManager.getCommands();
for( Object entryObject : commands.entrySet() ) for( Map.Entry<String, ICommand> entry : commands.entrySet() )
{ {
Map.Entry entry = (Map.Entry)entryObject; String name = entry.getKey();
String name = (String)entry.getKey(); ICommand command = entry.getValue();
ICommand command = (ICommand)entry.getValue();
try try
{ {
if( command.checkPermission( server, commmandSender ) ) if( command.checkPermission( server, commmandSender ) )

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -9,10 +9,8 @@ package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.IComputer; import dan200.computercraft.shared.computer.core.IComputer;
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
@ -25,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 BlockCommandComputer extends BlockComputerBase public class BlockCommandComputer extends BlockComputerBase
{ {
// Statics // Statics
@ -32,7 +32,7 @@ public class BlockCommandComputer extends BlockComputerBase
public static class Properties public static class Properties
{ {
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class); public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class);
} }
// Members // Members
@ -50,16 +50,16 @@ public class BlockCommandComputer extends BlockComputerBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
return new BlockStateContainer(this, new IProperty[] { return new BlockStateContainer(this, Properties.FACING, Properties.STATE );
Properties.FACING,
Properties.STATE
});
} }
@Nonnull
@Override @Override
@Deprecated
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
EnumFacing dir = EnumFacing.getFront( meta & 0x7 ); EnumFacing dir = EnumFacing.getFront( meta & 0x7 );
@ -73,11 +73,13 @@ public class BlockCommandComputer extends BlockComputerBase
@Override @Override
public int getMetaFromState( IBlockState state ) public int getMetaFromState( IBlockState state )
{ {
return ((EnumFacing)state.getValue( Properties.FACING )).getIndex(); return state.getValue( Properties.FACING ).getIndex();
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) @Deprecated
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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -12,7 +12,6 @@ import dan200.computercraft.shared.computer.core.IComputer;
import dan200.computercraft.shared.computer.items.ItemComputer; import dan200.computercraft.shared.computer.items.ItemComputer;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
@ -22,11 +21,13 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
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;
public class BlockComputer extends BlockComputerBase public class BlockComputer extends BlockComputerBase
{ {
// Statics // Statics
@ -34,7 +35,7 @@ public class BlockComputer extends BlockComputerBase
{ {
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool ADVANCED = PropertyBool.create("advanced"); public static final PropertyBool ADVANCED = PropertyBool.create("advanced");
public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class); public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class);
} }
// Members // Members
@ -52,17 +53,16 @@ public class BlockComputer extends BlockComputerBase
); );
} }
@Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()
{ {
return new BlockStateContainer(this, new IProperty[] { return new BlockStateContainer( this, Properties.FACING, Properties.ADVANCED, Properties.STATE );
Properties.FACING,
Properties.ADVANCED,
Properties.STATE
});
} }
@Nonnull
@Override @Override
@Deprecated
public IBlockState getStateFromMeta( int meta ) public IBlockState getStateFromMeta( int meta )
{ {
EnumFacing dir = EnumFacing.getFront( meta & 0x7 ); EnumFacing dir = EnumFacing.getFront( meta & 0x7 );
@ -86,8 +86,8 @@ public class BlockComputer extends BlockComputerBase
@Override @Override
public int getMetaFromState( IBlockState state ) public int getMetaFromState( IBlockState state )
{ {
int meta = ((EnumFacing)state.getValue( Properties.FACING )).getIndex(); int meta = state.getValue( Properties.FACING ).getIndex();
if( (Boolean)state.getValue( Properties.ADVANCED ) ) if( state.getValue( Properties.ADVANCED ) )
{ {
meta += 8; meta += 8;
} }
@ -117,8 +117,10 @@ public class BlockComputer extends BlockComputerBase
} }
} }
@Nonnull
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) @Deprecated
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 )
@ -148,7 +150,7 @@ public class BlockComputer extends BlockComputerBase
@Override @Override
public ComputerFamily getFamily( IBlockState state ) public ComputerFamily getFamily( IBlockState state )
{ {
if( (Boolean)state.getValue( Properties.ADVANCED ) ) { if( state.getValue( Properties.ADVANCED ) ) {
return ComputerFamily.Advanced; return ComputerFamily.Advanced;
} else { } else {
return ComputerFamily.Normal; return ComputerFamily.Normal;

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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" ),
@ -16,11 +18,12 @@ public enum ComputerState implements IStringSerializable
private String m_name; private String m_name;
private ComputerState( String name ) ComputerState( String name )
{ {
m_name = name; m_name = name;
} }
@Nonnull
@Override @Override
public String getName() public String getName()
{ {

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -12,9 +12,9 @@ import dan200.computercraft.shared.computer.core.IComputer;
public interface IComputerTile extends ITerminalTile public interface IComputerTile extends ITerminalTile
{ {
public void setComputerID( int id ); void setComputerID( int id );
public void setLabel( String label ); void setLabel( String label );
public IComputer getComputer(); IComputer getComputer();
public IComputer createComputer(); IComputer createComputer();
public ComputerFamily getFamily(); ComputerFamily getFamily();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -21,7 +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.Nullable; import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -53,6 +53,7 @@ public class TileCommandComputer extends TileComputer
// ICommandSender // ICommandSender
@Nonnull
@Override @Override
public ITextComponent getDisplayName() public ITextComponent getDisplayName()
{ {
@ -69,7 +70,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 +81,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 +96,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 +130,7 @@ public class TileCommandComputer extends TileComputer
} }
@Override @Override
public void fillInInfo( ByteBuf buf ) public void fillInInfo( @Nonnull ByteBuf buf )
{ {
} }
} }
@ -142,7 +146,7 @@ public class TileCommandComputer extends TileComputer
public EnumFacing getDirection() public EnumFacing getDirection()
{ {
IBlockState state = getBlockState(); IBlockState state = getBlockState();
return (EnumFacing)state.getValue( BlockCommandComputer.Properties.FACING ); return state.getValue( BlockCommandComputer.Properties.FACING );
} }
@Override @Override

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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();
@ -86,7 +87,7 @@ public class TileComputer extends TileComputerBase
public EnumFacing getDirection() public EnumFacing getDirection()
{ {
IBlockState state = getBlockState(); IBlockState state = getBlockState();
return (EnumFacing)state.getValue( BlockComputer.Properties.FACING ); return state.getValue( BlockComputer.Properties.FACING );
} }
@Override @Override

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -10,16 +10,16 @@ import dan200.computercraft.shared.common.ITerminal;
public interface IComputer extends ITerminal public interface IComputer extends ITerminal
{ {
public int getInstanceID(); int getInstanceID();
public int getID(); int getID();
public String getLabel(); String getLabel();
public boolean isOn(); boolean isOn();
public boolean isCursorDisplayed(); boolean isCursorDisplayed();
public void turnOn(); void turnOn();
public void shutdown(); void shutdown();
public void reboot(); void reboot();
public void queueEvent( String event ); void queueEvent( String event );
public void queueEvent( String event, Object[] arguments ); void queueEvent( String event, Object[] arguments );
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -8,5 +8,5 @@ package dan200.computercraft.shared.computer.core;
public interface IComputerContainer public interface IComputerContainer
{ {
public IComputer getComputer(); IComputer getComputer();
} }

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

View File

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
@ -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

@ -1,4 +1,4 @@
/** /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com

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