mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-20 14:12:55 +00:00
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:
parent
7d428030df
commit
a0e7c4a74c
49
build.gradle
49
build.gradle
@ -17,7 +17,9 @@ buildscript {
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
@ -66,6 +68,8 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
checkstyle "com.puppycrawl.tools:checkstyle:8.21"
|
||||
|
||||
deobfProvided "mezz.jei:jei_1.12.2:4.15.0.269:api"
|
||||
deobfProvided "pl.asie:Charset-Lib:0.5.4.6"
|
||||
deobfProvided "MCMultiPart2:MCMultiPart:2.5.3"
|
||||
@ -104,6 +108,8 @@ import java.util.zip.*
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
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 proguard.gradle.ProGuardTask
|
||||
|
||||
@ -227,6 +233,42 @@ task compressJson(dependsOn: extractAnnotationsJar) {
|
||||
|
||||
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 {
|
||||
group "upload"
|
||||
description "Verifies that everything is ready for a release"
|
||||
@ -266,7 +308,6 @@ task checkRelease {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
curseforge {
|
||||
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
|
||||
project {
|
||||
@ -369,6 +410,10 @@ gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xlint" << "-Xlint:-processing" << "-Werror"
|
||||
}
|
||||
|
||||
tasks.withType(LicenseFormat) {
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
}
|
||||
|
||||
runClient.outputs.upToDateWhen { false }
|
||||
|
159
config/checkstyle/checkstyle.xml
Normal file
159
config/checkstyle/checkstyle.xml
Normal 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>
|
||||
|
13
config/checkstyle/suppressions.xml
Normal file
13
config/checkstyle/suppressions.xml
Normal 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
3
config/license/api.txt
Normal 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
3
config/license/main.txt
Normal 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
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
|
@ -438,45 +438,45 @@ public final class ComputerCraftAPI
|
||||
computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[] {
|
||||
} );
|
||||
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class<?>[] {
|
||||
World.class, String.class
|
||||
World.class, String.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<?>[] {
|
||||
Class.class, String.class, String.class
|
||||
Class.class, String.class, String.class,
|
||||
} );
|
||||
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class<?>[] {
|
||||
IPeripheralProvider.class
|
||||
IPeripheralProvider.class,
|
||||
} );
|
||||
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class<?>[] {
|
||||
ITurtleUpgrade.class
|
||||
ITurtleUpgrade.class,
|
||||
} );
|
||||
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class<?>[] {
|
||||
IBundledRedstoneProvider.class
|
||||
IBundledRedstoneProvider.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<?>[] {
|
||||
IMediaProvider.class
|
||||
IMediaProvider.class,
|
||||
} );
|
||||
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class<?>[] {
|
||||
ITurtlePermissionProvider.class
|
||||
ITurtlePermissionProvider.class,
|
||||
} );
|
||||
computerCraft_registerPocketUpgrade = findCCMethod( "registerPocketUpgrade", new Class<?>[] {
|
||||
IPocketUpgrade.class
|
||||
IPocketUpgrade.class,
|
||||
} );
|
||||
computerCraft_getWirelessNetwork = findCCMethod( "getWirelessNetwork", new Class<?>[] {
|
||||
} );
|
||||
computerCraft_registerAPIFactory = findCCMethod( "registerAPIFactory", new Class<?>[] {
|
||||
ILuaAPIFactory.class
|
||||
ILuaAPIFactory.class,
|
||||
} );
|
||||
computerCraft_createWiredNodeForElement = findCCMethod( "createWiredNodeForElement", new Class<?>[] {
|
||||
IWiredElement.class
|
||||
IWiredElement.class,
|
||||
} );
|
||||
computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] {
|
||||
IBlockAccess.class, BlockPos.class, EnumFacing.class
|
||||
IBlockAccess.class, BlockPos.class, EnumFacing.class,
|
||||
} );
|
||||
}
|
||||
catch( Exception e )
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.filesystem;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -20,7 +19,7 @@ public class FileOperationException extends IOException
|
||||
{
|
||||
private static final long serialVersionUID = -8809108200853029849L;
|
||||
|
||||
private String filename;
|
||||
private final String filename;
|
||||
|
||||
public FileOperationException( @Nullable String filename, @Nonnull String message )
|
||||
{
|
||||
@ -31,6 +30,7 @@ public class FileOperationException extends IOException
|
||||
public FileOperationException( String message )
|
||||
{
|
||||
super( Objects.requireNonNull( message, "message cannot be null" ) );
|
||||
this.filename = null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.pocket;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2019. 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.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.turtle.event;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
|
@ -120,7 +120,7 @@ public class GuiTurtle extends GuiContainer
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public final class ModelTransformer
|
||||
private final Point3f[] before = 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 );
|
||||
this.positionMatrix = positionMatrix;
|
||||
|
@ -43,9 +43,7 @@ public class FSAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"fs"
|
||||
};
|
||||
return new String[] { "fs" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,9 +42,7 @@ public class HTTPAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"http"
|
||||
};
|
||||
return new String[] { "http" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ package dan200.computercraft.core.apis;
|
||||
* This exists purely to ensure binary compatibility.
|
||||
*
|
||||
* @see dan200.computercraft.api.lua.ILuaAPI
|
||||
* @deprecated Use the version in the public API. Only exists for compatibility with CCEmuX.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ILuaAPI extends dan200.computercraft.api.lua.ILuaAPI
|
||||
|
@ -36,9 +36,9 @@ public class OSAPI implements ILuaAPI
|
||||
|
||||
private static class Timer
|
||||
{
|
||||
public int m_ticksLeft;
|
||||
int m_ticksLeft;
|
||||
|
||||
public Timer( int ticksLeft )
|
||||
Timer( int ticksLeft )
|
||||
{
|
||||
m_ticksLeft = ticksLeft;
|
||||
}
|
||||
@ -46,10 +46,10 @@ public class OSAPI implements ILuaAPI
|
||||
|
||||
private static class Alarm implements Comparable<Alarm>
|
||||
{
|
||||
public final double m_time;
|
||||
public final int m_day;
|
||||
final double m_time;
|
||||
final int m_day;
|
||||
|
||||
public Alarm( double time, int day )
|
||||
Alarm( double time, int day )
|
||||
{
|
||||
m_time = time;
|
||||
m_day = day;
|
||||
@ -78,9 +78,7 @@ public class OSAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"os"
|
||||
};
|
||||
return new String[] { "os" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -385,9 +383,7 @@ public class OSAPI implements ILuaAPI
|
||||
// Get in-game epoch
|
||||
synchronized( m_alarms )
|
||||
{
|
||||
return new Object[] {
|
||||
m_day * 86400000 + (int) (m_time * 3600000.0f)
|
||||
};
|
||||
return new Object[] { m_day * 86400000 + (int) (m_time * 3600000.0f) };
|
||||
}
|
||||
default:
|
||||
throw new LuaException( "Unsupported operation" );
|
||||
|
@ -36,7 +36,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
private Map<String, Integer> m_methodMap;
|
||||
private boolean m_attached;
|
||||
|
||||
public PeripheralWrapper( IPeripheral peripheral, String side )
|
||||
PeripheralWrapper( IPeripheral peripheral, String side )
|
||||
{
|
||||
super( m_environment );
|
||||
m_side = side;
|
||||
@ -282,9 +282,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"peripheral"
|
||||
};
|
||||
return new String[] { "peripheral" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -326,7 +324,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
"isPresent",
|
||||
"getType",
|
||||
"getMethods",
|
||||
"call"
|
||||
"call",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"rs", "redstone"
|
||||
};
|
||||
return new String[] { "rs", "redstone" };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -33,9 +33,7 @@ public class TermAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"term"
|
||||
};
|
||||
return new String[] { "term" };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -89,9 +87,7 @@ public class TermAPI implements ILuaAPI
|
||||
|
||||
public static Object[] encodeColour( int colour ) throws LuaException
|
||||
{
|
||||
return new Object[] {
|
||||
1 << colour
|
||||
};
|
||||
return new Object[] { 1 << colour };
|
||||
}
|
||||
|
||||
public static void setColour( Terminal terminal, int colour, double r, double g, double b )
|
||||
|
@ -72,7 +72,8 @@ public abstract class Resource<T extends Resource<T>> implements Closeable
|
||||
*/
|
||||
protected void dispose()
|
||||
{
|
||||
@SuppressWarnings( "unchecked" ) T thisT = (T) this;
|
||||
@SuppressWarnings( "unchecked" )
|
||||
T thisT = (T) this;
|
||||
limiter.release( thisT );
|
||||
}
|
||||
|
||||
@ -95,7 +96,8 @@ public abstract class Resource<T extends Resource<T>> implements Closeable
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,10 @@ public enum ComputerSide
|
||||
|
||||
private final String name;
|
||||
|
||||
ComputerSide( String name ) {this.name = name;}
|
||||
ComputerSide( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ComputerSide valueOf( int side )
|
||||
|
@ -46,7 +46,7 @@ public class FileSystem
|
||||
m_writableMount = null;
|
||||
}
|
||||
|
||||
public MountWrapper( String label, String location, IWritableMount mount )
|
||||
MountWrapper( String label, String location, IWritableMount mount )
|
||||
{
|
||||
this( label, location, (IMount) mount );
|
||||
m_writableMount = mount;
|
||||
@ -779,7 +779,7 @@ public class FileSystem
|
||||
|
||||
// Clean the path or illegal characters.
|
||||
final char[] specialChars = new char[] {
|
||||
'"', ':', '<', '>', '?', '|' // Sorted by ascii value (important)
|
||||
'"', ':', '<', '>', '?', '|', // Sorted by ascii value (important)
|
||||
};
|
||||
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
|
@ -550,7 +550,7 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
{
|
||||
if( ComputerCraft.logPeripheralErrors ) ComputerCraft.log.error( "Error running task", t );
|
||||
m_computer.queueEvent( "task_complete", new Object[] {
|
||||
taskID, false, "Java Exception Thrown: " + t
|
||||
taskID, false, "Java Exception Thrown: " + t,
|
||||
} );
|
||||
}
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ package dan200.computercraft.core.terminal;
|
||||
|
||||
public class TextBuffer
|
||||
{
|
||||
public char[] m_text;
|
||||
private final char[] m_text;
|
||||
|
||||
public TextBuffer( char c, int length )
|
||||
{
|
||||
|
@ -47,9 +47,7 @@ public class CommandAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"commands"
|
||||
};
|
||||
return new String[] { "commands" };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -62,7 +60,7 @@ public class CommandAPI implements ILuaAPI
|
||||
"list",
|
||||
"getBlockPosition",
|
||||
"getBlockInfos",
|
||||
"getBlockInfo"
|
||||
"getBlockInfo",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
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_sessionID;
|
||||
|
||||
@ -33,12 +33,12 @@ public class ComputerRegistry<TComputer extends IComputer>
|
||||
return m_nextUnusedInstanceID++;
|
||||
}
|
||||
|
||||
public Collection<TComputer> getComputers()
|
||||
public Collection<T> getComputers()
|
||||
{
|
||||
return m_computers.values();
|
||||
}
|
||||
|
||||
public TComputer get( int instanceID )
|
||||
public T get( int instanceID )
|
||||
{
|
||||
if( instanceID >= 0 )
|
||||
{
|
||||
@ -55,7 +55,7 @@ public class ComputerRegistry<TComputer extends IComputer>
|
||||
return m_computers.containsKey( instanceID );
|
||||
}
|
||||
|
||||
public void add( int instanceID, TComputer computer )
|
||||
public void add( int instanceID, T computer )
|
||||
{
|
||||
if( m_computers.containsKey( instanceID ) )
|
||||
{
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.integration.charset;
|
||||
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.integration.charset;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
|
@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.integration.charset;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
|
@ -39,5 +39,8 @@ public enum PeripheralType implements IStringSerializable
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class CommandBlockPeripheral implements IPeripheral
|
||||
{
|
||||
case 0: // getCommand
|
||||
return context.executeMainThreadTask( () -> new Object[] {
|
||||
m_commandBlock.getCommandBlockLogic().getCommand()
|
||||
m_commandBlock.getCommandBlockLogic().getCommand(),
|
||||
} );
|
||||
case 1:
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
"playAudio",
|
||||
"stopAudio",
|
||||
"ejectDisk",
|
||||
"getDiskID"
|
||||
"getDiskID",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa
|
||||
for( IComputerAccess computer : m_computers )
|
||||
{
|
||||
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 abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa
|
||||
for( IComputerAccess computer : m_computers )
|
||||
{
|
||||
computer.queueEvent( "modem_message", new Object[] {
|
||||
computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload()
|
||||
computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload(),
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
private final String[] m_methods;
|
||||
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_peripheral = peripheral;
|
||||
|
@ -142,7 +142,7 @@ public class TileMonitor extends TileGeneric implements ITilePeripheral, IPeriph
|
||||
for( IComputerAccess computer : monitor.m_computers )
|
||||
{
|
||||
computer.queueEvent( "monitor_resize", new Object[] {
|
||||
computer.getAttachmentName()
|
||||
computer.getAttachmentName(),
|
||||
} );
|
||||
}
|
||||
}
|
||||
@ -660,7 +660,7 @@ public class TileMonitor extends TileGeneric implements ITilePeripheral, IPeriph
|
||||
for( IComputerAccess computer : monitor.m_computers )
|
||||
{
|
||||
computer.queueEvent( "monitor_touch", new Object[] {
|
||||
computer.getAttachmentName(), xCharPos, yCharPos
|
||||
computer.getAttachmentName(), xCharPos, yCharPos,
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
return new String[] {
|
||||
"playSound", // Plays sound at resourceLocator
|
||||
"playNote" // Plays note
|
||||
"playSound",
|
||||
"playNote",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,7 @@ public class PocketAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"pocket"
|
||||
};
|
||||
return new String[] { "pocket" };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -46,7 +44,7 @@ public class PocketAPI implements ILuaAPI
|
||||
{
|
||||
return new String[] {
|
||||
"equipBack",
|
||||
"unequipBack"
|
||||
"unequipBack",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,7 @@ public class TurtleAPI implements ILuaAPI
|
||||
@Override
|
||||
public String[] getNames()
|
||||
{
|
||||
return new String[] {
|
||||
"turtle"
|
||||
};
|
||||
return new String[] { "turtle" };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -908,14 +908,14 @@ public class TurtleBrain implements ITurtleAccess
|
||||
else
|
||||
{
|
||||
computer.queueEvent( "turtle_response", new Object[] {
|
||||
callbackID, true
|
||||
callbackID, true,
|
||||
} );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
computer.queueEvent( "turtle_response", new Object[] {
|
||||
callbackID, false, result != null ? result.getErrorMessage() : null
|
||||
callbackID, false, result != null ? result.getErrorMessage() : null,
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ public class ContainerTurtle extends Container implements IContainerComputer
|
||||
{
|
||||
private static final int PROGRESS_ID_SELECTED_SLOT = 0;
|
||||
|
||||
public final int m_playerInvStartY;
|
||||
public final int m_turtleInvStartX;
|
||||
public final int playerInvStartY;
|
||||
public final int turtleInvStartX;
|
||||
|
||||
private final ITurtleAccess m_turtle;
|
||||
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 )
|
||||
{
|
||||
m_playerInvStartY = playerInvStartY;
|
||||
m_turtleInvStartX = turtleInvStartX;
|
||||
this.playerInvStartY = playerInvStartY;
|
||||
this.turtleInvStartX = turtleInvStartX;
|
||||
|
||||
m_turtle = turtle;
|
||||
m_selectedSlot = m_turtle.getWorld().isRemote ? 0 : m_turtle.getSelectedSlot();
|
||||
|
@ -73,7 +73,10 @@ public class ItemTurtleLegacy extends ItemTurtleBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlay( @Nonnull ItemStack stack ) { return null; }
|
||||
public ResourceLocation getOverlay( @Nonnull ItemStack stack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFuelLevel( @Nonnull ItemStack stack )
|
||||
|
@ -54,7 +54,7 @@ public class TurtleHoe extends TurtleTool
|
||||
{
|
||||
if( verb == TurtleVerb.Dig )
|
||||
{
|
||||
ItemStack hoe = m_item.copy();
|
||||
ItemStack hoe = item.copy();
|
||||
ItemStack remainder = TurtlePlaceCommand.deploy( hoe, turtle, direction, null, null );
|
||||
if( remainder != hoe )
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public class TurtleShovel extends TurtleTool
|
||||
{
|
||||
if( verb == TurtleVerb.Dig )
|
||||
{
|
||||
ItemStack shovel = m_item.copy();
|
||||
ItemStack shovel = item.copy();
|
||||
ItemStack remainder = TurtlePlaceCommand.deploy( shovel, turtle, direction, null, null );
|
||||
if( remainder != shovel )
|
||||
{
|
||||
|
@ -48,18 +48,18 @@ import java.util.function.Function;
|
||||
|
||||
public class TurtleTool extends AbstractTurtleUpgrade
|
||||
{
|
||||
protected ItemStack m_item;
|
||||
protected final ItemStack item;
|
||||
|
||||
public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item 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 )
|
||||
{
|
||||
super( id, legacyID, TurtleUpgradeType.Tool, item );
|
||||
m_item = new ItemStack( item, 1, 0 );
|
||||
this.item = new ItemStack( item, 1, 0 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -76,7 +76,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
return Pair.of(
|
||||
mc.getRenderItem().getItemModelMesher().getItemModel( m_item ),
|
||||
mc.getRenderItem().getItemModelMesher().getItemModel( item ),
|
||||
transform
|
||||
);
|
||||
}
|
||||
@ -124,7 +124,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
if( hit != null )
|
||||
{
|
||||
// Load up the turtle's inventory
|
||||
ItemStack stackCopy = m_item.copy();
|
||||
ItemStack stackCopy = item.copy();
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
|
||||
Entity hitEntity = hit.getKey();
|
||||
@ -202,7 +202,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
IBlockState state = world.getBlockState( blockPosition );
|
||||
|
||||
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction );
|
||||
turtlePlayer.loadInventory( m_item.copy() );
|
||||
turtlePlayer.loadInventory( item.copy() );
|
||||
|
||||
if( ComputerCraft.turtlesObeyBlockProtection )
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public final class ColourUtils
|
||||
"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown",
|
||||
"dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray",
|
||||
"dyeGray", "dyePink", "dyeLime", "dyeYellow",
|
||||
"dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"
|
||||
"dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite",
|
||||
};
|
||||
|
||||
private static int[] ids;
|
||||
|
@ -72,12 +72,11 @@ public class Palette
|
||||
|
||||
public static double[] decodeRGB8( int rgb )
|
||||
{
|
||||
return new double[]
|
||||
{
|
||||
((rgb >> 16) & 0xFF) / 255.0f,
|
||||
((rgb >> 8) & 0xFF) / 255.0f,
|
||||
(rgb & 0xFF) / 255.0f
|
||||
};
|
||||
return new double[] {
|
||||
((rgb >> 16) & 0xFF) / 255.0f,
|
||||
((rgb >> 8) & 0xFF) / 255.0f,
|
||||
(rgb & 0xFF) / 255.0f,
|
||||
};
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
|
@ -35,6 +35,7 @@ public final class StringUtil
|
||||
/**
|
||||
* Translates a Stat name
|
||||
*/
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public static String translate( String key )
|
||||
{
|
||||
return net.minecraft.util.text.translation.I18n.translateToLocal( key );
|
||||
@ -43,6 +44,7 @@ public final class StringUtil
|
||||
/**
|
||||
* Translates a Stat name with format args
|
||||
*/
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public static String translateFormatted( String key, Object... format )
|
||||
{
|
||||
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format );
|
||||
|
@ -96,7 +96,7 @@ public class BasicEnvironment implements IComputerEnvironment
|
||||
|
||||
public static IMount createMount( Class<?> klass, String path, String fallback )
|
||||
{
|
||||
File file = getContainingFile(klass);
|
||||
File file = getContainingFile( klass );
|
||||
|
||||
if( file.isFile() )
|
||||
{
|
||||
@ -128,7 +128,7 @@ public class BasicEnvironment implements IComputerEnvironment
|
||||
}
|
||||
|
||||
|
||||
private static File getContainingFile(Class<?> klass)
|
||||
private static File getContainingFile( Class<?> klass )
|
||||
{
|
||||
String path = klass.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
int bangIndex = path.indexOf( "!" );
|
||||
|
@ -42,7 +42,7 @@ public class ComputerBootstrap
|
||||
.addFile( "test.lua", program )
|
||||
.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 )
|
||||
|
@ -253,14 +253,14 @@ public class NetworkTest
|
||||
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
|
||||
@Disabled( "Takes a long time to run, mostly for stress testing" )
|
||||
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.map( ( existing, pos ) -> new NetworkElement( null, null, "n_" + pos ).getNode() );
|
||||
|
||||
@ -324,7 +324,7 @@ public class NetworkTest
|
||||
}
|
||||
}
|
||||
|
||||
private static class NetworkElement implements IWiredElement
|
||||
private static final class NetworkElement implements IWiredElement
|
||||
{
|
||||
private final World world;
|
||||
private final Vec3d position;
|
||||
@ -433,7 +433,7 @@ public class NetworkTest
|
||||
private final T[] box;
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public Grid( int size )
|
||||
Grid( int size )
|
||||
{
|
||||
this.size = size;
|
||||
this.box = (T[]) new Object[size * size * size];
|
||||
|
Loading…
Reference in New Issue
Block a user