Add a little bit of source code checking to Gradle

- Adds a CheckStyle configuration which is pretty similar to CC's
   existing one.
 - Add the Gradle license plugin.
 - Ensure the existing source code is compatible with these additional
   checks.

See #239
This commit is contained in:
SquidDev 2019-06-08 00:28:03 +01:00
parent 7d428030df
commit a0e7c4a74c
54 changed files with 349 additions and 143 deletions

View File

@ -17,7 +17,9 @@
} }
plugins { plugins {
id 'com.matthewprenger.cursegradle' version '1.2.0' id "checkstyle"
id "com.github.hierynomus.license" version "0.15.0"
id "com.matthewprenger.cursegradle" version "1.3.0"
id "com.github.breadmoirai.github-release" version "2.2.4" id "com.github.breadmoirai.github-release" version "2.2.4"
} }
@ -66,6 +68,8 @@
} }
dependencies { dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.21"
deobfProvided "mezz.jei:jei_1.12.2:4.15.0.269:api" deobfProvided "mezz.jei:jei_1.12.2:4.15.0.269:api"
deobfProvided "pl.asie:Charset-Lib:0.5.4.6" deobfProvided "pl.asie:Charset-Lib:0.5.4.6"
deobfProvided "MCMultiPart2:MCMultiPart:2.5.3" deobfProvided "MCMultiPart2:MCMultiPart:2.5.3"
@ -104,6 +108,8 @@
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import com.google.gson.JsonElement import com.google.gson.JsonElement
import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat
import org.ajoberstar.grgit.Grgit import org.ajoberstar.grgit.Grgit
import proguard.gradle.ProGuardTask import proguard.gradle.ProGuardTask
@ -227,6 +233,42 @@ task compressJson(dependsOn: extractAnnotationsJar) {
assemble.dependsOn compressJson assemble.dependsOn compressJson
/* Check tasks */
license {
mapping("java", "SLASHSTAR_STYLE")
strictCheck true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
[licenseMain, licenseFormatMain].forEach {
it.configure {
include("**/*.java")
exclude("dan200/computercraft/api/**")
header rootProject.file('config/license/main.txt')
}
}
[licenseTest, licenseFormatTest].forEach {
it.configure {
include("**/*.java")
header rootProject.file('config/license/main.txt')
}
}
task licenseAPI(type: LicenseCheck);
task licenseFormatAPI(type: LicenseFormat);
[licenseAPI, licenseFormatAPI].forEach {
it.configure {
source = sourceSets.main.java
include("dan200/computercraft/api/**")
header rootProject.file('config/license/api.txt')
}
}
/* Upload tasks */
task checkRelease { task checkRelease {
group "upload" group "upload"
description "Verifies that everything is ready for a release" description "Verifies that everything is ready for a release"
@ -266,7 +308,6 @@ task compressJson(dependsOn: extractAnnotationsJar) {
} }
} }
curseforge { curseforge {
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : '' apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
project { project {
@ -369,6 +410,10 @@ task uploadAll(dependsOn: uploadTasks) {
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint" << "-Xlint:-processing" << "-Werror" options.compilerArgs << "-Xlint" << "-Xlint:-processing" << "-Werror"
} }
tasks.withType(LicenseFormat) {
outputs.upToDateWhen { false }
}
} }
runClient.outputs.upToDateWhen { false } runClient.outputs.upToDateWhen { false }

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="tabWidth" value="4"/>
<property name="charset" value="UTF-8" />
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml" />
</module>
<module name="TreeWalker">
<!-- Annotations -->
<module name="AnnotationLocation" />
<module name="AnnotationUseStyle" />
<module name="MissingDeprecated">
<property name="skipNoJavadoc" value="true" />
</module>
<module name="MissingOverride" />
<!-- Blocks -->
<module name="EmptyBlock" />
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="ignored" />
</module>
<module name="LeftCurly">
<property name="option" value="nl" />
<!-- The defaults, minus lambdas. -->
<property name="tokens" value="ANNOTATION_DEF,CLASS_DEF,CTOR_DEF,ENUM_CONSTANT_DEF,ENUM_DEF,INTERFACE_DEF,LITERAL_CASE,LITERAL_CATCH,LITERAL_DEFAULT,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,METHOD_DEF,OBJBLOCK,STATIC_INIT" />
</module>
<module name="NeedBraces">
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="RightCurly">
<property name="option" value="alone" />
</module>
<!-- Class design. As if we've ever followed good practice here. -->
<module name="FinalClass" />
<module name="InterfaceIsType" />
<module name="MutableException" />
<module name="OneTopLevelClass" />
<!-- Coding -->
<module name="ArrayTrailingComma" />
<module name="EqualsHashCode" />
<!-- FallThrough does not handle unreachable code well -->
<module name="IllegalInstantiation" />
<module name="IllegalThrows" />
<module name="ModifiedControlVariable" />
<module name="NoClone" />
<module name="NoFinalizer" />
<module name="OneStatementPerLine" />
<module name="PackageDeclaration" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="UnnecessaryParentheses" />
<!-- Imports -->
<module name="CustomImportOrder" />
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />
<!-- Javadoc -->
<module name="AtclauseOrder" />
<!-- TODO: Cleanup our documentation before enabling JavadocMethod, JavadocStyle, JavadocType and SummaryJavadoc. -->
<module name="NonEmptyAtclauseDescription" />
<module name="SingleLineJavadoc" />
<!-- Misc -->
<module name="ArrayTypeStyle" />
<module name="CommentsIndentation" />
<module name="Indentation" />
<module name="OuterTypeFilename" />
<!-- Modifiers -->
<module name="ModifierOrder" />
<module name="RedundantModifier" />
<!-- Naming -->
<module name="ClassTypeParameterName" />
<module name="InterfaceTypeParameterName" />
<module name="LambdaParameterName" />
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<!-- Allow an optional m_ on private members -->
<module name="MemberName">
<property name="applyToPrivate" value="false" />
<property name="applyToPackage" value="false" />
</module>
<module name="MemberName">
<property name="format" value="^(m_)?[a-z][a-zA-Z0-9]*$" />
<property name="applyToPrivate" value="true" />
<property name="applyToPackage" value="true" />
</module>
<module name="MethodName" />
<module name="MethodTypeParameterName" />
<module name="PackageName">
<property name="format" value="^dan200\.computercraf(\.[a-z][a-z0-9]*)*" />
</module>
<module name="ParameterName" />
<module name="StaticVariableName">
<property name="format" value="^[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z]+)?$" />
<property name="applyToPrivate" value="false" />
</module>
<module name="StaticVariableName">
<property name="format" value="^(s_)?[a-z][a-zA-Z0-9]*|CAPABILITY(_[A-Z]+)?$" />
<property name="applyToPrivate" value="true" />
</module>
<module name="TypeName" />
<!-- Whitespace -->
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad">
<property name="option" value="space"/>
</module>
<module name="GenericWhitespace" />
<module name="MethodParamPad" />
<module name="NoLineWrap" />
<module name="NoWhitespaceAfter">
<property name="tokens" value="AT,INC,DEC,UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP" />
</module>
<module name="NoWhitespaceBefore" />
<!-- TODO: Decide on an OperatorWrap style. -->
<module name="ParenPad">
<property name="option" value="space" />
<property name="tokens" value="ANNOTATION,ANNOTATION_FIELD_DEF,CTOR_CALL,CTOR_DEF,ENUM_CONSTANT_DEF,LITERAL_CATCH,LITERAL_DO,LITERAL_FOR,LITERAL_IF,LITERAL_NEW,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_WHILE,METHOD_CALL,METHOD_DEF,RESOURCE_SPECIFICATION,SUPER_CTOR_CALL,LAMBDA" />
</module>
<module name="ParenPad">
<property name="option" value="nospace" />
<property name="tokens" value="DOT,EXPR,QUESTION" />
</module>
<module name="SeparatorWrap">
<property name="option" value="eol" />
<property name="tokens" value="COMMA,SEMI,ELLIPSIS,ARRAY_DECLARATOR,RBRACK,METHOD_REF" />
</module>
<module name="SeparatorWrap">
<property name="option" value="nl" />
<property name="tokens" value="DOT,AT" />
</module>
<module name="SingleSpaceSeparator" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA" />
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true" />
<property name="ignoreEnhancedForColon" value="false" />
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_RETURN,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND" />
</module>
</module>
<module name="FileTabCharacter" />
<module name="NewlineAtEndOfFile" />
</module>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- Has a public m_label field. We need to check if this is used in other projects before renaming it. -->
<suppress checks="MemberName" files=".*[\\/]TileComputerBase.java"
message="Name 'm_label' must match pattern .*" />
<!-- All the config options and method fields. -->
<suppress checks="StaticVariableName" files=".*[\\/]ComputerCraft.java" />
<suppress checks="StaticVariableName" files=".*[\\/]ComputerCraftAPI.java" />
</suppressions>

3
config/license/api.txt Normal file
View File

@ -0,0 +1,3 @@
This file is part of the public ComputerCraft API - http://www.computercraft.info
Copyright Daniel Ratcliffe, 2011-${year}. This API may be redistributed unmodified and in full only.
For help using the API, and posting your mods, visit the forums at computercraft.info.

3
config/license/main.txt Normal file
View File

@ -0,0 +1,3 @@
This file is part of ComputerCraft - http://www.computercraft.info
Copyright Daniel Ratcliffe, 2011-${year}. Do not distribute without permission.
Send enquiries to dratcliffe@gmail.com

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api; package dan200.computercraft.api;
import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade;

View File

@ -438,45 +438,45 @@ private static void findCC()
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,
} ); } );
computerCraft_getWirelessNetwork = findCCMethod( "getWirelessNetwork", new Class<?>[] { computerCraft_getWirelessNetwork = findCCMethod( "getWirelessNetwork", new Class<?>[] {
} ); } );
computerCraft_registerAPIFactory = findCCMethod( "registerAPIFactory", new Class<?>[] { computerCraft_registerAPIFactory = findCCMethod( "registerAPIFactory", new Class<?>[] {
ILuaAPIFactory.class ILuaAPIFactory.class,
} ); } );
computerCraft_createWiredNodeForElement = findCCMethod( "createWiredNodeForElement", new Class<?>[] { computerCraft_createWiredNodeForElement = findCCMethod( "createWiredNodeForElement", new Class<?>[] {
IWiredElement.class IWiredElement.class,
} ); } );
computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] { computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] {
IBlockAccess.class, BlockPos.class, EnumFacing.class IBlockAccess.class, BlockPos.class, EnumFacing.class,
} ); } );
} }
catch( Exception e ) catch( Exception e )

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.filesystem; package dan200.computercraft.api.filesystem;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -20,7 +19,7 @@ public class FileOperationException extends IOException
{ {
private static final long serialVersionUID = -8809108200853029849L; private static final long serialVersionUID = -8809108200853029849L;
private String filename; private final String filename;
public FileOperationException( @Nullable String filename, @Nonnull String message ) public FileOperationException( @Nullable String filename, @Nonnull String message )
{ {
@ -31,6 +30,7 @@ public FileOperationException( @Nullable String filename, @Nonnull String messag
public FileOperationException( String message ) public FileOperationException( String message )
{ {
super( Objects.requireNonNull( message, "message cannot be null" ) ); super( Objects.requireNonNull( message, "message cannot be null" ) );
this.filename = null;
} }
@Nullable @Nullable

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.peripheral; package dan200.computercraft.api.peripheral;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.pocket; package dan200.computercraft.api.pocket;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only.
* Send enquiries to dratcliffe@gmail.com * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;

View File

@ -120,7 +120,7 @@ protected void drawSelectionSlot( boolean advanced )
int slotX = slot % 4; int slotX = slot % 4;
int slotY = slot / 4; int slotY = slot / 4;
mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
drawTexturedModalRect( guiLeft + m_container.m_turtleInvStartX - 2 + slotX * 18, guiTop + m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 ); drawTexturedModalRect( guiLeft + m_container.turtleInvStartX - 2 + slotX * 18, guiTop + m_container.playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24 );
} }
} }

View File

@ -94,7 +94,7 @@ private static class NormalAwareTransformer extends VertexTransformer
private final Point3f[] before = new Point3f[4]; private final Point3f[] before = new Point3f[4];
private final Point3f[] after = new Point3f[4]; private final Point3f[] after = new Point3f[4];
public NormalAwareTransformer( IVertexConsumer parent, Matrix4f positionMatrix, Matrix4f normalMatrix ) NormalAwareTransformer( IVertexConsumer parent, Matrix4f positionMatrix, Matrix4f normalMatrix )
{ {
super( parent ); super( parent );
this.positionMatrix = positionMatrix; this.positionMatrix = positionMatrix;

View File

@ -43,9 +43,7 @@ public FSAPI( IAPIEnvironment env )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "fs" };
"fs"
};
} }
@Override @Override

View File

@ -42,9 +42,7 @@ public HTTPAPI( IAPIEnvironment environment )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "http" };
"http"
};
} }
@Override @Override

View File

@ -10,6 +10,7 @@
* This exists purely to ensure binary compatibility. * This exists purely to ensure binary compatibility.
* *
* @see dan200.computercraft.api.lua.ILuaAPI * @see dan200.computercraft.api.lua.ILuaAPI
* @deprecated Use the version in the public API. Only exists for compatibility with CCEmuX.
*/ */
@Deprecated @Deprecated
public interface ILuaAPI extends dan200.computercraft.api.lua.ILuaAPI public interface ILuaAPI extends dan200.computercraft.api.lua.ILuaAPI

View File

@ -36,9 +36,9 @@ public class OSAPI implements ILuaAPI
private static class Timer private static class Timer
{ {
public int m_ticksLeft; int m_ticksLeft;
public Timer( int ticksLeft ) Timer( int ticksLeft )
{ {
m_ticksLeft = ticksLeft; m_ticksLeft = ticksLeft;
} }
@ -46,10 +46,10 @@ public Timer( int ticksLeft )
private static class Alarm implements Comparable<Alarm> private static class Alarm implements Comparable<Alarm>
{ {
public final double m_time; final double m_time;
public final int m_day; final int m_day;
public Alarm( double time, int day ) Alarm( double time, int day )
{ {
m_time = time; m_time = time;
m_day = day; m_day = day;
@ -78,9 +78,7 @@ public OSAPI( IAPIEnvironment environment )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "os" };
"os"
};
} }
@Override @Override
@ -385,9 +383,7 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
// Get in-game epoch // Get in-game epoch
synchronized( m_alarms ) synchronized( m_alarms )
{ {
return new Object[] { return new Object[] { m_day * 86400000 + (int) (m_time * 3600000.0f) };
m_day * 86400000 + (int) (m_time * 3600000.0f)
};
} }
default: default:
throw new LuaException( "Unsupported operation" ); throw new LuaException( "Unsupported operation" );

View File

@ -36,7 +36,7 @@ private class PeripheralWrapper extends ComputerAccess
private Map<String, Integer> m_methodMap; private Map<String, Integer> m_methodMap;
private boolean m_attached; private boolean m_attached;
public PeripheralWrapper( IPeripheral peripheral, String side ) PeripheralWrapper( IPeripheral peripheral, String side )
{ {
super( m_environment ); super( m_environment );
m_side = side; m_side = side;
@ -282,9 +282,7 @@ public void onPeripheralChanged( ComputerSide side, IPeripheral newPeripheral )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "peripheral" };
"peripheral"
};
} }
@Override @Override
@ -326,7 +324,7 @@ public String[] getMethodNames()
"isPresent", "isPresent",
"getType", "getType",
"getMethods", "getMethods",
"call" "call",
}; };
} }

View File

@ -29,9 +29,7 @@ public RedstoneAPI( IAPIEnvironment environment )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "rs", "redstone" };
"rs", "redstone"
};
} }
@Nonnull @Nonnull

View File

@ -33,9 +33,7 @@ public TermAPI( IAPIEnvironment environment )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "term" };
"term"
};
} }
@Nonnull @Nonnull
@ -89,9 +87,7 @@ public static int parseColour( Object[] args ) throws LuaException
public static Object[] encodeColour( int colour ) throws LuaException public static Object[] encodeColour( int colour ) throws LuaException
{ {
return new Object[] { return new Object[] { 1 << colour };
1 << colour
};
} }
public static void setColour( Terminal terminal, int colour, double r, double g, double b ) public static void setColour( Terminal terminal, int colour, double r, double g, double b )

View File

@ -72,7 +72,8 @@ protected final boolean tryClose()
*/ */
protected void dispose() protected void dispose()
{ {
@SuppressWarnings( "unchecked" ) T thisT = (T) this; @SuppressWarnings( "unchecked" )
T thisT = (T) this;
limiter.release( thisT ); limiter.release( thisT );
} }
@ -95,7 +96,8 @@ public final void close()
public boolean queue( Consumer<T> task ) public boolean queue( Consumer<T> task )
{ {
@SuppressWarnings( "unchecked" ) T thisT = (T) this; @SuppressWarnings( "unchecked" )
T thisT = (T) this;
return limiter.queue( thisT, () -> task.accept( thisT ) ); return limiter.queue( thisT, () -> task.accept( thisT ) );
} }

View File

@ -30,7 +30,10 @@ public enum ComputerSide
private final String name; private final String name;
ComputerSide( String name ) {this.name = name;} ComputerSide( String name )
{
this.name = name;
}
@Nonnull @Nonnull
public static ComputerSide valueOf( int side ) public static ComputerSide valueOf( int side )

View File

@ -46,7 +46,7 @@ private static class MountWrapper
m_writableMount = null; m_writableMount = null;
} }
public MountWrapper( String label, String location, IWritableMount mount ) MountWrapper( String label, String location, IWritableMount mount )
{ {
this( label, location, (IMount) mount ); this( label, location, (IMount) mount );
m_writableMount = mount; m_writableMount = mount;
@ -779,7 +779,7 @@ private static String sanitizePath( String path, boolean allowWildcards )
// Clean the path or illegal characters. // Clean the path or illegal characters.
final char[] specialChars = new char[] { final char[] specialChars = new char[] {
'"', ':', '<', '>', '?', '|' // Sorted by ascii value (important) '"', ':', '<', '>', '?', '|', // Sorted by ascii value (important)
}; };
StringBuilder cleanName = new StringBuilder(); StringBuilder cleanName = new StringBuilder();

View File

@ -550,7 +550,7 @@ public long issueMainThreadTask( @Nonnull final ILuaTask task ) throws LuaExcept
{ {
if( ComputerCraft.logPeripheralErrors ) ComputerCraft.log.error( "Error running task", t ); if( ComputerCraft.logPeripheralErrors ) ComputerCraft.log.error( "Error running task", t );
m_computer.queueEvent( "task_complete", new Object[] { m_computer.queueEvent( "task_complete", new Object[] {
taskID, false, "Java Exception Thrown: " + t taskID, false, "Java Exception Thrown: " + t,
} ); } );
} }
}; };

View File

@ -8,7 +8,7 @@
public class TextBuffer public class TextBuffer
{ {
public char[] m_text; private final char[] m_text;
public TextBuffer( char c, int length ) public TextBuffer( char c, int length )
{ {

View File

@ -47,9 +47,7 @@ public CommandAPI( TileCommandComputer computer )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "commands" };
"commands"
};
} }
@Nonnull @Nonnull
@ -62,7 +60,7 @@ public String[] getMethodNames()
"list", "list",
"getBlockPosition", "getBlockPosition",
"getBlockInfos", "getBlockInfos",
"getBlockInfo" "getBlockInfo",
}; };
} }

View File

@ -11,9 +11,9 @@
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
public class ComputerRegistry<TComputer extends IComputer> public class ComputerRegistry<T extends IComputer>
{ {
private Map<Integer, TComputer> m_computers; private Map<Integer, T> m_computers;
private int m_nextUnusedInstanceID; private int m_nextUnusedInstanceID;
private int m_sessionID; private int m_sessionID;
@ -33,12 +33,12 @@ public int getUnusedInstanceID()
return m_nextUnusedInstanceID++; return m_nextUnusedInstanceID++;
} }
public Collection<TComputer> getComputers() public Collection<T> getComputers()
{ {
return m_computers.values(); return m_computers.values();
} }
public TComputer get( int instanceID ) public T get( int instanceID )
{ {
if( instanceID >= 0 ) if( instanceID >= 0 )
{ {
@ -55,7 +55,7 @@ public boolean contains( int instanceID )
return m_computers.containsKey( instanceID ); return m_computers.containsKey( instanceID );
} }
public void add( int instanceID, TComputer computer ) public void add( int instanceID, T computer )
{ {
if( m_computers.containsKey( instanceID ) ) if( m_computers.containsKey( instanceID ) )
{ {

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.shared.integration.charset; package dan200.computercraft.shared.integration.charset;
import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.common.TileGeneric;

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.shared.integration.charset; package dan200.computercraft.shared.integration.charset;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider; import dan200.computercraft.api.redstone.IBundledRedstoneProvider;

View File

@ -1,9 +1,8 @@
/* /*
* This file is part of ComputerCraft - http://www.computercraft.info * This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.shared.integration.charset; package dan200.computercraft.shared.integration.charset;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;

View File

@ -39,5 +39,8 @@ public String getName()
} }
@Override @Override
public String toString() { return name; } public String toString()
{
return name;
}
} }

View File

@ -52,7 +52,7 @@ public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaCont
{ {
case 0: // getCommand case 0: // getCommand
return context.executeMainThreadTask( () -> new Object[] { return context.executeMainThreadTask( () -> new Object[] {
m_commandBlock.getCommandBlockLogic().getCommand() m_commandBlock.getCommandBlockLogic().getCommand(),
} ); } );
case 1: case 1:
{ {

View File

@ -51,7 +51,7 @@ public String[] getMethodNames()
"playAudio", "playAudio",
"stopAudio", "stopAudio",
"ejectDisk", "ejectDisk",
"getDiskID" "getDiskID",
}; };
} }

View File

@ -87,7 +87,7 @@ public void receiveSameDimension( @Nonnull Packet packet, double distance )
for( IComputerAccess computer : m_computers ) for( IComputerAccess computer : m_computers )
{ {
computer.queueEvent( "modem_message", new Object[] { computer.queueEvent( "modem_message", new Object[] {
computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload(), distance computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload(), distance,
} ); } );
} }
} }
@ -103,7 +103,7 @@ public void receiveDifferentDimension( @Nonnull Packet packet )
for( IComputerAccess computer : m_computers ) for( IComputerAccess computer : m_computers )
{ {
computer.queueEvent( "modem_message", new Object[] { computer.queueEvent( "modem_message", new Object[] {
computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload() computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload(),
} ); } );
} }
} }

View File

@ -277,7 +277,7 @@ private static class RemotePeripheralWrapper implements IComputerAccess
private final String[] m_methods; private final String[] m_methods;
private final Map<String, Integer> m_methodMap; private final Map<String, Integer> m_methodMap;
public RemotePeripheralWrapper( WiredModemElement element, IPeripheral peripheral, IComputerAccess computer, String name ) RemotePeripheralWrapper( WiredModemElement element, IPeripheral peripheral, IComputerAccess computer, String name )
{ {
m_element = element; m_element = element;
m_peripheral = peripheral; m_peripheral = peripheral;

View File

@ -142,7 +142,7 @@ public void updateTick()
for( IComputerAccess computer : monitor.m_computers ) for( IComputerAccess computer : monitor.m_computers )
{ {
computer.queueEvent( "monitor_resize", new Object[] { computer.queueEvent( "monitor_resize", new Object[] {
computer.getAttachmentName() computer.getAttachmentName(),
} ); } );
} }
} }
@ -660,7 +660,7 @@ public void monitorTouched( float xPos, float yPos, float zPos )
for( IComputerAccess computer : monitor.m_computers ) for( IComputerAccess computer : monitor.m_computers )
{ {
computer.queueEvent( "monitor_touch", new Object[] { computer.queueEvent( "monitor_touch", new Object[] {
computer.getAttachmentName(), xCharPos, yCharPos computer.getAttachmentName(), xCharPos, yCharPos,
} ); } );
} }
} }

View File

@ -71,8 +71,8 @@ public String getType()
public String[] getMethodNames() public String[] getMethodNames()
{ {
return new String[] { return new String[] {
"playSound", // Plays sound at resourceLocator "playSound",
"playNote" // Plays note "playNote",
}; };
} }

View File

@ -35,9 +35,7 @@ public PocketAPI( PocketServerComputer computer )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "pocket" };
"pocket"
};
} }
@Nonnull @Nonnull
@ -46,7 +44,7 @@ public String[] getMethodNames()
{ {
return new String[] { return new String[] {
"equipBack", "equipBack",
"unequipBack" "unequipBack",
}; };
} }

View File

@ -45,9 +45,7 @@ public TurtleAPI( IAPIEnvironment environment, ITurtleAccess turtle )
@Override @Override
public String[] getNames() public String[] getNames()
{ {
return new String[] { return new String[] { "turtle" };
"turtle"
};
} }
@Nonnull @Nonnull

View File

@ -908,14 +908,14 @@ private void updateCommands()
else else
{ {
computer.queueEvent( "turtle_response", new Object[] { computer.queueEvent( "turtle_response", new Object[] {
callbackID, true callbackID, true,
} ); } );
} }
} }
else else
{ {
computer.queueEvent( "turtle_response", new Object[] { computer.queueEvent( "turtle_response", new Object[] {
callbackID, false, result != null ? result.getErrorMessage() : null callbackID, false, result != null ? result.getErrorMessage() : null,
} ); } );
} }
} }

View File

@ -26,8 +26,8 @@ public class ContainerTurtle extends Container implements IContainerComputer
{ {
private static final int PROGRESS_ID_SELECTED_SLOT = 0; private static final int PROGRESS_ID_SELECTED_SLOT = 0;
public final int m_playerInvStartY; public final int playerInvStartY;
public final int m_turtleInvStartX; public final int turtleInvStartX;
private final ITurtleAccess m_turtle; private final ITurtleAccess m_turtle;
private IComputer m_computer; private IComputer m_computer;
@ -36,8 +36,8 @@ public class ContainerTurtle extends Container implements IContainerComputer
protected ContainerTurtle( IInventory playerInventory, ITurtleAccess turtle, int playerInvStartY, int turtleInvStartX ) protected ContainerTurtle( IInventory playerInventory, ITurtleAccess turtle, int playerInvStartY, int turtleInvStartX )
{ {
m_playerInvStartY = playerInvStartY; this.playerInvStartY = playerInvStartY;
m_turtleInvStartX = turtleInvStartX; this.turtleInvStartX = turtleInvStartX;
m_turtle = turtle; m_turtle = turtle;
m_selectedSlot = m_turtle.getWorld().isRemote ? 0 : m_turtle.getSelectedSlot(); m_selectedSlot = m_turtle.getWorld().isRemote ? 0 : m_turtle.getSelectedSlot();

View File

@ -73,7 +73,10 @@ public int getColour( @Nonnull ItemStack stack )
} }
@Override @Override
public ResourceLocation getOverlay( @Nonnull ItemStack stack ) { return null; } public ResourceLocation getOverlay( @Nonnull ItemStack stack )
{
return null;
}
@Override @Override
public int getFuelLevel( @Nonnull ItemStack stack ) public int getFuelLevel( @Nonnull ItemStack stack )

View File

@ -54,7 +54,7 @@ public TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull Turt
{ {
if( verb == TurtleVerb.Dig ) if( verb == TurtleVerb.Dig )
{ {
ItemStack hoe = m_item.copy(); ItemStack hoe = item.copy();
ItemStack remainder = TurtlePlaceCommand.deploy( hoe, turtle, direction, null, null ); ItemStack remainder = TurtlePlaceCommand.deploy( hoe, turtle, direction, null, null );
if( remainder != hoe ) if( remainder != hoe )
{ {

View File

@ -60,7 +60,7 @@ public TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull Turt
{ {
if( verb == TurtleVerb.Dig ) if( verb == TurtleVerb.Dig )
{ {
ItemStack shovel = m_item.copy(); ItemStack shovel = item.copy();
ItemStack remainder = TurtlePlaceCommand.deploy( shovel, turtle, direction, null, null ); ItemStack remainder = TurtlePlaceCommand.deploy( shovel, turtle, direction, null, null );
if( remainder != shovel ) if( remainder != shovel )
{ {

View File

@ -48,18 +48,18 @@
public class TurtleTool extends AbstractTurtleUpgrade public class TurtleTool extends AbstractTurtleUpgrade
{ {
protected ItemStack m_item; protected final ItemStack item;
public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item item ) public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item item )
{ {
super( id, legacyID, TurtleUpgradeType.Tool, adjective, item ); super( id, legacyID, TurtleUpgradeType.Tool, adjective, item );
m_item = new ItemStack( item, 1, 0 ); this.item = new ItemStack( item, 1, 0 );
} }
public TurtleTool( ResourceLocation id, int legacyID, Item item ) public TurtleTool( ResourceLocation id, int legacyID, Item item )
{ {
super( id, legacyID, TurtleUpgradeType.Tool, item ); super( id, legacyID, TurtleUpgradeType.Tool, item );
m_item = new ItemStack( item, 1, 0 ); this.item = new ItemStack( item, 1, 0 );
} }
@Nonnull @Nonnull
@ -76,7 +76,7 @@ public Pair<IBakedModel, Matrix4f> getModel( ITurtleAccess turtle, @Nonnull Turt
); );
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
return Pair.of( return Pair.of(
mc.getRenderItem().getItemModelMesher().getItemModel( m_item ), mc.getRenderItem().getItemModelMesher().getItemModel( item ),
transform transform
); );
} }
@ -124,7 +124,7 @@ private TurtleCommandResult attack( final ITurtleAccess turtle, EnumFacing direc
if( hit != null ) if( hit != null )
{ {
// Load up the turtle's inventory // Load up the turtle's inventory
ItemStack stackCopy = m_item.copy(); ItemStack stackCopy = item.copy();
turtlePlayer.loadInventory( stackCopy ); turtlePlayer.loadInventory( stackCopy );
Entity hitEntity = hit.getKey(); Entity hitEntity = hit.getKey();
@ -202,7 +202,7 @@ private TurtleCommandResult dig( ITurtleAccess turtle, EnumFacing direction, Tur
IBlockState state = world.getBlockState( blockPosition ); IBlockState state = world.getBlockState( blockPosition );
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction ); TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction );
turtlePlayer.loadInventory( m_item.copy() ); turtlePlayer.loadInventory( item.copy() );
if( ComputerCraft.turtlesObeyBlockProtection ) if( ComputerCraft.turtlesObeyBlockProtection )
{ {

View File

@ -20,7 +20,7 @@ public final class ColourUtils
"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown",
"dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray",
"dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeGray", "dyePink", "dyeLime", "dyeYellow",
"dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite",
}; };
private static int[] ids; private static int[] ids;

View File

@ -72,12 +72,11 @@ public static int encodeRGB8( double[] rgb )
public static double[] decodeRGB8( int rgb ) public static double[] decodeRGB8( int rgb )
{ {
return new double[] return new double[] {
{ ((rgb >> 16) & 0xFF) / 255.0f,
((rgb >> 16) & 0xFF) / 255.0f, ((rgb >> 8) & 0xFF) / 255.0f,
((rgb >> 8) & 0xFF) / 255.0f, (rgb & 0xFF) / 255.0f,
(rgb & 0xFF) / 255.0f };
};
} }
public NBTTagCompound writeToNBT( NBTTagCompound nbt ) public NBTTagCompound writeToNBT( NBTTagCompound nbt )

View File

@ -35,6 +35,7 @@ public static String normaliseLabel( String label )
/** /**
* Translates a Stat name * Translates a Stat name
*/ */
@SuppressWarnings( "deprecation" )
public static String translate( String key ) public static String translate( String key )
{ {
return net.minecraft.util.text.translation.I18n.translateToLocal( key ); return net.minecraft.util.text.translation.I18n.translateToLocal( key );
@ -43,6 +44,7 @@ public static String translate( String key )
/** /**
* Translates a Stat name with format args * Translates a Stat name with format args
*/ */
@SuppressWarnings( "deprecation" )
public static String translateFormatted( String key, Object... format ) public static String translateFormatted( String key, Object... format )
{ {
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format ); return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format );

View File

@ -96,7 +96,7 @@ public InputStream createResourceFile( String domain, String subPath )
public static IMount createMount( Class<?> klass, String path, String fallback ) public static IMount createMount( Class<?> klass, String path, String fallback )
{ {
File file = getContainingFile(klass); File file = getContainingFile( klass );
if( file.isFile() ) if( file.isFile() )
{ {
@ -128,7 +128,7 @@ public static IMount createMount( Class<?> klass, String path, String fallback )
} }
private static File getContainingFile(Class<?> klass) private static File getContainingFile( Class<?> klass )
{ {
String path = klass.getProtectionDomain().getCodeSource().getLocation().getPath(); String path = klass.getProtectionDomain().getCodeSource().getLocation().getPath();
int bangIndex = path.indexOf( "!" ); int bangIndex = path.indexOf( "!" );

View File

@ -42,7 +42,7 @@ public static void run( String program )
.addFile( "test.lua", program ) .addFile( "test.lua", program )
.addFile( "startup", "assertion.assert(pcall(loadfile('test.lua', _ENV))) os.shutdown()" ); .addFile( "startup", "assertion.assert(pcall(loadfile('test.lua', _ENV))) os.shutdown()" );
run( mount, x -> {} ); run( mount, x -> { } );
} }
public static void run( IWritableMount mount, Consumer<Computer> setup ) public static void run( IWritableMount mount, Consumer<Computer> setup )

View File

@ -253,14 +253,14 @@ public void testRemoveSplit()
assertEquals( Sets.newHashSet(), cE.allPeripherals().keySet(), "C's peripheral set should be empty" ); assertEquals( Sets.newHashSet(), cE.allPeripherals().keySet(), "C's peripheral set should be empty" );
} }
private static final int BRUTE_SIZE = 16;
private static final int TOGGLE_CONNECTION_TIMES = 5;
private static final int TOGGLE_NODE_TIMES = 5;
@Test @Test
@Disabled( "Takes a long time to run, mostly for stress testing" ) @Disabled( "Takes a long time to run, mostly for stress testing" )
public void testLarge() public void testLarge()
{ {
final int BRUTE_SIZE = 16;
final int TOGGLE_CONNECTION_TIMES = 5;
final int TOGGLE_NODE_TIMES = 5;
Grid<IWiredNode> grid = new Grid<>( BRUTE_SIZE ); Grid<IWiredNode> grid = new Grid<>( BRUTE_SIZE );
grid.map( ( existing, pos ) -> new NetworkElement( null, null, "n_" + pos ).getNode() ); grid.map( ( existing, pos ) -> new NetworkElement( null, null, "n_" + pos ).getNode() );
@ -324,7 +324,7 @@ public void testLarge()
} }
} }
private static class NetworkElement implements IWiredElement private static final class NetworkElement implements IWiredElement
{ {
private final World world; private final World world;
private final Vec3d position; private final Vec3d position;
@ -433,7 +433,7 @@ private static class Grid<T>
private final T[] box; private final T[] box;
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public Grid( int size ) Grid( int size )
{ {
this.size = size; this.size = size;
this.box = (T[]) new Object[size * size * size]; this.box = (T[]) new Object[size * size * size];