diff --git a/README.md b/README.md index b29bd9d78..c3fd20cd4 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ This mod includes textures that are more in-line with the style of Mojang's new We also have a second resourcepack made by [3prm3](https://github.com/3prm3), it features a complete overhaul and can be enabled by enabling the `overhaul` resource pack, go check out his resource pack over here! # Conflicts -Currently Iris and Canvas Shaders are Incompatible with this mod, +Currently Iris and Canvas Shaders are Incompatible with this mod, - Iris has transparent monitors, and when a computer displays something on the monitor, the face becomes black - Canvas... uhm - Computer Terminals are 100% unusable and scuffed - - + - - Monitors break with either rendering option - TBO - Just crashes on world load diff --git a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java index f7e630d02..5e8128645 100644 --- a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java +++ b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java @@ -80,11 +80,11 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI @Override public String getInstalledVersion() { - if( this.version != null ) + if( version != null ) { - return this.version; + return version; } - return this.version = FabricLoader.getInstance() + return version = FabricLoader.getInstance() .getModContainer( ComputerCraft.MOD_ID ) .map( x -> x.getMetadata() .getVersion() diff --git a/src/main/java/dan200/computercraft/api/client/TransformedModel.java b/src/main/java/dan200/computercraft/api/client/TransformedModel.java index a62350b07..1d1cc5828 100644 --- a/src/main/java/dan200/computercraft/api/client/TransformedModel.java +++ b/src/main/java/dan200/computercraft/api/client/TransformedModel.java @@ -38,7 +38,7 @@ public final class TransformedModel public TransformedModel( @Nonnull BakedModel model ) { this.model = Objects.requireNonNull( model ); - this.matrix = AffineTransformation.identity(); + matrix = AffineTransformation.identity(); } public static TransformedModel of( @Nonnull ModelIdentifier location ) @@ -60,26 +60,26 @@ public final class TransformedModel @Nonnull public BakedModel getModel() { - return this.model; + return model; } @Nonnull public AffineTransformation getMatrix() { - return this.matrix; + return matrix; } public void push( MatrixStack matrixStack ) { matrixStack.push(); - AffineTransformationAccess access = (AffineTransformationAccess) (Object) this.matrix; + AffineTransformationAccess access = (AffineTransformationAccess) (Object) matrix; if( access.getTranslation() != null ) { matrixStack.translate( access.getTranslation().getX(), access.getTranslation().getY(), access.getTranslation().getZ() ); } - matrixStack.multiply( this.matrix.getRotation2() ); + matrixStack.multiply( matrix.getRotation2() ); if( access.getScale() != null ) { diff --git a/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java b/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java index ce05e8181..20db37caa 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java +++ b/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java @@ -47,13 +47,13 @@ final class FileAttributes implements BasicFileAttributes @Override public boolean isRegularFile() { - return !this.isDirectory; + return !isDirectory; } @Override public boolean isDirectory() { - return this.isDirectory; + return isDirectory; } @Override @@ -71,7 +71,7 @@ final class FileAttributes implements BasicFileAttributes @Override public long size() { - return this.size; + return size; } @Override diff --git a/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java b/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java index a0d4de1aa..dc08e0268 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java +++ b/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java @@ -31,12 +31,12 @@ public class FileOperationException extends IOException public FileOperationException( @Nonnull String message ) { super( Objects.requireNonNull( message, "message cannot be null" ) ); - this.filename = null; + filename = null; } @Nullable public String getFilename() { - return this.filename; + return filename; } } diff --git a/src/main/java/dan200/computercraft/api/filesystem/IMount.java b/src/main/java/dan200/computercraft/api/filesystem/IMount.java index f767bcd5a..9634cbb57 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/IMount.java +++ b/src/main/java/dan200/computercraft/api/filesystem/IMount.java @@ -59,11 +59,11 @@ public interface IMount @Nonnull default BasicFileAttributes getAttributes( @Nonnull String path ) throws IOException { - if( !this.exists( path ) ) + if( !exists( path ) ) { throw new FileOperationException( path, "No such file" ); } - return new FileAttributes( this.isDirectory( path ), this.getSize( path ) ); + return new FileAttributes( isDirectory( path ), getSize( path ) ); } /** diff --git a/src/main/java/dan200/computercraft/api/lua/IArguments.java b/src/main/java/dan200/computercraft/api/lua/IArguments.java index 2d4d73983..5546176ca 100644 --- a/src/main/java/dan200/computercraft/api/lua/IArguments.java +++ b/src/main/java/dan200/computercraft/api/lua/IArguments.java @@ -30,10 +30,10 @@ public interface IArguments default Object[] getAll() { - Object[] result = new Object[this.count()]; + Object[] result = new Object[count()]; for( int i = 0; i < result.length; i++ ) { - result[i] = this.get( i ); + result[i] = get( i ); } return result; } @@ -71,7 +71,7 @@ public interface IArguments */ default int getInt( int index ) throws LuaException { - return (int) this.getLong( index ); + return (int) getLong( index ); } /** @@ -83,7 +83,7 @@ public interface IArguments */ default long getLong( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( !(value instanceof Number) ) { throw LuaValues.badArgumentOf( index, "number", value ); @@ -101,7 +101,7 @@ public interface IArguments */ default double getFiniteDouble( int index ) throws LuaException { - return checkFinite( index, this.getDouble( index ) ); + return checkFinite( index, getDouble( index ) ); } /** @@ -114,7 +114,7 @@ public interface IArguments */ default double getDouble( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( !(value instanceof Number) ) { throw LuaValues.badArgumentOf( index, "number", value ); @@ -131,7 +131,7 @@ public interface IArguments */ default boolean getBoolean( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( !(value instanceof Boolean) ) { throw LuaValues.badArgumentOf( index, "boolean", value ); @@ -149,7 +149,7 @@ public interface IArguments @Nonnull default ByteBuffer getBytes( int index ) throws LuaException { - return LuaValues.encode( this.getString( index ) ); + return LuaValues.encode( getString( index ) ); } /** @@ -162,7 +162,7 @@ public interface IArguments @Nonnull default String getString( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( !(value instanceof String) ) { throw LuaValues.badArgumentOf( index, "string", value ); @@ -182,7 +182,7 @@ public interface IArguments @Nonnull default > T getEnum( int index, Class klass ) throws LuaException { - return LuaValues.checkEnum( index, klass, this.getString( index ) ); + return LuaValues.checkEnum( index, klass, getString( index ) ); } /** @@ -195,7 +195,7 @@ public interface IArguments @Nonnull default Map getTable( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( !(value instanceof Map) ) { throw LuaValues.badArgumentOf( index, "table", value ); @@ -212,7 +212,7 @@ public interface IArguments */ default Optional optBytes( int index ) throws LuaException { - return this.optString( index ).map( LuaValues::encode ); + return optString( index ).map( LuaValues::encode ); } /** @@ -224,7 +224,7 @@ public interface IArguments */ default Optional optString( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( value == null ) { return Optional.empty(); @@ -248,7 +248,7 @@ public interface IArguments @Nonnull default > Optional optEnum( int index, Class klass ) throws LuaException { - Optional str = this.optString( index ); + Optional str = optString( index ); return str.isPresent() ? Optional.of( LuaValues.checkEnum( index, klass, str.get() ) ) : Optional.empty(); } @@ -262,7 +262,7 @@ public interface IArguments */ default double optDouble( int index, double def ) throws LuaException { - return this.optDouble( index ).orElse( def ); + return optDouble( index ).orElse( def ); } /** @@ -275,7 +275,7 @@ public interface IArguments @Nonnull default Optional optDouble( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( value == null ) { return Optional.empty(); @@ -297,7 +297,7 @@ public interface IArguments */ default int optInt( int index, int def ) throws LuaException { - return this.optInt( index ).orElse( def ); + return optInt( index ).orElse( def ); } /** @@ -310,7 +310,7 @@ public interface IArguments @Nonnull default Optional optInt( int index ) throws LuaException { - return this.optLong( index ).map( Long::intValue ); + return optLong( index ).map( Long::intValue ); } /** @@ -322,7 +322,7 @@ public interface IArguments */ default Optional optLong( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( value == null ) { return Optional.empty(); @@ -345,7 +345,7 @@ public interface IArguments */ default long optLong( int index, long def ) throws LuaException { - return this.optLong( index ).orElse( def ); + return optLong( index ).orElse( def ); } /** @@ -358,7 +358,7 @@ public interface IArguments */ default double optFiniteDouble( int index, double def ) throws LuaException { - return this.optFiniteDouble( index ).orElse( def ); + return optFiniteDouble( index ).orElse( def ); } /** @@ -370,7 +370,7 @@ public interface IArguments */ default Optional optFiniteDouble( int index ) throws LuaException { - Optional value = this.optDouble( index ); + Optional value = optDouble( index ); if( value.isPresent() ) { LuaValues.checkFiniteNum( index, value.get() ); @@ -388,7 +388,7 @@ public interface IArguments */ default boolean optBoolean( int index, boolean def ) throws LuaException { - return this.optBoolean( index ).orElse( def ); + return optBoolean( index ).orElse( def ); } /** @@ -400,7 +400,7 @@ public interface IArguments */ default Optional optBoolean( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( value == null ) { return Optional.empty(); @@ -422,7 +422,7 @@ public interface IArguments */ default String optString( int index, String def ) throws LuaException { - return this.optString( index ).orElse( def ); + return optString( index ).orElse( def ); } /** @@ -435,7 +435,7 @@ public interface IArguments */ default Map optTable( int index, Map def ) throws LuaException { - return this.optTable( index ).orElse( def ); + return optTable( index ).orElse( def ); } /** @@ -447,7 +447,7 @@ public interface IArguments */ default Optional> optTable( int index ) throws LuaException { - Object value = this.get( index ); + Object value = get( index ); if( value == null ) { return Optional.empty(); diff --git a/src/main/java/dan200/computercraft/api/lua/LuaException.java b/src/main/java/dan200/computercraft/api/lua/LuaException.java index 21d799c4a..df97ed0fa 100644 --- a/src/main/java/dan200/computercraft/api/lua/LuaException.java +++ b/src/main/java/dan200/computercraft/api/lua/LuaException.java @@ -20,14 +20,14 @@ public class LuaException extends Exception public LuaException( @Nullable String message ) { super( message ); - this.hasLevel = false; - this.level = 1; + hasLevel = false; + level = 1; } public LuaException( @Nullable String message, int level ) { super( message ); - this.hasLevel = true; + hasLevel = true; this.level = level; } @@ -38,7 +38,7 @@ public class LuaException extends Exception */ public boolean hasLevel() { - return this.hasLevel; + return hasLevel; } /** @@ -48,6 +48,6 @@ public class LuaException extends Exception */ public int getLevel() { - return this.level; + return level; } } diff --git a/src/main/java/dan200/computercraft/api/lua/MethodResult.java b/src/main/java/dan200/computercraft/api/lua/MethodResult.java index c7ee1d3ae..8787bf911 100644 --- a/src/main/java/dan200/computercraft/api/lua/MethodResult.java +++ b/src/main/java/dan200/computercraft/api/lua/MethodResult.java @@ -31,14 +31,14 @@ public final class MethodResult private MethodResult( Object[] arguments, ILuaCallback callback ) { - this.result = arguments; + result = arguments; this.callback = callback; - this.adjust = 0; + adjust = 0; } private MethodResult( Object[] arguments, ILuaCallback callback, int adjust ) { - this.result = arguments; + result = arguments; this.callback = callback; this.adjust = adjust; } @@ -141,18 +141,18 @@ public final class MethodResult @Nullable public Object[] getResult() { - return this.result; + return result; } @Nullable public ILuaCallback getCallback() { - return this.callback; + return callback; } public int getErrorAdjust() { - return this.adjust; + return adjust; } /** @@ -168,10 +168,10 @@ public final class MethodResult { throw new IllegalArgumentException( "cannot adjust by a negative amount" ); } - if( adjust == 0 || this.callback == null ) + if( adjust == 0 || callback == null ) { return this; } - return new MethodResult( this.result, this.callback, this.adjust + adjust ); + return new MethodResult( result, callback, this.adjust + adjust ); } } diff --git a/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java b/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java index d0c58833b..d800d0ac6 100644 --- a/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java +++ b/src/main/java/dan200/computercraft/api/lua/ObjectArguments.java @@ -47,30 +47,30 @@ public final class ObjectArguments implements IArguments { return this; } - if( count >= this.args.size() ) + if( count >= args.size() ) { return EMPTY; } - return new ObjectArguments( this.args.subList( count, this.args.size() ) ); + return new ObjectArguments( args.subList( count, args.size() ) ); } @Override public Object[] getAll() { - return this.args.toArray(); + return args.toArray(); } @Override public int count() { - return this.args.size(); + return args.size(); } @Nullable @Override public Object get( int index ) { - return index >= this.args.size() ? null : this.args.get( index ); + return index >= args.size() ? null : args.get( index ); } } diff --git a/src/main/java/dan200/computercraft/api/network/Packet.java b/src/main/java/dan200/computercraft/api/network/Packet.java index 58251e01f..34b2bd41f 100644 --- a/src/main/java/dan200/computercraft/api/network/Packet.java +++ b/src/main/java/dan200/computercraft/api/network/Packet.java @@ -53,7 +53,7 @@ public class Packet */ public int getChannel() { - return this.channel; + return channel; } /** @@ -63,7 +63,7 @@ public class Packet */ public int getReplyChannel() { - return this.replyChannel; + return replyChannel; } /** @@ -74,7 +74,7 @@ public class Packet @Nullable public Object getPayload() { - return this.payload; + return payload; } /** @@ -85,17 +85,17 @@ public class Packet @Nonnull public IPacketSender getSender() { - return this.sender; + return sender; } @Override public int hashCode() { int result; - result = this.channel; - result = 31 * result + this.replyChannel; - result = 31 * result + (this.payload != null ? this.payload.hashCode() : 0); - result = 31 * result + this.sender.hashCode(); + result = channel; + result = 31 * result + replyChannel; + result = 31 * result + (payload != null ? payload.hashCode() : 0); + result = 31 * result + sender.hashCode(); return result; } @@ -106,25 +106,25 @@ public class Packet { return true; } - if( o == null || this.getClass() != o.getClass() ) + if( o == null || getClass() != o.getClass() ) { return false; } Packet packet = (Packet) o; - if( this.channel != packet.channel ) + if( channel != packet.channel ) { return false; } - if( this.replyChannel != packet.replyChannel ) + if( replyChannel != packet.replyChannel ) { return false; } - if( !Objects.equals( this.payload, packet.payload ) ) + if( !Objects.equals( payload, packet.payload ) ) { return false; } - return this.sender.equals( packet.sender ); + return sender.equals( packet.sender ); } } diff --git a/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java b/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java index 233da434c..73afe2fd7 100644 --- a/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java +++ b/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java @@ -46,7 +46,7 @@ public interface IWiredNode extends IPacketNetwork */ default boolean connectTo( @Nonnull IWiredNode node ) { - return this.getNetwork().connect( this, node ); + return getNetwork().connect( this, node ); } /** @@ -72,7 +72,7 @@ public interface IWiredNode extends IPacketNetwork */ default boolean disconnectFrom( @Nonnull IWiredNode node ) { - return this.getNetwork().disconnect( this, node ); + return getNetwork().disconnect( this, node ); } /** @@ -86,7 +86,7 @@ public interface IWiredNode extends IPacketNetwork */ default boolean remove() { - return this.getNetwork().remove( this ); + return getNetwork().remove( this ); } /** @@ -99,6 +99,6 @@ public interface IWiredNode extends IPacketNetwork */ default void updatePeripherals( @Nonnull Map peripherals ) { - this.getNetwork().updatePeripherals( this, peripherals ); + getNetwork().updatePeripherals( this, peripherals ); } } diff --git a/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java b/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java index 30d4c6522..0514ea509 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java +++ b/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java @@ -43,7 +43,7 @@ public interface IComputerAccess @Nullable default String mount( @Nonnull String desiredLocation, @Nonnull IMount mount ) { - return this.mount( desiredLocation, mount, this.getAttachmentName() ); + return mount( desiredLocation, mount, getAttachmentName() ); } /** @@ -93,7 +93,7 @@ public interface IComputerAccess @Nullable default String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount ) { - return this.mountWritable( desiredLocation, mount, this.getAttachmentName() ); + return mountWritable( desiredLocation, mount, getAttachmentName() ); } /** diff --git a/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java b/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java index bddfb4985..21ae59438 100644 --- a/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java +++ b/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java @@ -45,7 +45,7 @@ public interface IWorkMonitor default boolean runWork( @Nonnull Runnable runnable ) { Objects.requireNonNull( runnable, "runnable should not be null" ); - if( !this.canWork() ) + if( !canWork() ) { return false; } @@ -57,7 +57,7 @@ public interface IWorkMonitor } finally { - this.trackWork( System.nanoTime() - start, TimeUnit.NANOSECONDS ); + trackWork( System.nanoTime() - start, TimeUnit.NANOSECONDS ); } return true; diff --git a/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java b/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java index 16f183441..d17820409 100644 --- a/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java +++ b/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java @@ -33,7 +33,7 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade { this.id = id; this.adjective = adjective; - this.stack = new ItemStack( item ); + stack = new ItemStack( item ); } protected AbstractPocketUpgrade( Identifier id, String adjective, ItemStack stack ) @@ -48,20 +48,20 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade @Override public final Identifier getUpgradeID() { - return this.id; + return id; } @Nonnull @Override public final String getUnlocalisedAdjective() { - return this.adjective; + return adjective; } @Nonnull @Override public final ItemStack getCraftingItem() { - return this.stack; + return stack; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java b/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java index 34b5bc1cf..e53215bbd 100644 --- a/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java +++ b/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java @@ -53,27 +53,27 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade @Override public final Identifier getUpgradeID() { - return this.id; + return id; } @Nonnull @Override public final String getUnlocalisedAdjective() { - return this.adjective; + return adjective; } @Nonnull @Override public final TurtleUpgradeType getType() { - return this.type; + return type; } @Nonnull @Override public final ItemStack getCraftingItem() { - return this.stack; + return stack; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java index d36eef98c..a67f10e34 100644 --- a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java +++ b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java @@ -54,7 +54,7 @@ public class FakePlayer extends ServerPlayerEntity public FakePlayer( ServerWorld world, GameProfile gameProfile ) { super( world.getServer(), world, gameProfile, new ServerPlayerInteractionManager( world ) ); - this.networkHandler = new FakeNetHandler( this ); + networkHandler = new FakeNetHandler( this ); } // region Direct networkHandler access diff --git a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java index 14c96c638..6213a079b 100644 --- a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java +++ b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java @@ -267,7 +267,7 @@ public interface ITurtleAccess default ItemStorage getItemHandler() { - return ItemStorage.wrap( this.getInventory() ); + return ItemStorage.wrap( getInventory() ); } /** diff --git a/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java b/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java index 70974fc24..17f42bb85 100644 --- a/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java +++ b/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java @@ -91,7 +91,7 @@ public final class TurtleCommandResult */ public boolean isSuccess() { - return this.success; + return success; } /** @@ -102,7 +102,7 @@ public final class TurtleCommandResult @Nullable public String getErrorMessage() { - return this.errorMessage; + return errorMessage; } /** @@ -113,6 +113,6 @@ public final class TurtleCommandResult @Nullable public Object[] getResults() { - return this.results; + return results; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleActionEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleActionEvent.java index ac1e93952..b6c129855 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleActionEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleActionEvent.java @@ -32,7 +32,7 @@ public class TurtleActionEvent extends TurtleEvent public TurtleAction getAction() { - return this.action; + return action; } /** @@ -47,7 +47,7 @@ public class TurtleActionEvent extends TurtleEvent @Deprecated public void setCanceled( boolean cancel ) { - this.setCanceled( cancel, null ); + setCanceled( cancel, null ); } /** @@ -61,7 +61,7 @@ public class TurtleActionEvent extends TurtleEvent */ public void setCanceled( boolean cancel, @Nullable String failureMessage ) { - this.cancelled = true; + cancelled = true; this.failureMessage = cancel ? failureMessage : null; } @@ -75,11 +75,11 @@ public class TurtleActionEvent extends TurtleEvent @Nullable public String getFailureMessage() { - return this.failureMessage; + return failureMessage; } public boolean isCancelled() { - return this.cancelled; + return cancelled; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleAttackEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleAttackEvent.java index 4a8440d39..fa8c492cc 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleAttackEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleAttackEvent.java @@ -46,7 +46,7 @@ public class TurtleAttackEvent extends TurtlePlayerEvent @Nonnull public Entity getTarget() { - return this.target; + return target; } /** @@ -57,7 +57,7 @@ public class TurtleAttackEvent extends TurtlePlayerEvent @Nonnull public ITurtleUpgrade getUpgrade() { - return this.upgrade; + return upgrade; } /** @@ -68,6 +68,6 @@ public class TurtleAttackEvent extends TurtlePlayerEvent @Nonnull public TurtleSide getSide() { - return this.side; + return side; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleBlockEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleBlockEvent.java index 1b8ded608..2a195e62a 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleBlockEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleBlockEvent.java @@ -52,7 +52,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent */ public World getWorld() { - return this.world; + return world; } /** @@ -62,7 +62,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent */ public BlockPos getPos() { - return this.pos; + return pos; } /** @@ -97,7 +97,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public BlockState getBlock() { - return this.block; + return block; } /** @@ -108,7 +108,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public ITurtleUpgrade getUpgrade() { - return this.upgrade; + return upgrade; } /** @@ -119,7 +119,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public TurtleSide getSide() { - return this.side; + return side; } } @@ -161,7 +161,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public ItemStack getStack() { - return this.stack; + return stack; } } @@ -196,7 +196,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public BlockState getState() { - return this.state; + return state; } /** @@ -207,7 +207,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent @Nonnull public Map getData() { - return this.data; + return data; } /** @@ -218,7 +218,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent public void addData( @Nonnull Map newData ) { Objects.requireNonNull( newData, "newData cannot be null" ); - this.data.putAll( newData ); + data.putAll( newData ); } } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java index 7d11a1432..726a059ae 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java @@ -46,7 +46,7 @@ public abstract class TurtleEvent @Nonnull public ITurtleAccess getTurtle() { - return this.turtle; + return turtle; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleInspectItemEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleInspectItemEvent.java index 3da00d484..d22b6673d 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleInspectItemEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleInspectItemEvent.java @@ -53,7 +53,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent @Nonnull public ItemStack getStack() { - return this.stack; + return stack; } /** @@ -64,7 +64,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent @Nonnull public Map getData() { - return this.data; + return data; } /** @@ -74,7 +74,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent */ public boolean onMainThread() { - return this.mainThread; + return mainThread; } /** @@ -85,6 +85,6 @@ public class TurtleInspectItemEvent extends TurtleActionEvent public void addData( @Nonnull Map newData ) { Objects.requireNonNull( newData, "newData cannot be null" ); - this.data.putAll( newData ); + data.putAll( newData ); } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleInventoryEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleInventoryEvent.java index 61ff87594..37b01ecb5 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleInventoryEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleInventoryEvent.java @@ -39,7 +39,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent @Nullable public Inventory getItemHandler() { - return this.handler; + return handler; } /** @@ -81,7 +81,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent @Nonnull public ItemStack getStack() { - return this.stack; + return stack; } } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtlePlayerEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtlePlayerEvent.java index 54d79753c..463a6602c 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtlePlayerEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtlePlayerEvent.java @@ -39,6 +39,6 @@ public abstract class TurtlePlayerEvent extends TurtleActionEvent @Nonnull public FakePlayer getPlayer() { - return this.player; + return player; } } diff --git a/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java b/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java index 97c7e3a32..a5374d684 100644 --- a/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java +++ b/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java @@ -41,7 +41,7 @@ public class TurtleRefuelEvent extends TurtleActionEvent */ public ItemStack getStack() { - return this.stack; + return stack; } /** @@ -53,7 +53,7 @@ public class TurtleRefuelEvent extends TurtleActionEvent @Nullable public Handler getHandler() { - return this.handler; + return handler; } /** diff --git a/src/main/java/dan200/computercraft/client/ClientRegistry.java b/src/main/java/dan200/computercraft/client/ClientRegistry.java index b1dd6e568..eb66e181a 100644 --- a/src/main/java/dan200/computercraft/client/ClientRegistry.java +++ b/src/main/java/dan200/computercraft/client/ClientRegistry.java @@ -103,10 +103,8 @@ public final class ClientRegistry case 1: // Frame colour return IColouredItem.getColourBasic( stack ); case 2: // Light colour - { int light = ItemPocketComputer.getLightState( stack ); return light == -1 ? Colour.BLACK.getHex() : light; - } } }, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_NORMAL, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_ADVANCED ); diff --git a/src/main/java/dan200/computercraft/client/ClientTableFormatter.java b/src/main/java/dan200/computercraft/client/ClientTableFormatter.java index a7ccd63d1..8a0fdb581 100644 --- a/src/main/java/dan200/computercraft/client/ClientTableFormatter.java +++ b/src/main/java/dan200/computercraft/client/ClientTableFormatter.java @@ -35,7 +35,7 @@ public class ClientTableFormatter implements TableFormatter @Nullable public Text getPadding( Text component, int width ) { - int extraWidth = width - this.getWidth( component ); + int extraWidth = width - getWidth( component ); if( extraWidth <= 0 ) { return null; diff --git a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java index bdef11dc7..a4f40a783 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java @@ -65,27 +65,27 @@ public class GuiComputer extends HandledScreen< protected void initTerminal( int border, int widthExtra, int heightExtra ) { - this.client.keyboard.setRepeatEvents( true ); + client.keyboard.setRepeatEvents( true ); - int termPxWidth = this.termWidth * FixedWidthFontRenderer.FONT_WIDTH; - int termPxHeight = this.termHeight * FixedWidthFontRenderer.FONT_HEIGHT; + int termPxWidth = termWidth * FixedWidthFontRenderer.FONT_WIDTH; + int termPxHeight = termHeight * FixedWidthFontRenderer.FONT_HEIGHT; - this.backgroundWidth = termPxWidth + MARGIN * 2 + border * 2 + widthExtra; - this.backgroundHeight = termPxHeight + MARGIN * 2 + border * 2 + heightExtra; + backgroundWidth = termPxWidth + MARGIN * 2 + border * 2 + widthExtra; + backgroundHeight = termPxHeight + MARGIN * 2 + border * 2 + heightExtra; super.init(); - this.terminal = new WidgetTerminal( this.client, () -> this.computer, this.termWidth, this.termHeight, MARGIN, MARGIN, MARGIN, MARGIN ); - this.terminalWrapper = new WidgetWrapper( this.terminal, MARGIN + border + this.x, MARGIN + border + this.y, termPxWidth, termPxHeight ); + terminal = new WidgetTerminal( client, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN ); + terminalWrapper = new WidgetWrapper( terminal, MARGIN + border + x, MARGIN + border + y, termPxWidth, termPxHeight ); - this.children.add( this.terminalWrapper ); - this.setFocused( this.terminalWrapper ); + children.add( terminalWrapper ); + setFocused( terminalWrapper ); } @Override protected void init() { - this.initTerminal( BORDER, 0, 0 ); + initTerminal( BORDER, 0, 0 ); } @Override @@ -93,7 +93,7 @@ public class GuiComputer extends HandledScreen< { this.renderBackground( stack ); super.render( stack, mouseX, mouseY, partialTicks ); - this.drawMouseoverTooltip( stack, mouseX, mouseY ); + drawMouseoverTooltip( stack, mouseX, mouseY ); } @Override @@ -106,35 +106,35 @@ public class GuiComputer extends HandledScreen< public void drawBackground( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY ) { // Draw terminal - this.terminal.draw( this.terminalWrapper.getX(), this.terminalWrapper.getY() ); + terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() ); // Draw a border around the terminal RenderSystem.color4f( 1, 1, 1, 1 ); - this.client.getTextureManager() - .bindTexture( ComputerBorderRenderer.getTexture( this.family ) ); - ComputerBorderRenderer.render( this.terminalWrapper.getX() - MARGIN, this.terminalWrapper.getY() - MARGIN, - this.getZOffset(), this.terminalWrapper.getWidth() + MARGIN * 2, this.terminalWrapper.getHeight() + MARGIN * 2 ); + client.getTextureManager() + .bindTexture( ComputerBorderRenderer.getTexture( family ) ); + ComputerBorderRenderer.render( terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN, + getZOffset(), terminalWrapper.getWidth() + MARGIN * 2, terminalWrapper.getHeight() + MARGIN * 2 ); } @Override public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) { - return (this.getFocused() != null && this.getFocused().mouseDragged( x, y, button, deltaX, deltaY )) || super.mouseDragged( x, y, button, deltaX, deltaY ); + return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY )) || super.mouseDragged( x, y, button, deltaX, deltaY ); } @Override public boolean mouseReleased( double mouseX, double mouseY, int button ) { - return (this.getFocused() != null && this.getFocused().mouseReleased( mouseX, mouseY, button )) || super.mouseReleased( x, y, button ); + return (getFocused() != null && getFocused().mouseReleased( mouseX, mouseY, button )) || super.mouseReleased( x, y, button ); } @Override public boolean keyPressed( int key, int scancode, int modifiers ) { // Forward the tab key to the terminal, rather than moving between controls. - if( key == GLFW.GLFW_KEY_TAB && this.getFocused() != null && this.getFocused() == this.terminalWrapper ) + if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper ) { - return this.getFocused().keyPressed( key, scancode, modifiers ); + return getFocused().keyPressed( key, scancode, modifiers ); } return super.keyPressed( key, scancode, modifiers ); @@ -144,15 +144,15 @@ public class GuiComputer extends HandledScreen< public void removed() { super.removed(); - this.children.remove( this.terminal ); - this.terminal = null; - this.client.keyboard.setRepeatEvents( false ); + children.remove( terminal ); + terminal = null; + client.keyboard.setRepeatEvents( false ); } @Override public void tick() { super.tick(); - this.terminal.update(); + terminal.update(); } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java index b098d37c5..773ac2c00 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java @@ -28,17 +28,17 @@ public class GuiDiskDrive extends HandledScreen @Override public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) { - this.renderBackground( transform ); + renderBackground( transform ); super.render( transform, mouseX, mouseY, partialTicks ); - this.drawMouseoverTooltip( transform, mouseX, mouseY ); + drawMouseoverTooltip( transform, mouseX, mouseY ); } @Override protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - this.client.getTextureManager() + client.getTextureManager() .bindTexture( BACKGROUND ); - this.drawTexture( transform, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight ); + drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight ); } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java index 48988356a..f0e29a49b 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java @@ -36,22 +36,22 @@ public class GuiPrinter extends HandledScreen @Override public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { - this.renderBackground( stack ); + renderBackground( stack ); super.render( stack, mouseX, mouseY, partialTicks ); - this.drawMouseoverTooltip( stack, mouseX, mouseY ); + drawMouseoverTooltip( stack, mouseX, mouseY ); } @Override protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - this.client.getTextureManager() + client.getTextureManager() .bindTexture( BACKGROUND ); - this.drawTexture( transform, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight ); + drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight ); - if( this.getScreenHandler().isPrinting() ) + if( getScreenHandler().isPrinting() ) { - this.drawTexture( transform, this.x + 34, this.y + 21, 176, 0, 25, 45 ); + drawTexture( transform, x + 34, y + 21, 176, 0, 25, 45 ); } } } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java index 47833b321..261948e19 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java @@ -35,7 +35,7 @@ public class GuiPrintout extends HandledScreen { super( container, player, title ); - this.backgroundHeight = Y_SIZE; + backgroundHeight = Y_SIZE; String[] text = ItemPrintout.getText( container.getStack() ); this.text = new TextBuffer[text.length]; @@ -51,9 +51,9 @@ public class GuiPrintout extends HandledScreen this.colours[i] = new TextBuffer( colours[i] ); } - this.page = 0; - this.pages = Math.max( this.text.length / ItemPrintout.LINES_PER_PAGE, 1 ); - this.book = ((ItemPrintout) container.getStack() + page = 0; + pages = Math.max( this.text.length / ItemPrintout.LINES_PER_PAGE, 1 ); + book = ((ItemPrintout) container.getStack() .getItem()).getType() == ItemPrintout.Type.BOOK; } @@ -67,9 +67,9 @@ public class GuiPrintout extends HandledScreen if( delta < 0 ) { // Scroll up goes to the next page - if( this.page < this.pages - 1 ) + if( page < pages - 1 ) { - this.page++; + page++; } return true; } @@ -77,9 +77,9 @@ public class GuiPrintout extends HandledScreen if( delta > 0 ) { // Scroll down goes to the previous page - if( this.page > 0 ) + if( page > 0 ) { - this.page--; + page--; } return true; } @@ -91,9 +91,9 @@ public class GuiPrintout extends HandledScreen public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) { // We must take the background further back in order to not overlap with our printed pages. - this.setZOffset( this.getZOffset() - 1 ); - this.renderBackground( stack ); - this.setZOffset( this.getZOffset() + 1 ); + setZOffset( getZOffset() - 1 ); + renderBackground( stack ); + setZOffset( getZOffset() + 1 ); super.render( stack, mouseX, mouseY, partialTicks ); } @@ -116,8 +116,8 @@ public class GuiPrintout extends HandledScreen .getEntityVertexConsumers(); Matrix4f matrix = transform.peek() .getModel(); - drawBorder( matrix, renderer, this.x, this.y, this.getZOffset(), this.page, this.pages, this.book ); - drawText( matrix, renderer, this.x + X_TEXT_MARGIN, this.y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * this.page, this.text, this.colours ); + drawBorder( matrix, renderer, x, y, getZOffset(), page, pages, book ); + drawText( matrix, renderer, x + X_TEXT_MARGIN, y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, text, colours ); renderer.draw(); } @@ -131,18 +131,18 @@ public class GuiPrintout extends HandledScreen if( key == GLFW.GLFW_KEY_RIGHT ) { - if( this.page < this.pages - 1 ) + if( page < pages - 1 ) { - this.page++; + page++; } return true; } if( key == GLFW.GLFW_KEY_LEFT ) { - if( this.page > 0 ) + if( page > 0 ) { - this.page--; + page--; } return true; } diff --git a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java index e7abbe333..af78829ad 100644 --- a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java +++ b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java @@ -33,29 +33,29 @@ public class GuiTurtle extends GuiComputer @Override protected void init() { - this.initTerminal( 8, 0, 80 ); + initTerminal( 8, 0, 80 ); } @Override public void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) { // Draw term - Identifier texture = this.family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL; - this.terminal.draw( this.terminalWrapper.getX(), this.terminalWrapper.getY() ); + Identifier texture = family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL; + terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() ); // Draw border/inventory RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); - this.client.getTextureManager() + client.getTextureManager() .bindTexture( texture ); - this.drawTexture( transform, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight ); + drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight ); // Draw selection slot - int slot = this.container.getSelectedSlot(); + int slot = container.getSelectedSlot(); if( slot >= 0 ) { int slotX = slot % 4; int slotY = slot / 4; - this.drawTexture( transform, this.x + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, this.y + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, + drawTexture( transform, x + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, y + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java index b0ce38000..495a98a96 100644 --- a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java +++ b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetTerminal.java @@ -74,9 +74,9 @@ public class WidgetTerminal implements Element computer.mouseClick( button + 1, charX + 1, charY + 1 ); - this.lastMouseButton = button; - this.lastMouseX = charX; - this.lastMouseY = charY; + lastMouseButton = button; + lastMouseX = charX; + lastMouseY = charY; } return true; @@ -99,14 +99,14 @@ public class WidgetTerminal implements Element charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); - if( this.lastMouseButton == button ) + if( lastMouseButton == button ) { - computer.mouseUp( this.lastMouseButton + 1, charX + 1, charY + 1 ); - this.lastMouseButton = -1; + computer.mouseUp( lastMouseButton + 1, charX + 1, charY + 1 ); + lastMouseButton = -1; } - this.lastMouseX = charX; - this.lastMouseY = charY; + lastMouseX = charX; + lastMouseY = charY; } return false; @@ -129,11 +129,11 @@ public class WidgetTerminal implements Element charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); - if( button == this.lastMouseButton && (charX != this.lastMouseX || charY != this.lastMouseY) ) + if( button == lastMouseButton && (charX != lastMouseX || charY != lastMouseY) ) { computer.mouseDrag( button + 1, charX + 1, charY + 1 ); - this.lastMouseX = charX; - this.lastMouseY = charY; + lastMouseX = charX; + lastMouseY = charY; } } @@ -159,8 +159,8 @@ public class WidgetTerminal implements Element computer.mouseScroll( delta < 0 ? 1 : -1, charX + 1, charY + 1 ); - this.lastMouseX = charX; - this.lastMouseY = charY; + lastMouseX = charX; + lastMouseY = charY; } return true; @@ -178,27 +178,27 @@ public class WidgetTerminal implements Element switch( key ) { case GLFW.GLFW_KEY_T: - if( this.terminateTimer < 0 ) + if( terminateTimer < 0 ) { - this.terminateTimer = 0; + terminateTimer = 0; } return true; case GLFW.GLFW_KEY_S: - if( this.shutdownTimer < 0 ) + if( shutdownTimer < 0 ) { - this.shutdownTimer = 0; + shutdownTimer = 0; } return true; case GLFW.GLFW_KEY_R: - if( this.rebootTimer < 0 ) + if( rebootTimer < 0 ) { - this.rebootTimer = 0; + rebootTimer = 0; } return true; case GLFW.GLFW_KEY_V: // Ctrl+V for paste - String clipboard = this.client.keyboard.getClipboard(); + String clipboard = client.keyboard.getClipboard(); if( clipboard != null ) { // Clip to the first occurrence of \r or \n @@ -226,7 +226,7 @@ public class WidgetTerminal implements Element { clipboard = clipboard.substring( 0, 512 ); } - this.queueEvent( "paste", clipboard ); + queueEvent( "paste", clipboard ); } return true; @@ -234,11 +234,11 @@ public class WidgetTerminal implements Element } } - if( key >= 0 && this.terminateTimer < 0 && this.rebootTimer < 0 && this.shutdownTimer < 0 ) + if( key >= 0 && terminateTimer < 0 && rebootTimer < 0 && shutdownTimer < 0 ) { // Queue the "key" event and add to the down set - boolean repeat = this.keysDown.get( key ); - this.keysDown.set( key ); + boolean repeat = keysDown.get( key ); + keysDown.set( key ); IComputer computer = this.computer.get(); if( computer != null ) { @@ -253,9 +253,9 @@ public class WidgetTerminal implements Element public boolean keyReleased( int key, int scancode, int modifiers ) { // Queue the "key_up" event and remove from the down set - if( key >= 0 && this.keysDown.get( key ) ) + if( key >= 0 && keysDown.get( key ) ) { - this.keysDown.set( key, false ); + keysDown.set( key, false ); IComputer computer = this.computer.get(); if( computer != null ) { @@ -266,17 +266,17 @@ public class WidgetTerminal implements Element switch( key ) { case GLFW.GLFW_KEY_T: - this.terminateTimer = -1; + terminateTimer = -1; break; case GLFW.GLFW_KEY_R: - this.rebootTimer = -1; + rebootTimer = -1; break; case GLFW.GLFW_KEY_S: - this.shutdownTimer = -1; + shutdownTimer = -1; break; case GLFW.GLFW_KEY_LEFT_CONTROL: case GLFW.GLFW_KEY_RIGHT_CONTROL: - this.terminateTimer = this.rebootTimer = this.shutdownTimer = -1; + terminateTimer = rebootTimer = shutdownTimer = -1; break; } @@ -289,7 +289,7 @@ public class WidgetTerminal implements Element if( ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255 ) // printable chars in byte range { // Queue the "char" event - this.queueEvent( "char", Character.toString( ch ) ); + queueEvent( "char", Character.toString( ch ) ); } return true; @@ -298,32 +298,32 @@ public class WidgetTerminal implements Element @Override public boolean changeFocus( boolean reversed ) { - if( this.focused ) + if( focused ) { // When blurring, we should make all keys go up - for( int key = 0; key < this.keysDown.size(); key++ ) + for( int key = 0; key < keysDown.size(); key++ ) { - if( this.keysDown.get( key ) ) + if( keysDown.get( key ) ) { - this.queueEvent( "key_up", key ); + queueEvent( "key_up", key ); } } - this.keysDown.clear(); + keysDown.clear(); // When blurring, we should make the last mouse button go up - if( this.lastMouseButton > 0 ) + if( lastMouseButton > 0 ) { IComputer computer = this.computer.get(); if( computer != null ) { - computer.mouseUp( this.lastMouseButton + 1, this.lastMouseX + 1, this.lastMouseY + 1 ); + computer.mouseUp( lastMouseButton + 1, lastMouseX + 1, lastMouseY + 1 ); } - this.lastMouseButton = -1; + lastMouseButton = -1; } - this.shutdownTimer = this.terminateTimer = this.rebootTimer = -1; + shutdownTimer = terminateTimer = rebootTimer = -1; } - this.focused = !this.focused; + focused = !focused; return true; } @@ -344,12 +344,12 @@ public class WidgetTerminal implements Element public void update() { - if( this.terminateTimer >= 0 && this.terminateTimer < TERMINATE_TIME && (this.terminateTimer += 0.05f) > TERMINATE_TIME ) + if( terminateTimer >= 0 && terminateTimer < TERMINATE_TIME && (terminateTimer += 0.05f) > TERMINATE_TIME ) { - this.queueEvent( "terminate" ); + queueEvent( "terminate" ); } - if( this.shutdownTimer >= 0 && this.shutdownTimer < TERMINATE_TIME && (this.shutdownTimer += 0.05f) > TERMINATE_TIME ) + if( shutdownTimer >= 0 && shutdownTimer < TERMINATE_TIME && (shutdownTimer += 0.05f) > TERMINATE_TIME ) { ClientComputer computer = this.computer.get(); if( computer != null ) @@ -358,7 +358,7 @@ public class WidgetTerminal implements Element } } - if( this.rebootTimer >= 0 && this.rebootTimer < TERMINATE_TIME && (this.rebootTimer += 0.05f) > TERMINATE_TIME ) + if( rebootTimer >= 0 && rebootTimer < TERMINATE_TIME && (rebootTimer += 0.05f) > TERMINATE_TIME ) { ClientComputer computer = this.computer.get(); if( computer != null ) @@ -379,21 +379,21 @@ public class WidgetTerminal implements Element public void draw( int originX, int originY ) { - synchronized( this.computer ) + synchronized( computer ) { // Draw the screen contents ClientComputer computer = this.computer.get(); Terminal terminal = computer != null ? computer.getTerminal() : null; if( terminal != null ) { - FixedWidthFontRenderer.drawTerminal( originX, originY, terminal, !computer.isColour(), this.topMargin, this.bottomMargin, this.leftMargin, - this.rightMargin ); + FixedWidthFontRenderer.drawTerminal( originX, originY, terminal, !computer.isColour(), topMargin, bottomMargin, leftMargin, + rightMargin ); } else { - FixedWidthFontRenderer.drawEmptyTerminal( originX - this.leftMargin, - originY - this.rightMargin, this.termWidth * FONT_WIDTH + this.leftMargin + this.rightMargin, - this.termHeight * FONT_HEIGHT + this.topMargin + this.bottomMargin ); + FixedWidthFontRenderer.drawEmptyTerminal( originX - leftMargin, + originY - rightMargin, termWidth * FONT_WIDTH + leftMargin + rightMargin, + termHeight * FONT_HEIGHT + topMargin + bottomMargin ); } } } diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetWrapper.java b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetWrapper.java index 3b7da58a8..c805a16ce 100644 --- a/src/main/java/dan200/computercraft/client/gui/widgets/WidgetWrapper.java +++ b/src/main/java/dan200/computercraft/client/gui/widgets/WidgetWrapper.java @@ -29,78 +29,78 @@ public class WidgetWrapper implements Element public boolean mouseClicked( double x, double y, int button ) { double dx = x - this.x, dy = y - this.y; - return dx >= 0 && dx < this.width && dy >= 0 && dy < this.height && this.listener.mouseClicked( dx, dy, button ); + return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseClicked( dx, dy, button ); } @Override public boolean mouseReleased( double x, double y, int button ) { double dx = x - this.x, dy = y - this.y; - return dx >= 0 && dx < this.width && dy >= 0 && dy < this.height && this.listener.mouseReleased( dx, dy, button ); + return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseReleased( dx, dy, button ); } @Override public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) { double dx = x - this.x, dy = y - this.y; - return dx >= 0 && dx < this.width && dy >= 0 && dy < this.height && this.listener.mouseDragged( dx, dy, button, deltaX, deltaY ); + return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseDragged( dx, dy, button, deltaX, deltaY ); } @Override public boolean mouseScrolled( double x, double y, double delta ) { double dx = x - this.x, dy = y - this.y; - return dx >= 0 && dx < this.width && dy >= 0 && dy < this.height && this.listener.mouseScrolled( dx, dy, delta ); + return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseScrolled( dx, dy, delta ); } @Override public boolean keyPressed( int key, int scancode, int modifiers ) { - return this.listener.keyPressed( key, scancode, modifiers ); + return listener.keyPressed( key, scancode, modifiers ); } @Override public boolean keyReleased( int key, int scancode, int modifiers ) { - return this.listener.keyReleased( key, scancode, modifiers ); + return listener.keyReleased( key, scancode, modifiers ); } @Override public boolean charTyped( char character, int modifiers ) { - return this.listener.charTyped( character, modifiers ); + return listener.charTyped( character, modifiers ); } @Override public boolean changeFocus( boolean b ) { - return this.listener.changeFocus( b ); + return listener.changeFocus( b ); } @Override public boolean isMouseOver( double x, double y ) { double dx = x - this.x, dy = y - this.y; - return dx >= 0 && dx < this.width && dy >= 0 && dy < this.height; + return dx >= 0 && dx < width && dy >= 0 && dy < height; } public int getX() { - return this.x; + return x; } public int getY() { - return this.y; + return y; } public int getWidth() { - return this.width; + return width; } public int getHeight() { - return this.height; + return height; } } diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java index d28e67d31..65166b05d 100644 --- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java @@ -113,13 +113,13 @@ public class ComputerBorderRenderer int endY = y + height; // Vertical bars - this.renderLine( x - BORDER, y, 0, CORNER_TOP_Y, BORDER, endY - y ); - this.renderLine( endX, y, BORDER_RIGHT_X, CORNER_TOP_Y, BORDER, endY - y ); + renderLine( x - BORDER, y, 0, CORNER_TOP_Y, BORDER, endY - y ); + renderLine( endX, y, BORDER_RIGHT_X, CORNER_TOP_Y, BORDER, endY - y ); // Top bar - this.renderLine( x, y - BORDER, 0, 0, endX - x, BORDER ); - this.renderCorner( x - BORDER, y - BORDER, CORNER_LEFT_X, CORNER_TOP_Y ); - this.renderCorner( endX, y - BORDER, CORNER_RIGHT_X, CORNER_TOP_Y ); + renderLine( x, y - BORDER, 0, 0, endX - x, BORDER ); + renderCorner( x - BORDER, y - BORDER, CORNER_LEFT_X, CORNER_TOP_Y ); + renderCorner( endX, y - BORDER, CORNER_RIGHT_X, CORNER_TOP_Y ); // Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the // pocket computer's lights). @@ -131,43 +131,43 @@ public class ComputerBorderRenderer } else { - this.renderLine( x, endY, 0, BORDER, endX - x, BORDER ); - this.renderCorner( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y ); - this.renderCorner( endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y ); + renderLine( x, endY, 0, BORDER, endX - x, BORDER ); + renderCorner( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y ); + renderCorner( endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y ); } } private void renderLine( int x, int y, int u, int v, int width, int height ) { - this.renderTexture( x, y, u, v, width, height, BORDER, BORDER ); + renderTexture( x, y, u, v, width, height, BORDER, BORDER ); } private void renderCorner( int x, int y, int u, int v ) { - this.renderTexture( x, y, u, v, BORDER, BORDER, BORDER, BORDER ); + renderTexture( x, y, u, v, BORDER, BORDER, BORDER, BORDER ); } private void renderTexture( int x, int y, int u, int v, int width, int height ) { - this.renderTexture( x, y, u, v, width, height, width, height ); + renderTexture( x, y, u, v, width, height, width, height ); } private void renderTexture( int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight ) { - this.builder.vertex( this.transform, x, y + height, this.z ) - .color( this.r, this.g, this.b, 1.0f ) + builder.vertex( transform, x, y + height, z ) + .color( r, g, b, 1.0f ) .texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .next(); - this.builder.vertex( this.transform, x + width, y + height, this.z ) - .color( this.r, this.g, this.b, 1.0f ) + builder.vertex( transform, x + width, y + height, z ) + .color( r, g, b, 1.0f ) .texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .next(); - this.builder.vertex( this.transform, x + width, y, this.z ) - .color( this.r, this.g, this.b, 1.0f ) + builder.vertex( transform, x + width, y, z ) + .color( r, g, b, 1.0f ) .texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ) .next(); - this.builder.vertex( this.transform, x, y, this.z ) - .color( this.r, this.g, this.b, 1.0f ) + builder.vertex( transform, x, y, z ) + .color( r, g, b, 1.0f ) .texture( u * TEX_SCALE, v * TEX_SCALE ) .next(); } diff --git a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java index 7d3fb152b..ed7608367 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java @@ -33,11 +33,11 @@ public abstract class ItemMapLikeRenderer transform.push(); if( hand == Hand.MAIN_HAND && player.getOffHandStack().isEmpty() ) { - this.renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack ); + renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack ); } else { - this.renderItemFirstPersonSide( transform, + renderItemFirstPersonSide( transform, render, lightTexture, hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(), @@ -89,7 +89,7 @@ public abstract class ItemMapLikeRenderer transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) ); transform.scale( 2.0F, 2.0F, 2.0F ); - this.renderItem( transform, render, stack ); + renderItem( transform, render, stack ); } /** @@ -133,7 +133,7 @@ public abstract class ItemMapLikeRenderer transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( f2 * -45f ) ); transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) ); - this.renderItem( transform, render, stack ); + renderItem( transform, render, stack ); transform.pop(); } diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java index 2c40576e4..5c0c1a879 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java @@ -229,7 +229,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer } case VBO: - { VertexBuffer vbo = monitor.buffer; if( redraw ) { @@ -259,7 +258,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer FixedWidthFontRenderer.TYPE.getVertexFormat() .endDrawing(); break; - } } } } diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java index e788540db..5d6eceea6 100644 --- a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java @@ -116,7 +116,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer // Render the label String label = turtle.createProxy() .getLabel(); - HitResult hit = this.dispatcher.crosshairTarget; + HitResult hit = dispatcher.crosshairTarget; if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getPos() .equals( ((BlockHitResult) hit).getBlockPos() ) ) { diff --git a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java index 2012b4b17..1882ac2bd 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleModelLoader.java @@ -76,7 +76,7 @@ public final class TurtleModelLoader public Collection getTextureDependencies( Function modelGetter, Set> missingTextureErrors ) { - return this.getModelDependencies() + return getModelDependencies() .stream() .flatMap( x -> modelGetter.apply( x ) .getTextureDependencies( modelGetter, missingTextureErrors ) @@ -88,14 +88,14 @@ public final class TurtleModelLoader @Override public Collection getModelDependencies() { - return Arrays.asList( this.family, COLOUR_TURTLE_MODEL ); + return Arrays.asList( family, COLOUR_TURTLE_MODEL ); } @Override public BakedModel bake( @Nonnull ModelLoader loader, @Nonnull Function spriteGetter, @Nonnull ModelBakeSettings state, Identifier modelId ) { - return new TurtleSmartItemModel( loader.getOrLoadModel( this.family ) + return new TurtleSmartItemModel( loader.getOrLoadModel( family ) .bake( loader, spriteGetter, state, modelId ), loader.getOrLoadModel( COLOUR_TURTLE_MODEL ) .bake( loader, spriteGetter, state, modelId ) ); diff --git a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java index df3e83669..e58ac12f4 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java @@ -13,6 +13,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.json.ModelOverrideList; +import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.AffineTransformation; import net.minecraft.util.math.Direction; @@ -48,19 +49,19 @@ public class TurtleMultiModel implements BakedModel { if( side != null ) { - if( !this.faceQuads.containsKey( side ) ) + if( !faceQuads.containsKey( side ) ) { - this.faceQuads.put( side, this.buildQuads( state, side, rand ) ); + faceQuads.put( side, buildQuads( state, side, rand ) ); } - return this.faceQuads.get( side ); + return faceQuads.get( side ); } else { - if( this.generalQuads == null ) + if( generalQuads == null ) { - this.generalQuads = this.buildQuads( state, side, rand ); + generalQuads = buildQuads( state, side, rand ); } - return this.generalQuads; + return generalQuads; } } @@ -69,22 +70,22 @@ public class TurtleMultiModel implements BakedModel ArrayList quads = new ArrayList<>(); - ModelTransformer.transformQuadsTo( quads, this.baseModel.getQuads( state, side, rand ), this.generalTransform.getMatrix() ); - if( this.overlayModel != null ) + ModelTransformer.transformQuadsTo( quads, baseModel.getQuads( state, side, rand ), generalTransform.getMatrix() ); + if( overlayModel != null ) { - ModelTransformer.transformQuadsTo( quads, this.overlayModel.getQuads( state, side, rand ), this.generalTransform.getMatrix() ); + ModelTransformer.transformQuadsTo( quads, overlayModel.getQuads( state, side, rand ), generalTransform.getMatrix() ); } - if( this.leftUpgradeModel != null ) + if( leftUpgradeModel != null ) { - AffineTransformation upgradeTransform = this.generalTransform.multiply( this.leftUpgradeModel.getMatrix() ); - ModelTransformer.transformQuadsTo( quads, this.leftUpgradeModel.getModel() + AffineTransformation upgradeTransform = generalTransform.multiply( leftUpgradeModel.getMatrix() ); + ModelTransformer.transformQuadsTo( quads, leftUpgradeModel.getModel() .getQuads( state, side, rand ), upgradeTransform.getMatrix() ); } - if( this.rightUpgradeModel != null ) + if( rightUpgradeModel != null ) { - AffineTransformation upgradeTransform = this.generalTransform.multiply( this.rightUpgradeModel.getMatrix() ); - ModelTransformer.transformQuadsTo( quads, this.rightUpgradeModel.getModel() + AffineTransformation upgradeTransform = generalTransform.multiply( rightUpgradeModel.getMatrix() ); + ModelTransformer.transformQuadsTo( quads, rightUpgradeModel.getModel() .getQuads( state, side, rand ), upgradeTransform.getMatrix() ); } @@ -95,25 +96,25 @@ public class TurtleMultiModel implements BakedModel @Override public boolean useAmbientOcclusion() { - return this.baseModel.useAmbientOcclusion(); + return baseModel.useAmbientOcclusion(); } @Override public boolean hasDepth() { - return this.baseModel.hasDepth(); + return baseModel.hasDepth(); } @Override public boolean isSideLit() { - return this.baseModel.isSideLit(); + return baseModel.isSideLit(); } @Override public boolean isBuiltin() { - return this.baseModel.isBuiltin(); + return baseModel.isBuiltin(); } @Nonnull @@ -121,15 +122,15 @@ public class TurtleMultiModel implements BakedModel @Deprecated public Sprite getSprite() { - return this.baseModel.getSprite(); + return baseModel.getSprite(); } @Nonnull @Override @Deprecated - public net.minecraft.client.render.model.json.ModelTransformation getTransformation() + public ModelTransformation getTransformation() { - return this.baseModel.getTransformation(); + return baseModel.getTransformation(); } @Nonnull diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java index d0056ec90..85e559106 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java @@ -66,7 +66,7 @@ public class TurtleSmartItemModel implements BakedModel this.colourModel = colourModel; // this actually works I think, trust me - this.overrides = new ModelOverrideList( null, null, null, Collections.emptyList() ) + overrides = new ModelOverrideList( null, null, null, Collections.emptyList() ) { @Nonnull @Override @@ -85,10 +85,10 @@ public class TurtleSmartItemModel implements BakedModel boolean flip = false; TurtleModelCombination combo = new TurtleModelCombination( colour != -1, leftUpgrade, rightUpgrade, overlay, christmas, flip ); - BakedModel model = TurtleSmartItemModel.this.cachedModels.get( combo ); + BakedModel model = cachedModels.get( combo ); if( model == null ) { - TurtleSmartItemModel.this.cachedModels.put( combo, model = TurtleSmartItemModel.this.buildModel( combo ) ); + cachedModels.put( combo, model = buildModel( combo ) ); } return model; } @@ -103,7 +103,7 @@ public class TurtleSmartItemModel implements BakedModel .getModelManager(); ModelIdentifier overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.overlay, combo.christmas ); - BakedModel baseModel = combo.colour ? this.colourModel : this.familyModel; + BakedModel baseModel = combo.colour ? colourModel : familyModel; BakedModel overlayModel = overlayModelLocation != null ? modelManager.getModel( overlayModelLocation ) : null; AffineTransformation transform = combo.flip ? flip : identity; TransformedModel leftModel = combo.leftUpgrade != null ? combo.leftUpgrade.getModel( null, TurtleSide.LEFT ) : null; @@ -116,31 +116,31 @@ public class TurtleSmartItemModel implements BakedModel @Deprecated public List getQuads( BlockState state, Direction facing, @Nonnull Random rand ) { - return this.familyModel.getQuads( state, facing, rand ); + return familyModel.getQuads( state, facing, rand ); } @Override public boolean useAmbientOcclusion() { - return this.familyModel.useAmbientOcclusion(); + return familyModel.useAmbientOcclusion(); } @Override public boolean hasDepth() { - return this.familyModel.hasDepth(); + return familyModel.hasDepth(); } @Override public boolean isSideLit() { - return this.familyModel.isSideLit(); + return familyModel.isSideLit(); } @Override public boolean isBuiltin() { - return this.familyModel.isBuiltin(); + return familyModel.isBuiltin(); } @Nonnull @@ -148,7 +148,7 @@ public class TurtleSmartItemModel implements BakedModel @Deprecated public Sprite getSprite() { - return this.familyModel.getSprite(); + return familyModel.getSprite(); } @Nonnull @@ -156,14 +156,14 @@ public class TurtleSmartItemModel implements BakedModel @Deprecated public ModelTransformation getTransformation() { - return this.familyModel.getTransformation(); + return familyModel.getTransformation(); } @Nonnull @Override public ModelOverrideList getOverrides() { - return this.overrides; + return overrides; } private static class TurtleModelCombination @@ -191,12 +191,12 @@ public class TurtleSmartItemModel implements BakedModel { final int prime = 31; int result = 0; - result = prime * result + (this.colour ? 1 : 0); - result = prime * result + (this.leftUpgrade != null ? this.leftUpgrade.hashCode() : 0); - result = prime * result + (this.rightUpgrade != null ? this.rightUpgrade.hashCode() : 0); - result = prime * result + (this.overlay != null ? this.overlay.hashCode() : 0); - result = prime * result + (this.christmas ? 1 : 0); - result = prime * result + (this.flip ? 1 : 0); + result = prime * result + (colour ? 1 : 0); + result = prime * result + (leftUpgrade != null ? leftUpgrade.hashCode() : 0); + result = prime * result + (rightUpgrade != null ? rightUpgrade.hashCode() : 0); + result = prime * result + (overlay != null ? overlay.hashCode() : 0); + result = prime * result + (christmas ? 1 : 0); + result = prime * result + (flip ? 1 : 0); return result; } @@ -213,8 +213,8 @@ public class TurtleSmartItemModel implements BakedModel } TurtleModelCombination otherCombo = (TurtleModelCombination) other; - return otherCombo.colour == this.colour && otherCombo.leftUpgrade == this.leftUpgrade && otherCombo.rightUpgrade == this.rightUpgrade && Objects.equal( - otherCombo.overlay, this.overlay ) && otherCombo.christmas == this.christmas && otherCombo.flip == this.flip; + return otherCombo.colour == colour && otherCombo.leftUpgrade == leftUpgrade && otherCombo.rightUpgrade == rightUpgrade && Objects.equal( + otherCombo.overlay, overlay ) && otherCombo.christmas == christmas && otherCombo.flip == flip; } } diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index 5cd6b9e2c..6d1e5f2f6 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -344,11 +344,9 @@ public class FSAPI implements ILuaAPI return new Object[] { new EncodedWritableHandle( writer.get(), writer ) }; } case "rb": - { // Open the file for binary reading, then create a wrapper around the reader FileSystemWrapper reader = fileSystem.openForRead( path, Function.identity() ); return new Object[] { BinaryReadableHandle.of( reader.get(), reader ) }; - } case "wb": { // Open the file for binary writing, then create a wrapper around the writer @@ -356,11 +354,9 @@ public class FSAPI implements ILuaAPI return new Object[] { BinaryWritableHandle.of( writer.get(), writer ) }; } case "ab": - { // Open the file for binary appending, then create a wrapper around the reader FileSystemWrapper writer = fileSystem.openForWrite( path, true, Function.identity() ); return new Object[] { BinaryWritableHandle.of( writer.get(), writer ) }; - } default: throw new LuaException( "Unsupported mode" ); } diff --git a/src/main/java/dan200/computercraft/core/apis/OSAPI.java b/src/main/java/dan200/computercraft/core/apis/OSAPI.java index 9b59ffcef..0ef4899bc 100644 --- a/src/main/java/dan200/computercraft/core/apis/OSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/OSAPI.java @@ -403,11 +403,9 @@ public class OSAPI implements ILuaAPI return getEpochForCalendar( c ); } case "local": - { // Get local epoch Calendar c = Calendar.getInstance(); return getEpochForCalendar( c ); - } case "ingame": // Get in-game epoch synchronized( alarms ) diff --git a/src/main/java/dan200/computercraft/core/apis/http/NetworkUtils.java b/src/main/java/dan200/computercraft/core/apis/http/NetworkUtils.java index f3804f847..cbbaf20c5 100644 --- a/src/main/java/dan200/computercraft/core/apis/http/NetworkUtils.java +++ b/src/main/java/dan200/computercraft/core/apis/http/NetworkUtils.java @@ -108,7 +108,7 @@ public final class NetworkUtils } /** - * Create a {@link InetSocketAddress} from a {@link java.net.URI}. + * Create a {@link InetSocketAddress} from a {@link URI}. * * Note, this may require a DNS lookup, and so should not be executed on the main CC thread. * diff --git a/src/main/java/dan200/computercraft/core/asm/Generator.java b/src/main/java/dan200/computercraft/core/asm/Generator.java index cdc966044..e68732f95 100644 --- a/src/main/java/dan200/computercraft/core/asm/Generator.java +++ b/src/main/java/dan200/computercraft/core/asm/Generator.java @@ -66,7 +66,7 @@ public final class Generator { this.base = base; this.context = context; - this.interfaces = new String[] { Type.getInternalName( base ) }; + interfaces = new String[] { Type.getInternalName( base ) }; this.wrap = wrap; StringBuilder methodDesc = new StringBuilder().append( "(Ljava/lang/Object;" ); diff --git a/src/main/java/dan200/computercraft/core/asm/Reflect.java b/src/main/java/dan200/computercraft/core/asm/Reflect.java index 4517fecc3..5504f3bc8 100644 --- a/src/main/java/dan200/computercraft/core/asm/Reflect.java +++ b/src/main/java/dan200/computercraft/core/asm/Reflect.java @@ -18,7 +18,7 @@ import static org.objectweb.asm.Opcodes.ICONST_0; final class Reflect { - static final java.lang.reflect.Type OPTIONAL_IN = Optional.class.getTypeParameters()[0]; + static final Type OPTIONAL_IN = Optional.class.getTypeParameters()[0]; private Reflect() { @@ -57,7 +57,7 @@ final class Reflect ParameterizedType type = (ParameterizedType) underlying; if( !allowParameter ) { - for( java.lang.reflect.Type arg : type.getActualTypeArguments() ) + for( Type arg : type.getActualTypeArguments() ) { if( arg instanceof WildcardType ) continue; if( arg instanceof TypeVariable && ((TypeVariable) arg).getName().startsWith( "capture#" ) ) diff --git a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java index 0131e33b2..2a5ad299f 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java @@ -313,7 +313,7 @@ public final class ResourceMount implements IMount prepareProfiler.push( "Mount reloading" ); try { - for( ResourceMount mount : this.mounts ) mount.load(); + for( ResourceMount mount : mounts ) mount.load(); } finally { diff --git a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java index 54a7efdc6..82093db4e 100644 --- a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java @@ -64,7 +64,7 @@ public class CobaltLuaMachine implements ILuaMachine { this.computer = computer; this.timeout = timeout; - this.context = new LuaContext( computer ); + context = new LuaContext( computer ); debug = new TimeoutDebugHandler(); // Create an environment to run in @@ -367,7 +367,6 @@ public class CobaltLuaMachine implements ILuaMachine case Constants.TSTRING: return value.toString(); case Constants.TTABLE: - { // Table: // Start remembering stuff if( objects == null ) @@ -409,7 +408,6 @@ public class CobaltLuaMachine implements ILuaMachine } } return table; - } default: return null; } diff --git a/src/main/java/dan200/computercraft/core/terminal/Terminal.java b/src/main/java/dan200/computercraft/core/terminal/Terminal.java index d09e984de..9b8894757 100644 --- a/src/main/java/dan200/computercraft/core/terminal/Terminal.java +++ b/src/main/java/dan200/computercraft/core/terminal/Terminal.java @@ -44,9 +44,9 @@ public class Terminal this.height = height; onChanged = changedCallback; - text = new TextBuffer[this.height]; - textColour = new TextBuffer[this.height]; - backgroundColour = new TextBuffer[this.height]; + text = new TextBuffer[height]; + textColour = new TextBuffer[height]; + backgroundColour = new TextBuffer[height]; for( int i = 0; i < this.height; i++ ) { text[i] = new TextBuffer( ' ', this.width ); @@ -93,9 +93,9 @@ public class Terminal this.width = width; this.height = height; - text = new TextBuffer[this.height]; - textColour = new TextBuffer[this.height]; - backgroundColour = new TextBuffer[this.height]; + text = new TextBuffer[height]; + textColour = new TextBuffer[height]; + backgroundColour = new TextBuffer[height]; for( int i = 0; i < this.height; i++ ) { if( i >= oldHeight ) diff --git a/src/main/java/dan200/computercraft/core/terminal/TextBuffer.java b/src/main/java/dan200/computercraft/core/terminal/TextBuffer.java index d042a2b34..1c399764b 100644 --- a/src/main/java/dan200/computercraft/core/terminal/TextBuffer.java +++ b/src/main/java/dan200/computercraft/core/terminal/TextBuffer.java @@ -12,7 +12,7 @@ public class TextBuffer public TextBuffer( char c, int length ) { text = new char[length]; - this.fill( c ); + fill( c ); } public TextBuffer( String text ) diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java index c4fba913c..4d8c34bf0 100644 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java +++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java @@ -32,7 +32,7 @@ public class MixinWorld @Inject( method = "setBlockEntity", at = @At( "HEAD" ) ) public void setBlockEntity( BlockPos pos, @Nullable BlockEntity entity, CallbackInfo info ) { - if( !World.isOutOfBuildLimitVertically( pos ) && entity != null && !entity.isRemoved() && this.iteratingTickingBlockEntities ) + if( !World.isOutOfBuildLimitVertically( pos ) && entity != null && !entity.isRemoved() && iteratingTickingBlockEntities ) { setWorld( entity, this ); } @@ -49,7 +49,7 @@ public class MixinWorld @Inject( method = "addBlockEntities", at = @At( "HEAD" ) ) public void addBlockEntities( Collection entities, CallbackInfo info ) { - if( this.iteratingTickingBlockEntities ) + if( iteratingTickingBlockEntities ) { for( BlockEntity entity : entities ) { diff --git a/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java b/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java index 255f2d68b..f59b40577 100644 --- a/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java +++ b/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java @@ -27,11 +27,11 @@ public final class TurtleUpgrades Wrapper( ITurtleUpgrade upgrade ) { this.upgrade = upgrade; - this.id = upgrade.getUpgradeID() + id = upgrade.getUpgradeID() .toString(); // TODO This should be the mod id of the mod the peripheral comes from - this.modId = ComputerCraft.MOD_ID; - this.enabled = true; + modId = ComputerCraft.MOD_ID; + enabled = true; } } diff --git a/src/main/java/dan200/computercraft/shared/command/arguments/ChoiceArgumentType.java b/src/main/java/dan200/computercraft/shared/command/arguments/ChoiceArgumentType.java index aa6e48fea..642b5af10 100644 --- a/src/main/java/dan200/computercraft/shared/command/arguments/ChoiceArgumentType.java +++ b/src/main/java/dan200/computercraft/shared/command/arguments/ChoiceArgumentType.java @@ -40,7 +40,7 @@ public abstract class ChoiceArgumentType implements ArgumentType int start = reader.getCursor(); String name = reader.readUnquotedString(); - for( T choice : this.choices ) + for( T choice : choices ) { String choiceName = this.name.apply( choice ); if( name.equals( choiceName ) ) @@ -50,7 +50,7 @@ public abstract class ChoiceArgumentType implements ArgumentType } reader.setCursor( start ); - throw this.exception.createWithContext( reader, name ); + throw exception.createWithContext( reader, name ); } @Override @@ -58,7 +58,7 @@ public abstract class ChoiceArgumentType implements ArgumentType { String remaining = builder.getRemaining() .toLowerCase( Locale.ROOT ); - for( T choice : this.choices ) + for( T choice : choices ) { String name = this.name.apply( choice ); if( !name.toLowerCase( Locale.ROOT ) @@ -66,7 +66,7 @@ public abstract class ChoiceArgumentType implements ArgumentType { continue; } - builder.suggest( name, this.tooltip.apply( choice ) ); + builder.suggest( name, tooltip.apply( choice ) ); } return builder.buildFuture(); @@ -75,10 +75,10 @@ public abstract class ChoiceArgumentType implements ArgumentType @Override public Collection getExamples() { - List items = this.choices instanceof Collection ? new ArrayList<>( ((Collection) this.choices).size() ) : new ArrayList<>(); - for( T choice : this.choices ) + List items = choices instanceof Collection ? new ArrayList<>( ((Collection) choices).size() ) : new ArrayList<>(); + for( T choice : choices ) { - items.add( this.name.apply( choice ) ); + items.add( name.apply( choice ) ); } items.sort( Comparator.naturalOrder() ); return items; diff --git a/src/main/java/dan200/computercraft/shared/command/arguments/ComputersArgumentType.java b/src/main/java/dan200/computercraft/shared/command/arguments/ComputersArgumentType.java index e69ae8558..db7900c2f 100644 --- a/src/main/java/dan200/computercraft/shared/command/arguments/ComputersArgumentType.java +++ b/src/main/java/dan200/computercraft/shared/command/arguments/ComputersArgumentType.java @@ -105,7 +105,7 @@ public final class ComputersArgumentType implements ArgumentType implements ArgumentType> } int startParse = reader.getCursor(); - this.appender.accept( out, this.child.parse( reader ) ); + appender.accept( out, child.parse( reader ) ); hadSome = true; if( reader.getCursor() == startParse ) { - throw new IllegalStateException( this.child + " did not consume any input on " + reader.getRemaining() ); + throw new IllegalStateException( child + " did not consume any input on " + reader.getRemaining() ); } } @@ -93,7 +93,7 @@ public final class RepeatArgumentType implements ArgumentType> // We should probably review that this is sensible in the future. if( !hadSome ) { - throw this.some.createWithContext( reader ); + throw some.createWithContext( reader ); } return Collections.unmodifiableList( out ); @@ -109,7 +109,7 @@ public final class RepeatArgumentType implements ArgumentType> { try { - this.child.parse( reader ); + child.parse( reader ); } catch( CommandSyntaxException e ) { @@ -126,13 +126,13 @@ public final class RepeatArgumentType implements ArgumentType> } reader.setCursor( previous ); - return this.child.listSuggestions( context, builder.createOffset( previous ) ); + return child.listSuggestions( context, builder.createOffset( previous ) ); } @Override public Collection getExamples() { - return this.child.getExamples(); + return child.getExamples(); } public static class Serializer implements ArgumentSerializer> diff --git a/src/main/java/dan200/computercraft/shared/command/builder/CommandBuilder.java b/src/main/java/dan200/computercraft/shared/command/builder/CommandBuilder.java index 901e97eb3..72233bd69 100644 --- a/src/main/java/dan200/computercraft/shared/command/builder/CommandBuilder.java +++ b/src/main/java/dan200/computercraft/shared/command/builder/CommandBuilder.java @@ -48,58 +48,58 @@ public class CommandBuilder implements CommandNodeBuilder> public CommandBuilder requires( Predicate predicate ) { - this.requires = this.requires == null ? predicate : this.requires.and( predicate ); + requires = requires == null ? predicate : requires.and( predicate ); return this; } public CommandBuilder arg( String name, ArgumentType type ) { - this.args.add( RequiredArgumentBuilder.argument( name, type ) ); + args.add( RequiredArgumentBuilder.argument( name, type ) ); return this; } public CommandNodeBuilder>> argManyValue( String name, ArgumentType type, T defaultValue ) { - return this.argManyValue( name, type, Collections.singletonList( defaultValue ) ); + return argManyValue( name, type, Collections.singletonList( defaultValue ) ); } public CommandNodeBuilder>> argManyValue( String name, ArgumentType type, List empty ) { - return this.argMany( name, type, () -> empty ); + return argMany( name, type, () -> empty ); } public CommandNodeBuilder>> argMany( String name, ArgumentType type, Supplier> empty ) { - return this.argMany( name, RepeatArgumentType.some( type, ARGUMENT_EXPECTED ), empty ); + return argMany( name, RepeatArgumentType.some( type, ARGUMENT_EXPECTED ), empty ); } private CommandNodeBuilder>> argMany( String name, RepeatArgumentType type, Supplier> empty ) { - if( this.args.isEmpty() ) + if( args.isEmpty() ) { throw new IllegalStateException( "Cannot have empty arg chain builder" ); } return command -> { // The node for no arguments - ArgumentBuilder tail = this.tail( ctx -> command.run( ctx, empty.get() ) ); + ArgumentBuilder tail = tail( ctx -> command.run( ctx, empty.get() ) ); // The node for one or more arguments ArgumentBuilder moreArg = RequiredArgumentBuilder.>argument( name, type ).executes( ctx -> command.run( ctx, getList( ctx, name ) ) ); // Chain all of them together! tail.then( moreArg ); - return this.link( tail ); + return link( tail ); }; } private ArgumentBuilder tail( Command command ) { - ArgumentBuilder defaultTail = this.args.get( this.args.size() - 1 ); + ArgumentBuilder defaultTail = args.get( args.size() - 1 ); defaultTail.executes( command ); - if( this.requires != null ) + if( requires != null ) { - defaultTail.requires( this.requires ); + defaultTail.requires( requires ); } return defaultTail; } @@ -112,9 +112,9 @@ public class CommandBuilder implements CommandNodeBuilder> private CommandNode link( ArgumentBuilder tail ) { - for( int i = this.args.size() - 2; i >= 0; i-- ) + for( int i = args.size() - 2; i >= 0; i-- ) { - tail = this.args.get( i ) + tail = args.get( i ) .then( tail ); } return tail.build(); @@ -122,17 +122,17 @@ public class CommandBuilder implements CommandNodeBuilder> public CommandNodeBuilder>> argManyFlatten( String name, ArgumentType> type, Supplier> empty ) { - return this.argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty ); + return argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty ); } @Override public CommandNode executes( Command command ) { - if( this.args.isEmpty() ) + if( args.isEmpty() ) { throw new IllegalStateException( "Cannot have empty arg chain builder" ); } - return this.link( this.tail( command ) ); + return link( tail( command ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java b/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java index 58767e62d..98461eb45 100644 --- a/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java +++ b/src/main/java/dan200/computercraft/shared/command/builder/HelpingArgumentBuilder.java @@ -107,14 +107,14 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder then( final ArgumentBuilder argument ) { - if( this.getRedirect() != null ) + if( getRedirect() != null ) { throw new IllegalStateException( "Cannot add children to a redirected node" ); } if( argument instanceof HelpingArgumentBuilder ) { - this.children.add( (HelpingArgumentBuilder) argument ); + children.add( (HelpingArgumentBuilder) argument ); } else if( argument instanceof LiteralArgumentBuilder ) { @@ -147,25 +147,25 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder build() { - return this.buildImpl( this.getLiteral().replace( '-', '_' ), this.getLiteral() ); + return buildImpl( getLiteral().replace( '-', '_' ), getLiteral() ); } private LiteralCommandNode build( @Nonnull String id, @Nonnull String command ) { - return this.buildImpl( id + "." + this.getLiteral().replace( '-', '_' ), command + " " + this.getLiteral() ); + return buildImpl( id + "." + getLiteral().replace( '-', '_' ), command + " " + getLiteral() ); } private LiteralCommandNode buildImpl( String id, String command ) { HelpCommand helpCommand = new HelpCommand( id, command ); - LiteralCommandNode node = new LiteralCommandNode<>( this.getLiteral(), - helpCommand, this.getRequirement(), - this.getRedirect(), this.getRedirectModifier(), this.isFork() ); + LiteralCommandNode node = new LiteralCommandNode<>( getLiteral(), + helpCommand, getRequirement(), + getRedirect(), getRedirectModifier(), isFork() ); helpCommand.node = node; // Set up a /... help command LiteralArgumentBuilder helpNode = - LiteralArgumentBuilder.literal( "help" ).requires( x -> this.getArguments().stream() + LiteralArgumentBuilder.literal( "help" ).requires( x -> getArguments().stream() .anyMatch( y -> y.getRequirement() .test( @@ -173,7 +173,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder child : this.getArguments() ) + for( CommandNode child : getArguments() ) { node.addChild( child ); @@ -183,7 +183,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder child = childBuilder.build( id, command ); node.addChild( child ); @@ -214,7 +214,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder context ) { context.getSource() - .sendFeedback( getHelp( context, this.node, this.id, this.command ), false ); + .sendFeedback( getHelp( context, node, id, command ), false ); return 0; } } diff --git a/src/main/java/dan200/computercraft/shared/command/text/ServerTableFormatter.java b/src/main/java/dan200/computercraft/shared/command/text/ServerTableFormatter.java index 4a48e8391..fe8ee5b7c 100644 --- a/src/main/java/dan200/computercraft/shared/command/text/ServerTableFormatter.java +++ b/src/main/java/dan200/computercraft/shared/command/text/ServerTableFormatter.java @@ -26,7 +26,7 @@ public class ServerTableFormatter implements TableFormatter @Nullable public Text getPadding( Text component, int width ) { - int extraWidth = width - this.getWidth( component ); + int extraWidth = width - getWidth( component ); if( extraWidth <= 0 ) { return null; @@ -50,6 +50,6 @@ public class ServerTableFormatter implements TableFormatter @Override public void writeLine( int id, Text component ) { - this.source.sendFeedback( component, false ); + source.sendFeedback( component, false ); } } diff --git a/src/main/java/dan200/computercraft/shared/command/text/TableBuilder.java b/src/main/java/dan200/computercraft/shared/command/text/TableBuilder.java index 800068e29..c65c58294 100644 --- a/src/main/java/dan200/computercraft/shared/command/text/TableBuilder.java +++ b/src/main/java/dan200/computercraft/shared/command/text/TableBuilder.java @@ -34,7 +34,7 @@ public class TableBuilder } this.id = id; this.headers = headers; - this.columns = headers.length; + columns = headers.length; } public TableBuilder( int id ) @@ -44,7 +44,7 @@ public class TableBuilder throw new IllegalArgumentException( "ID must be positive" ); } this.id = id; - this.headers = null; + headers = null; } public TableBuilder( int id, @Nonnull String... headers ) @@ -55,7 +55,7 @@ public class TableBuilder } this.id = id; this.headers = new Text[headers.length]; - this.columns = headers.length; + columns = headers.length; for( int i = 0; i < headers.length; i++ ) { @@ -65,15 +65,15 @@ public class TableBuilder public void row( @Nonnull Text... row ) { - if( this.columns == -1 ) + if( columns == -1 ) { - this.columns = row.length; + columns = row.length; } - if( row.length != this.columns ) + if( row.length != columns ) { throw new IllegalArgumentException( "Row is the incorrect length" ); } - this.rows.add( row ); + rows.add( row ); } /** @@ -85,7 +85,7 @@ public class TableBuilder */ public int getId() { - return this.id; + return id; } /** @@ -97,24 +97,24 @@ public class TableBuilder */ public int getColumns() { - return this.columns; + return columns; } @Nullable public Text[] getHeaders() { - return this.headers; + return headers; } @Nonnull public List getRows() { - return this.rows; + return rows; } public int getAdditional() { - return this.additional; + return additional; } public void setAdditional( int additional ) @@ -126,12 +126,12 @@ public class TableBuilder { if( CommandUtils.isPlayer( source ) ) { - this.trim( 18 ); + trim( 18 ); NetworkHandler.sendToPlayer( (ServerPlayerEntity) source.getEntity(), new ChatTableClientMessage( this ) ); } else { - this.trim( 100 ); + trim( 100 ); new ServerTableFormatter( source ).display( this ); } } @@ -143,10 +143,10 @@ public class TableBuilder */ public void trim( int height ) { - if( this.rows.size() > height ) + if( rows.size() > height ) { - this.additional += this.rows.size() - height - 1; - this.rows.subList( height - 1, this.rows.size() ) + additional += rows.size() - height - 1; + rows.subList( height - 1, rows.size() ) .clear(); } } diff --git a/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java b/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java index ae11ae058..3c942e2d8 100644 --- a/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java +++ b/src/main/java/dan200/computercraft/shared/command/text/TableFormatter.java @@ -37,7 +37,7 @@ public interface TableFormatter { for( int i = 0; i < columns; i++ ) { - maxWidths[i] = this.getWidth( headers[i] ); + maxWidths[i] = getWidth( headers[i] ); } } @@ -45,7 +45,7 @@ public interface TableFormatter { for( int i = 0; i < row.length; i++ ) { - int width = this.getWidth( row[i] ); + int width = getWidth( row[i] ); if( width > maxWidths[i] ) { maxWidths[i] = width; @@ -55,7 +55,7 @@ public interface TableFormatter // Add a small amount of padding after each column { - int padding = this.getColumnPadding(); + int padding = getColumnPadding(); for( int i = 0; i < maxWidths.length - 1; i++ ) { maxWidths[i] += padding; @@ -63,7 +63,7 @@ public interface TableFormatter } // And compute the total width - int totalWidth = (columns - 1) * this.getWidth( SEPARATOR ); + int totalWidth = (columns - 1) * getWidth( SEPARATOR ); for( int x : maxWidths ) { totalWidth += x; @@ -75,7 +75,7 @@ public interface TableFormatter for( int i = 0; i < columns - 1; i++ ) { line.append( headers[i] ); - Text padding = this.getPadding( headers[i], maxWidths[i] ); + Text padding = getPadding( headers[i], maxWidths[i] ); if( padding != null ) { line.append( padding ); @@ -84,13 +84,13 @@ public interface TableFormatter } line.append( headers[columns - 1] ); - this.writeLine( rowId++, line ); + writeLine( rowId++, line ); // Write a separator line. We round the width up rather than down to make // it a tad prettier. - int rowCharWidth = this.getWidth( HEADER ); + int rowCharWidth = getWidth( HEADER ); int rowWidth = totalWidth / rowCharWidth + (totalWidth % rowCharWidth == 0 ? 0 : 1); - this.writeLine( rowId++, coloured( StringUtils.repeat( HEADER.getString(), rowWidth ), Formatting.GRAY ) ); + writeLine( rowId++, coloured( StringUtils.repeat( HEADER.getString(), rowWidth ), Formatting.GRAY ) ); } for( Text[] row : table.getRows() ) @@ -99,7 +99,7 @@ public interface TableFormatter for( int i = 0; i < columns - 1; i++ ) { line.append( row[i] ); - Text padding = this.getPadding( row[i], maxWidths[i] ); + Text padding = getPadding( row[i], maxWidths[i] ); if( padding != null ) { line.append( padding ); @@ -107,12 +107,12 @@ public interface TableFormatter line.append( SEPARATOR ); } line.append( row[columns - 1] ); - this.writeLine( rowId++, line ); + writeLine( rowId++, line ); } if( table.getAdditional() > 0 ) { - this.writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), Formatting.AQUA ) ); + writeLine( rowId++, coloured( translate( "commands.computercraft.generic.additional_rows", table.getAdditional() ), Formatting.AQUA ) ); } return rowId - table.getId(); diff --git a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java index 5b5ce5a32..4781320ac 100644 --- a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java +++ b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java @@ -96,6 +96,6 @@ public abstract class BlockGeneric extends BlockWithEntity @Override public BlockEntity createBlockEntity( @Nonnull BlockView world ) { - return this.type.instantiate(); + return type.instantiate(); } } diff --git a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java index 30a8d0679..be189e35e 100644 --- a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java +++ b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java @@ -19,14 +19,14 @@ public class ClientTerminal implements ITerminal public ClientTerminal( boolean colour ) { this.colour = colour; - this.terminal = null; - this.terminalChanged = false; + terminal = null; + terminalChanged = false; } public boolean pollTerminalChanged() { - boolean changed = this.terminalChanged; - this.terminalChanged = false; + boolean changed = terminalChanged; + terminalChanged = false; return changed; } @@ -35,63 +35,63 @@ public class ClientTerminal implements ITerminal @Override public Terminal getTerminal() { - return this.terminal; + return terminal; } @Override public boolean isColour() { - return this.colour; + return colour; } public void read( TerminalState state ) { - this.colour = state.colour; + colour = state.colour; if( state.hasTerminal() ) { - this.resizeTerminal( state.width, state.height ); - state.apply( this.terminal ); + resizeTerminal( state.width, state.height ); + state.apply( terminal ); } else { - this.deleteTerminal(); + deleteTerminal(); } } private void resizeTerminal( int width, int height ) { - if( this.terminal == null ) + if( terminal == null ) { - this.terminal = new Terminal( width, height, () -> this.terminalChanged = true ); - this.terminalChanged = true; + terminal = new Terminal( width, height, () -> terminalChanged = true ); + terminalChanged = true; } else { - this.terminal.resize( width, height ); + terminal.resize( width, height ); } } private void deleteTerminal() { - if( this.terminal != null ) + if( terminal != null ) { - this.terminal = null; - this.terminalChanged = true; + terminal = null; + terminalChanged = true; } } public void readDescription( CompoundTag nbt ) { - this.colour = nbt.getBoolean( "colour" ); + colour = nbt.getBoolean( "colour" ); if( nbt.contains( "terminal" ) ) { CompoundTag terminal = nbt.getCompound( "terminal" ); - this.resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) ); + resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) ); this.terminal.readFromNBT( terminal ); } else { - this.deleteTerminal(); + deleteTerminal(); } } } diff --git a/src/main/java/dan200/computercraft/shared/common/ContainerHeldItem.java b/src/main/java/dan200/computercraft/shared/common/ContainerHeldItem.java index 3d22443a0..64a5fe91f 100644 --- a/src/main/java/dan200/computercraft/shared/common/ContainerHeldItem.java +++ b/src/main/java/dan200/computercraft/shared/common/ContainerHeldItem.java @@ -13,7 +13,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; @@ -33,7 +32,7 @@ public class ContainerHeldItem extends ScreenHandler super( type, id ); this.hand = hand; - this.stack = player.getStackInHand( hand ) + stack = player.getStackInHand( hand ) .copy(); } @@ -50,7 +49,7 @@ public class ContainerHeldItem extends ScreenHandler @Nonnull public ItemStack getStack() { - return this.stack; + return stack; } @Override @@ -61,11 +60,11 @@ public class ContainerHeldItem extends ScreenHandler return false; } - ItemStack stack = player.getStackInHand( this.hand ); + ItemStack stack = player.getStackInHand( hand ); return stack == this.stack || !stack.isEmpty() && !this.stack.isEmpty() && stack.getItem() == this.stack.getItem(); } - public static class Factory implements NamedScreenHandlerFactory, ExtendedScreenHandlerFactory + public static class Factory implements ExtendedScreenHandlerFactory { private final ScreenHandlerType type; private final Text name; @@ -74,7 +73,7 @@ public class ContainerHeldItem extends ScreenHandler public Factory( ScreenHandlerType type, ItemStack stack, Hand hand ) { this.type = type; - this.name = stack.getName(); + name = stack.getName(); this.hand = hand; } @@ -82,20 +81,20 @@ public class ContainerHeldItem extends ScreenHandler @Override public Text getDisplayName() { - return this.name; + return name; } @Nullable @Override public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player ) { - return new ContainerHeldItem( this.type, id, player, this.hand ); + return new ContainerHeldItem( type, id, player, hand ); } @Override public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf ) { - packetByteBuf.writeEnumConstant( this.hand ); + packetByteBuf.writeEnumConstant( hand ); } } } diff --git a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java index 70c76b463..6a95c9e5b 100644 --- a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java +++ b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java @@ -22,73 +22,73 @@ public class ServerTerminal implements ITerminal public ServerTerminal( boolean colour ) { this.colour = colour; - this.terminal = null; + terminal = null; } public ServerTerminal( boolean colour, int terminalWidth, int terminalHeight ) { this.colour = colour; - this.terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged ); + terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged ); } protected void markTerminalChanged() { - this.terminalChanged.set( true ); + terminalChanged.set( true ); } protected void resize( int width, int height ) { - if( this.terminal == null ) + if( terminal == null ) { - this.terminal = new Terminal( width, height, this::markTerminalChanged ); - this.markTerminalChanged(); + terminal = new Terminal( width, height, this::markTerminalChanged ); + markTerminalChanged(); } else { - this.terminal.resize( width, height ); + terminal.resize( width, height ); } } public void delete() { - if( this.terminal != null ) + if( terminal != null ) { - this.terminal = null; - this.markTerminalChanged(); + terminal = null; + markTerminalChanged(); } } public void update() { - this.terminalChangedLastFrame = this.terminalChanged.getAndSet( false ); + terminalChangedLastFrame = terminalChanged.getAndSet( false ); } public boolean hasTerminalChanged() { - return this.terminalChangedLastFrame; + return terminalChangedLastFrame; } @Override public Terminal getTerminal() { - return this.terminal; + return terminal; } @Override public boolean isColour() { - return this.colour; + return colour; } public TerminalState write() { - return new TerminalState( this.colour, this.terminal ); + return new TerminalState( colour, terminal ); } public void writeDescription( CompoundTag nbt ) { - nbt.putBoolean( "colour", this.colour ); - if( this.terminal != null ) + nbt.putBoolean( "colour", colour ); + if( terminal != null ) { CompoundTag terminal = new CompoundTag(); terminal.putInt( "term_width", this.terminal.getWidth() ); diff --git a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java index a1936ca4d..9690ef44c 100644 --- a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java +++ b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java @@ -36,10 +36,10 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie public final void updateBlock() { - this.markDirty(); - BlockPos pos = this.getPos(); - BlockState state = this.getCachedState(); - this.getWorld().updateListeners( pos, state, state, 3 ); + markDirty(); + BlockPos pos = getPos(); + BlockState state = getCachedState(); + getWorld().updateListeners( pos, state, state, 3 ); } @Nonnull @@ -62,7 +62,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie public boolean isUsable( PlayerEntity player, boolean ignoreRange ) { - if( player == null || !player.isAlive() || this.getWorld().getBlockEntity( this.getPos() ) != this ) + if( player == null || !player.isAlive() || getWorld().getBlockEntity( getPos() ) != this ) { return false; } @@ -71,9 +71,9 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie return true; } - double range = this.getInteractRange( player ); - BlockPos pos = this.getPos(); - return player.getEntityWorld() == this.getWorld() && player.squaredDistanceTo( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range; + double range = getInteractRange( player ); + BlockPos pos = getPos(); + return player.getEntityWorld() == getWorld() && player.squaredDistanceTo( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range; } protected double getInteractRange( PlayerEntity player ) @@ -84,7 +84,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie @Override public void fromClientTag( CompoundTag compoundTag ) { - this.readDescription( compoundTag ); + readDescription( compoundTag ); } protected void readDescription( @Nonnull CompoundTag nbt ) @@ -94,7 +94,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie @Override public CompoundTag toClientTag( CompoundTag compoundTag ) { - this.writeDescription( compoundTag ); + writeDescription( compoundTag ); return compoundTag; } diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index b76d8704a..290daff6e 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -61,12 +61,12 @@ public class CommandAPI implements ILuaAPI @LuaFunction( mainThread = true ) public final Object[] exec( String command ) { - return this.doCommand( command ); + return doCommand( command ); } private Object[] doCommand( String command ) { - MinecraftServer server = this.computer.getWorld() + MinecraftServer server = computer.getWorld() .getServer(); if( server == null || !server.areCommandBlocksEnabled() ) { @@ -74,11 +74,11 @@ public class CommandAPI implements ILuaAPI } CommandManager commandManager = server.getCommandManager(); - TileCommandComputer.CommandReceiver receiver = this.computer.getReceiver(); + TileCommandComputer.CommandReceiver receiver = computer.getReceiver(); try { receiver.clearOutput(); - int result = commandManager.execute( this.computer.getSource(), command ); + int result = commandManager.execute( computer.getSource(), command ); return new Object[] { result > 0, receiver.copyOutput(), result }; } catch( Throwable t ) @@ -118,7 +118,7 @@ public class CommandAPI implements ILuaAPI @LuaFunction public final long execAsync( ILuaContext context, String command ) throws LuaException { - return context.issueMainThreadTask( () -> this.doCommand( command ) ); + return context.issueMainThreadTask( () -> doCommand( command ) ); } /** @@ -132,7 +132,7 @@ public class CommandAPI implements ILuaAPI @LuaFunction( mainThread = true ) public final List list( IArguments args ) throws LuaException { - MinecraftServer server = this.computer.getWorld() + MinecraftServer server = computer.getWorld() .getServer(); if( server == null ) @@ -176,7 +176,7 @@ public class CommandAPI implements ILuaAPI public final Object[] getBlockPosition() { // This is probably safe to do on the Lua thread. Probably. - BlockPos pos = this.computer.getPos(); + BlockPos pos = computer.getPos(); return new Object[] { pos.getX(), pos.getY(), pos.getZ() }; } @@ -201,7 +201,7 @@ public class CommandAPI implements ILuaAPI public final List> getBlockInfos( int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) throws LuaException { // Get the details of the block - World world = this.computer.getWorld(); + World world = computer.getWorld(); BlockPos min = new BlockPos( Math.min( minX, maxX ), Math.min( minY, maxY ), Math.min( minZ, maxZ ) ); BlockPos max = new BlockPos( Math.max( minX, maxX ), Math.max( minY, maxY ), Math.max( minZ, maxZ ) ); if( !World.isInBuildLimit( min ) || !World.isInBuildLimit( max ) ) @@ -287,7 +287,7 @@ public class CommandAPI implements ILuaAPI public final Map getBlockInfo( int x, int y, int z ) throws LuaException { // Get the details of the block - World world = this.computer.getWorld(); + World world = computer.getWorld(); BlockPos position = new BlockPos( x, y, z ); if( World.isInBuildLimit( position ) ) { diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputer.java index d64b679da..f597a84e2 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputer.java @@ -31,7 +31,7 @@ public class BlockComputer extends BlockComputerBase public BlockComputer( Settings settings, ComputerFamily family, BlockEntityType type ) { super( settings, family, type ); - this.setDefaultState( this.getDefaultState().with( FACING, Direction.NORTH ) + setDefaultState( getDefaultState().with( FACING, Direction.NORTH ) .with( STATE, ComputerState.OFF ) ); } @@ -39,7 +39,7 @@ public class BlockComputer extends BlockComputerBase @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, placement.getPlayerFacing() .getOpposite() ); } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java index a14f539d9..4f98a1e54 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/BlockComputerBase.java @@ -69,7 +69,7 @@ public abstract class BlockComputerBase extends Bloc @Deprecated public int getWeakRedstonePower( @Nonnull BlockState state, @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide ) { - return this.getStrongRedstonePower( state, world, pos, incomingSide ); + return getStrongRedstonePower( state, world, pos, incomingSide ); } @Override @@ -95,7 +95,7 @@ public abstract class BlockComputerBase extends Bloc public ComputerFamily getFamily() { - return this.family; + return family; } @Override @@ -165,7 +165,7 @@ public abstract class BlockComputerBase extends Bloc BlockEntity tile = world.getBlockEntity( pos ); if( tile instanceof TileComputerBase ) { - ItemStack result = this.getItem( (TileComputerBase) tile ); + ItemStack result = getItem( (TileComputerBase) tile ); if( !result.isEmpty() ) { return result; @@ -202,7 +202,7 @@ public abstract class BlockComputerBase extends Bloc .parameter( LootContextParameters.TOOL, player.getMainHandStack() ) .parameter( LootContextParameters.THIS_ENTITY, player ) .parameter( LootContextParameters.BLOCK_ENTITY, tile ) - .putDrop( DROP, ( ctx, out ) -> out.accept( this.getItem( computer ) ) ); + .putDrop( DROP, ( ctx, out ) -> out.accept( getItem( computer ) ) ); for( ItemStack item : state.getDroppedStacks( context ) ) { dropStack( world, pos, item ); diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerPeripheral.java b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerPeripheral.java index 86758b264..23b1cd9d7 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerPeripheral.java @@ -36,20 +36,20 @@ public class ComputerPeripheral implements IPeripheral @Override public String getType() { - return this.type; + return type; } @Nonnull @Override public Object getTarget() { - return this.computer.getTile(); + return computer.getTile(); } @Override public boolean equals( IPeripheral other ) { - return other instanceof ComputerPeripheral && this.computer == ((ComputerPeripheral) other).computer; + return other instanceof ComputerPeripheral && computer == ((ComputerPeripheral) other).computer; } /** @@ -58,7 +58,7 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final void turnOn() { - this.computer.turnOn(); + computer.turnOn(); } /** @@ -67,7 +67,7 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final void shutdown() { - this.computer.shutdown(); + computer.shutdown(); } /** @@ -76,7 +76,7 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final void reboot() { - this.computer.reboot(); + computer.reboot(); } /** @@ -88,7 +88,7 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final int getID() { - return this.computer.assignID(); + return computer.assignID(); } /** @@ -99,7 +99,7 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final boolean isOn() { - return this.computer.isOn(); + return computer.isOn(); } /** @@ -112,6 +112,6 @@ public class ComputerPeripheral implements IPeripheral @LuaFunction public final String getLabel() { - return this.computer.getLabel(); + return computer.getLabel(); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java index 24203b73f..2eee9af0d 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java @@ -25,7 +25,7 @@ public class ComputerProxy public void turnOn() { - TileComputerBase tile = this.getTile(); + TileComputerBase tile = getTile(); ServerComputer computer = tile.getServerComputer(); if( computer == null ) { @@ -39,12 +39,12 @@ public class ComputerProxy protected TileComputerBase getTile() { - return this.get.get(); + return get.get(); } public void shutdown() { - TileComputerBase tile = this.getTile(); + TileComputerBase tile = getTile(); ServerComputer computer = tile.getServerComputer(); if( computer == null ) { @@ -58,7 +58,7 @@ public class ComputerProxy public void reboot() { - TileComputerBase tile = this.getTile(); + TileComputerBase tile = getTile(); ServerComputer computer = tile.getServerComputer(); if( computer == null ) { @@ -72,20 +72,20 @@ public class ComputerProxy public int assignID() { - TileComputerBase tile = this.getTile(); + TileComputerBase tile = getTile(); ServerComputer computer = tile.getServerComputer(); return computer == null ? tile.getComputerID() : computer.getID(); } public boolean isOn() { - ServerComputer computer = this.getTile().getServerComputer(); + ServerComputer computer = getTile().getServerComputer(); return computer != null && computer.isOn(); } public String getLabel() { - TileComputerBase tile = this.getTile(); + TileComputerBase tile = getTile(); ServerComputer computer = tile.getServerComputer(); return computer == null ? tile.getLabel() : computer.getLabel(); } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java index 97d3c9e62..60dd39182 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java @@ -35,17 +35,17 @@ public class TileCommandComputer extends TileComputer public TileCommandComputer( ComputerFamily family, BlockEntityType type ) { super( family, type ); - this.receiver = new CommandReceiver(); + receiver = new CommandReceiver(); } public CommandReceiver getReceiver() { - return this.receiver; + return receiver; } public ServerCommandSource getSource() { - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); String name = "@"; if( computer != null ) { @@ -56,14 +56,14 @@ public class TileCommandComputer extends TileComputer } } - return new ServerCommandSource( this.receiver, - new Vec3d( this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5 ), + return new ServerCommandSource( receiver, + new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO, - (ServerWorld) this.getWorld(), + (ServerWorld) getWorld(), 2, name, new LiteralText( name ), - this.getWorld().getServer(), + getWorld().getServer(), null ); } @@ -105,29 +105,29 @@ public class TileCommandComputer extends TileComputer public void clearOutput() { - this.output.clear(); + output.clear(); } public Map getOutput() { - return this.output; + return output; } public Map copyOutput() { - return new HashMap<>( this.output ); + return new HashMap<>( output ); } @Override public void sendSystemMessage( @Nonnull Text textComponent, @Nonnull UUID id ) { - this.output.put( this.output.size() + 1, textComponent.getString() ); + output.put( output.size() + 1, textComponent.getString() ); } @Override public boolean shouldReceiveFeedback() { - return TileCommandComputer.this.getWorld().getGameRules() + return getWorld().getGameRules() .getBoolean( GameRules.SEND_COMMAND_FEEDBACK ); } @@ -140,7 +140,7 @@ public class TileCommandComputer extends TileComputer @Override public boolean shouldBroadcastConsoleToOps() { - return TileCommandComputer.this.getWorld().getGameRules() + return getWorld().getGameRules() .getBoolean( GameRules.COMMAND_BLOCK_OUTPUT ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java index 5a487a1f4..078a9925a 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java @@ -33,23 +33,23 @@ public class TileComputer extends TileComputerBase public boolean isUsableByPlayer( PlayerEntity player ) { - return this.isUsable( player, false ); + return isUsable( player, false ); } @Override protected void updateBlockState( ComputerState newState ) { - BlockState existing = this.getCachedState(); + BlockState existing = getCachedState(); if( existing.get( BlockComputer.STATE ) != newState ) { - this.getWorld().setBlockState( this.getPos(), existing.with( BlockComputer.STATE, newState ), 3 ); + getWorld().setBlockState( getPos(), existing.with( BlockComputer.STATE, newState ), 3 ); } } @Override public Direction getDirection() { - return this.getCachedState().get( BlockComputer.FACING ); + return getCachedState().get( BlockComputer.FACING ); } @Override @@ -71,23 +71,23 @@ public class TileComputer extends TileComputerBase @Override protected ServerComputer createComputer( int instanceID, int id ) { - ComputerFamily family = this.getFamily(); - ServerComputer computer = new ServerComputer( this.getWorld(), - id, this.label, + ComputerFamily family = getFamily(); + ServerComputer computer = new ServerComputer( getWorld(), + id, label, instanceID, family, ComputerCraft.computerTermWidth, ComputerCraft.computerTermHeight ); - computer.setPosition( this.getPos() ); + computer.setPosition( getPos() ); return computer; } @Override public ComputerProxy createProxy() { - if( this.proxy == null ) + if( proxy == null ) { - this.proxy = new ComputerProxy( () -> this ) + proxy = new ComputerProxy( () -> this ) { @Override protected TileComputerBase getTile() @@ -96,7 +96,7 @@ public class TileComputer extends TileComputerBase } }; } - return this.proxy; + return proxy; } @Nullable diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index 15b38b3ed..e4104daa6 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -30,7 +30,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.PacketByteBuf; -import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -48,7 +47,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Objects; -public abstract class TileComputerBase extends TileGeneric implements IComputerTile, Tickable, IPeripheralTile, Nameable, NamedScreenHandlerFactory, +public abstract class TileComputerBase extends TileGeneric implements IComputerTile, Tickable, IPeripheralTile, Nameable, ExtendedScreenHandlerFactory { private static final String NBT_ID = "ComputerId"; @@ -71,10 +70,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public void destroy() { - this.unload(); + unload(); for( Direction dir : DirectionUtil.FACINGS ) { - RedstoneUtil.propagateRedstoneOutput( this.getWorld(), this.getPos(), dir ); + RedstoneUtil.propagateRedstoneOutput( getWorld(), getPos(), dir ); } } @@ -86,13 +85,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT protected void unload() { - if( this.instanceID >= 0 ) + if( instanceID >= 0 ) { - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - ComputerCraft.serverComputerRegistry.remove( this.instanceID ); + ComputerCraft.serverComputerRegistry.remove( instanceID ); } - this.instanceID = -1; + instanceID = -1; } } @@ -101,12 +100,12 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT public ActionResult onActivate( PlayerEntity player, Hand hand, BlockHitResult hit ) { ItemStack currentItem = player.getStackInHand( hand ); - if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && this.canNameWithTag( player ) && currentItem.hasCustomName() ) + if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) && currentItem.hasCustomName() ) { // Label to rename computer - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - this.setLabel( currentItem.getName() + setLabel( currentItem.getName() .getString() ); currentItem.decrement( 1 ); } @@ -115,11 +114,11 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT else if( !player.isInSneakingPose() ) { // Regular right click to activate computer - if( !this.getWorld().isClient && this.isUsable( player, false ) ) + if( !getWorld().isClient && isUsable( player, false ) ) { - this.createServerComputer().turnOn(); - this.createServerComputer().sendTerminalState( player ); - new ComputerContainerData( this.createServerComputer() ).open( player, this ); + createServerComputer().turnOn(); + createServerComputer().sendTerminalState( player ); + new ComputerContainerData( createServerComputer() ).open( player, this ); } return ActionResult.SUCCESS; } @@ -133,48 +132,48 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT public ServerComputer createServerComputer() { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return null; } boolean changed = false; - if( this.instanceID < 0 ) + if( instanceID < 0 ) { - this.instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID(); + instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID(); changed = true; } - if( !ComputerCraft.serverComputerRegistry.contains( this.instanceID ) ) + if( !ComputerCraft.serverComputerRegistry.contains( instanceID ) ) { - ServerComputer computer = this.createComputer( this.instanceID, this.computerID ); - ComputerCraft.serverComputerRegistry.add( this.instanceID, computer ); - this.fresh = true; + ServerComputer computer = createComputer( instanceID, computerID ); + ComputerCraft.serverComputerRegistry.add( instanceID, computer ); + fresh = true; changed = true; } if( changed ) { - this.updateBlock(); - this.updateInput(); + updateBlock(); + updateInput(); } - return ComputerCraft.serverComputerRegistry.get( this.instanceID ); + return ComputerCraft.serverComputerRegistry.get( instanceID ); } public ServerComputer getServerComputer() { - return this.getWorld().isClient ? null : ComputerCraft.serverComputerRegistry.get( this.instanceID ); + return getWorld().isClient ? null : ComputerCraft.serverComputerRegistry.get( instanceID ); } protected abstract ServerComputer createComputer( int instanceID, int id ); public void updateInput() { - if( this.getWorld() == null || this.getWorld().isClient ) + if( getWorld() == null || getWorld().isClient ) { return; } // Update all sides - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); if( computer == null ) { return; @@ -183,27 +182,27 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT BlockPos pos = computer.getPosition(); for( Direction dir : DirectionUtil.FACINGS ) { - this.updateSideInput( computer, dir, pos.offset( dir ) ); + updateSideInput( computer, dir, pos.offset( dir ) ); } } private void updateSideInput( ServerComputer computer, Direction dir, BlockPos offset ) { Direction offsetSide = dir.getOpposite(); - ComputerSide localDir = this.remapToLocalSide( dir ); + ComputerSide localDir = remapToLocalSide( dir ); - computer.setRedstoneInput( localDir, getRedstoneInput( this.world, offset, dir ) ); - computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( this.getWorld(), offset, offsetSide ) ); - if( !this.isPeripheralBlockedOnSide( localDir ) ) + computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) ); + computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) ); + if( !isPeripheralBlockedOnSide( localDir ) ) { - IPeripheral peripheral = Peripherals.getPeripheral( this.getWorld(), offset, offsetSide ); + IPeripheral peripheral = Peripherals.getPeripheral( getWorld(), offset, offsetSide ); computer.setPeripheral( localDir, peripheral ); } } protected ComputerSide remapToLocalSide( Direction globalSide ) { - return this.remapLocalSide( DirectionUtil.toLocal( this.getDirection(), globalSide ) ); + return remapLocalSide( DirectionUtil.toLocal( getDirection(), globalSide ) ); } /** @@ -241,74 +240,74 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public void onNeighbourChange( @Nonnull BlockPos neighbour ) { - this.updateInput( neighbour ); + updateInput( neighbour ); } @Override public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) { - this.updateInput( neighbour ); + updateInput( neighbour ); } @Override protected void readDescription( @Nonnull CompoundTag nbt ) { super.readDescription( nbt ); - this.label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; - this.computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; + label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; + computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; } @Override protected void writeDescription( @Nonnull CompoundTag nbt ) { super.writeDescription( nbt ); - if( this.label != null ) + if( label != null ) { - nbt.putString( NBT_LABEL, this.label ); + nbt.putString( NBT_LABEL, label ); } - if( this.computerID >= 0 ) + if( computerID >= 0 ) { - nbt.putInt( NBT_ID, this.computerID ); + nbt.putInt( NBT_ID, computerID ); } } @Override public void tick() { - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - ServerComputer computer = this.createServerComputer(); + ServerComputer computer = createServerComputer(); if( computer == null ) { return; } // If the computer isn't on and should be, then turn it on - if( this.startOn || (this.fresh && this.on) ) + if( startOn || (fresh && on) ) { computer.turnOn(); - this.startOn = false; + startOn = false; } computer.keepAlive(); - this.fresh = false; - this.computerID = computer.getID(); - this.label = computer.getLabel(); - this.on = computer.isOn(); + fresh = false; + computerID = computer.getID(); + label = computer.getLabel(); + on = computer.isOn(); if( computer.hasOutputChanged() ) { - this.updateOutput(); + updateOutput(); } // Update the block state if needed. We don't fire a block update intentionally, // as this only really is needed on the client side. - this.updateBlockState( computer.getState() ); + updateBlockState( computer.getState() ); if( computer.hasOutputChanged() ) { - this.updateOutput(); + updateOutput(); } } } @@ -316,10 +315,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT public void updateOutput() { // Update redstone - this.updateBlock(); + updateBlock(); for( Direction dir : DirectionUtil.FACINGS ) { - RedstoneUtil.propagateRedstoneOutput( this.getWorld(), this.getPos(), dir ); + RedstoneUtil.propagateRedstoneOutput( getWorld(), getPos(), dir ); } } @@ -331,9 +330,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT super.fromTag( state, nbt ); // Load ID, label and power state - this.computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; - this.label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; - this.on = this.startOn = nbt.getBoolean( NBT_ON ); + computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; + label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; + on = startOn = nbt.getBoolean( NBT_ON ); } @Nonnull @@ -341,15 +340,15 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT public CompoundTag toTag( @Nonnull CompoundTag nbt ) { // Save ID, label and power state - if( this.computerID >= 0 ) + if( computerID >= 0 ) { - nbt.putInt( NBT_ID, this.computerID ); + nbt.putInt( NBT_ID, computerID ); } - if( this.label != null ) + if( label != null ) { - nbt.putString( NBT_LABEL, this.label ); + nbt.putString( NBT_LABEL, label ); } - nbt.putBoolean( NBT_ON, this.on ); + nbt.putBoolean( NBT_ON, on ); return super.toTag( nbt ); } @@ -357,18 +356,18 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public void markRemoved() { - this.unload(); + unload(); super.markRemoved(); } private void updateInput( BlockPos neighbour ) { - if( this.getWorld() == null || this.getWorld().isClient ) + if( getWorld() == null || getWorld().isClient ) { return; } - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); if( computer == null ) { return; @@ -376,61 +375,61 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT for( Direction dir : DirectionUtil.FACINGS ) { - BlockPos offset = this.pos.offset( dir ); + BlockPos offset = pos.offset( dir ); if( offset.equals( neighbour ) ) { - this.updateSideInput( computer, dir, offset ); + updateSideInput( computer, dir, offset ); return; } } // If the position is not any adjacent one, update all inputs. - this.updateInput(); + updateInput(); } private void updateInput( Direction dir ) { - if( this.getWorld() == null || this.getWorld().isClient ) + if( getWorld() == null || getWorld().isClient ) { return; } - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); if( computer == null ) { return; } - this.updateSideInput( computer, dir, this.pos.offset( dir ) ); + updateSideInput( computer, dir, pos.offset( dir ) ); } @Override public final int getComputerID() { - return this.computerID; + return computerID; } @Override public final void setComputerID( int id ) { - if( this.getWorld().isClient || this.computerID == id ) + if( getWorld().isClient || computerID == id ) { return; } - this.computerID = id; - ServerComputer computer = this.getServerComputer(); + computerID = id; + ServerComputer computer = getServerComputer(); if( computer != null ) { - computer.setID( this.computerID ); + computer.setID( computerID ); } - this.markDirty(); + markDirty(); } @Override public final String getLabel() { - return this.label; + return label; } // Networking stuff @@ -438,37 +437,37 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public final void setLabel( String label ) { - if( this.getWorld().isClient || Objects.equals( this.label, label ) ) + if( getWorld().isClient || Objects.equals( this.label, label ) ) { return; } this.label = label; - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); if( computer != null ) { computer.setLabel( label ); } - this.markDirty(); + markDirty(); } @Override public ComputerFamily getFamily() { - return this.family; + return family; } protected void transferStateFrom( TileComputerBase copy ) { - if( copy.computerID != this.computerID || copy.instanceID != this.instanceID ) + if( copy.computerID != computerID || copy.instanceID != instanceID ) { - this.unload(); - this.instanceID = copy.instanceID; - this.computerID = copy.computerID; - this.label = copy.label; - this.on = copy.on; - this.startOn = copy.startOn; - this.updateBlock(); + unload(); + instanceID = copy.instanceID; + computerID = copy.computerID; + label = copy.label; + on = copy.on; + startOn = copy.startOn; + updateBlock(); } copy.instanceID = -1; } @@ -477,7 +476,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public IPeripheral getPeripheral( Direction side ) { - return new ComputerPeripheral( "computer", this.createProxy() ); + return new ComputerPeripheral( "computer", createProxy() ); } public abstract ComputerProxy createProxy(); @@ -486,14 +485,14 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public Text getName() { - return this.hasCustomName() ? new LiteralText( this.label ) : new TranslatableText( this.getCachedState().getBlock() + return hasCustomName() ? new LiteralText( label ) : new TranslatableText( getCachedState().getBlock() .getTranslationKey() ); } @Override public boolean hasCustomName() { - return !Strings.isNullOrEmpty( this.label ); + return !Strings.isNullOrEmpty( label ); } @Nonnull @@ -507,13 +506,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public Text getCustomName() { - return this.hasCustomName() ? new LiteralText( this.label ) : null; + return hasCustomName() ? new LiteralText( label ) : null; } @Override public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf ) { - packetByteBuf.writeInt( this.getServerComputer().getInstanceID() ); - packetByteBuf.writeEnumConstant( this.getServerComputer().getFamily() ); + packetByteBuf.writeInt( getServerComputer().getInstanceID() ); + packetByteBuf.writeEnumConstant( getServerComputer().getFamily() ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java index 8ce7d7759..df0a18625 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java @@ -28,13 +28,13 @@ public class ClientComputer extends ClientTerminal implements IComputer public CompoundTag getUserData() { - return this.userData; + return userData; } public void requestState() { // Request state from server - NetworkHandler.sendToServer( new RequestComputerMessage( this.getInstanceID() ) ); + NetworkHandler.sendToServer( new RequestComputerMessage( getInstanceID() ) ); } // IComputer @@ -42,53 +42,53 @@ public class ClientComputer extends ClientTerminal implements IComputer @Override public int getInstanceID() { - return this.instanceID; + return instanceID; } @Override public void turnOn() { // Send turnOn to server - NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.TURN_ON ) ); + NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.TURN_ON ) ); } @Override public void shutdown() { // Send shutdown to server - NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.SHUTDOWN ) ); + NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.SHUTDOWN ) ); } @Override public void reboot() { // Send reboot to server - NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.REBOOT ) ); + NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.REBOOT ) ); } @Override public void queueEvent( String event, Object[] arguments ) { // Send event to server - NetworkHandler.sendToServer( new QueueEventServerMessage( this.instanceID, event, arguments ) ); + NetworkHandler.sendToServer( new QueueEventServerMessage( instanceID, event, arguments ) ); } @Override public boolean isOn() { - return this.on; + return on; } @Override public boolean isCursorDisplayed() { - return this.on && this.blinking; + return on && blinking; } @Override public void keyDown( int key, boolean repeat ) { - NetworkHandler.sendToServer( new KeyEventServerMessage( this.instanceID, + NetworkHandler.sendToServer( new KeyEventServerMessage( instanceID, repeat ? KeyEventServerMessage.TYPE_REPEAT : KeyEventServerMessage.TYPE_DOWN, key ) ); } @@ -96,37 +96,37 @@ public class ClientComputer extends ClientTerminal implements IComputer @Override public void keyUp( int key ) { - NetworkHandler.sendToServer( new KeyEventServerMessage( this.instanceID, KeyEventServerMessage.TYPE_UP, key ) ); + NetworkHandler.sendToServer( new KeyEventServerMessage( instanceID, KeyEventServerMessage.TYPE_UP, key ) ); } @Override public void mouseClick( int button, int x, int y ) { - NetworkHandler.sendToServer( new MouseEventServerMessage( this.instanceID, MouseEventServerMessage.TYPE_CLICK, button, x, y ) ); + NetworkHandler.sendToServer( new MouseEventServerMessage( instanceID, MouseEventServerMessage.TYPE_CLICK, button, x, y ) ); } @Override public void mouseUp( int button, int x, int y ) { - NetworkHandler.sendToServer( new MouseEventServerMessage( this.instanceID, MouseEventServerMessage.TYPE_UP, button, x, y ) ); + NetworkHandler.sendToServer( new MouseEventServerMessage( instanceID, MouseEventServerMessage.TYPE_UP, button, x, y ) ); } @Override public void mouseDrag( int button, int x, int y ) { - NetworkHandler.sendToServer( new MouseEventServerMessage( this.instanceID, MouseEventServerMessage.TYPE_DRAG, button, x, y ) ); + NetworkHandler.sendToServer( new MouseEventServerMessage( instanceID, MouseEventServerMessage.TYPE_DRAG, button, x, y ) ); } @Override public void mouseScroll( int direction, int x, int y ) { - NetworkHandler.sendToServer( new MouseEventServerMessage( this.instanceID, MouseEventServerMessage.TYPE_SCROLL, direction, x, y ) ); + NetworkHandler.sendToServer( new MouseEventServerMessage( instanceID, MouseEventServerMessage.TYPE_SCROLL, direction, x, y ) ); } public void setState( ComputerState state, CompoundTag userData ) { - this.on = state != ComputerState.OFF; - this.blinking = state == ComputerState.BLINKING; + on = state != ComputerState.OFF; + blinking = state == ComputerState.BLINKING; this.userData = userData; } } diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ComputerRegistry.java b/src/main/java/dan200/computercraft/shared/computer/core/ComputerRegistry.java index aa1b0a438..29451df8f 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ComputerRegistry.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ComputerRegistry.java @@ -19,39 +19,39 @@ public class ComputerRegistry protected ComputerRegistry() { - this.computers = new HashMap<>(); - this.reset(); + computers = new HashMap<>(); + reset(); } public void reset() { - this.computers.clear(); - this.nextUnusedInstanceID = 0; - this.sessionID = new Random().nextInt(); + computers.clear(); + nextUnusedInstanceID = 0; + sessionID = new Random().nextInt(); } public int getSessionID() { - return this.sessionID; + return sessionID; } public int getUnusedInstanceID() { - return this.nextUnusedInstanceID++; + return nextUnusedInstanceID++; } public Collection getComputers() { - return this.computers.values(); + return computers.values(); } public T get( int instanceID ) { if( instanceID >= 0 ) { - if( this.computers.containsKey( instanceID ) ) + if( computers.containsKey( instanceID ) ) { - return this.computers.get( instanceID ); + return computers.get( instanceID ); } } return null; @@ -59,21 +59,21 @@ public class ComputerRegistry public boolean contains( int instanceID ) { - return this.computers.containsKey( instanceID ); + return computers.containsKey( instanceID ); } public void add( int instanceID, T computer ) { - if( this.computers.containsKey( instanceID ) ) + if( computers.containsKey( instanceID ) ) { - this.remove( instanceID ); + remove( instanceID ); } - this.computers.put( instanceID, computer ); - this.nextUnusedInstanceID = Math.max( this.nextUnusedInstanceID, instanceID + 1 ); + computers.put( instanceID, computer ); + nextUnusedInstanceID = Math.max( nextUnusedInstanceID, instanceID + 1 ); } public void remove( int instanceID ) { - this.computers.remove( instanceID ); + computers.remove( instanceID ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java b/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java index 59c48797f..c88169a2c 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ComputerState.java @@ -25,12 +25,12 @@ public enum ComputerState implements StringIdentifiable @Override public String asString() { - return this.name; + return name; } @Override public String toString() { - return this.name; + return name; } } diff --git a/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java index 0a119990c..149e3a057 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java @@ -20,7 +20,7 @@ public interface IComputer extends ITerminal, InputHandler default void queueEvent( String event ) { - this.queueEvent( event, null ); + queueEvent( event, null ); } @Override @@ -28,11 +28,11 @@ public interface IComputer extends ITerminal, InputHandler default ComputerState getState() { - if( !this.isOn() ) + if( !isOn() ) { return ComputerState.OFF; } - return this.isCursorDisplayed() ? ComputerState.BLINKING : ComputerState.ON; + return isCursorDisplayed() ? ComputerState.BLINKING : ComputerState.ON; } boolean isOn(); diff --git a/src/main/java/dan200/computercraft/shared/computer/core/InputState.java b/src/main/java/dan200/computercraft/shared/computer/core/InputState.java index d5af8608e..111faee60 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/InputState.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/InputState.java @@ -30,7 +30,7 @@ public class InputState implements InputHandler @Override public void queueEvent( String event, Object[] arguments ) { - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.queueEvent( event, arguments ); @@ -40,8 +40,8 @@ public class InputState implements InputHandler @Override public void keyDown( int key, boolean repeat ) { - this.keysDown.add( key ); - IComputer computer = this.owner.getComputer(); + keysDown.add( key ); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.keyDown( key, repeat ); @@ -51,8 +51,8 @@ public class InputState implements InputHandler @Override public void keyUp( int key ) { - this.keysDown.remove( key ); - IComputer computer = this.owner.getComputer(); + keysDown.remove( key ); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.keyUp( key ); @@ -62,11 +62,11 @@ public class InputState implements InputHandler @Override public void mouseClick( int button, int x, int y ) { - this.lastMouseX = x; - this.lastMouseY = y; - this.lastMouseDown = button; + lastMouseX = x; + lastMouseY = y; + lastMouseDown = button; - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.mouseClick( button, x, y ); @@ -76,11 +76,11 @@ public class InputState implements InputHandler @Override public void mouseUp( int button, int x, int y ) { - this.lastMouseX = x; - this.lastMouseY = y; - this.lastMouseDown = -1; + lastMouseX = x; + lastMouseY = y; + lastMouseDown = -1; - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.mouseUp( button, x, y ); @@ -90,11 +90,11 @@ public class InputState implements InputHandler @Override public void mouseDrag( int button, int x, int y ) { - this.lastMouseX = x; - this.lastMouseY = y; - this.lastMouseDown = button; + lastMouseX = x; + lastMouseY = y; + lastMouseDown = button; - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.mouseDrag( button, x, y ); @@ -104,10 +104,10 @@ public class InputState implements InputHandler @Override public void mouseScroll( int direction, int x, int y ) { - this.lastMouseX = x; - this.lastMouseY = y; + lastMouseX = x; + lastMouseY = y; - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { computer.mouseScroll( direction, x, y ); @@ -116,22 +116,22 @@ public class InputState implements InputHandler public void close() { - IComputer computer = this.owner.getComputer(); + IComputer computer = owner.getComputer(); if( computer != null ) { - IntIterator keys = this.keysDown.iterator(); + IntIterator keys = keysDown.iterator(); while( keys.hasNext() ) { computer.keyUp( keys.nextInt() ); } - if( this.lastMouseDown != -1 ) + if( lastMouseDown != -1 ) { - computer.mouseUp( this.lastMouseDown, this.lastMouseX, this.lastMouseY ); + computer.mouseUp( lastMouseDown, lastMouseX, lastMouseY ); } } - this.keysDown.clear(); - this.lastMouseDown = -1; + keysDown.clear(); + lastMouseDown = -1; } } diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index 1cec31629..3bbf9bd20 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -54,26 +54,26 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput this.instanceID = instanceID; this.world = world; - this.position = null; + position = null; this.family = family; - this.computer = new Computer( this, this.getTerminal(), computerID ); - this.computer.setLabel( label ); - this.userData = null; - this.changed = false; + computer = new Computer( this, getTerminal(), computerID ); + computer.setLabel( label ); + userData = null; + changed = false; - this.changedLastFrame = false; - this.ticksSincePing = 0; + changedLastFrame = false; + ticksSincePing = 0; } public ComputerFamily getFamily() { - return this.family; + return family; } public World getWorld() { - return this.world; + return world; } public void setWorld( World world ) @@ -83,78 +83,78 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput public BlockPos getPosition() { - return this.position; + return position; } public void setPosition( BlockPos pos ) { - this.position = new BlockPos( pos ); + position = new BlockPos( pos ); } public IAPIEnvironment getAPIEnvironment() { - return this.computer.getAPIEnvironment(); + return computer.getAPIEnvironment(); } public Computer getComputer() { - return this.computer; + return computer; } @Override public void update() { super.update(); - this.computer.tick(); + computer.tick(); - this.changedLastFrame = this.computer.pollAndResetChanged() || this.changed; - this.changed = false; + changedLastFrame = computer.pollAndResetChanged() || changed; + changed = false; - this.ticksSincePing++; + ticksSincePing++; } public void keepAlive() { - this.ticksSincePing = 0; + ticksSincePing = 0; } public boolean hasTimedOut() { - return this.ticksSincePing > 100; + return ticksSincePing > 100; } public void unload() { - this.computer.unload(); + computer.unload(); } public CompoundTag getUserData() { - if( this.userData == null ) + if( userData == null ) { - this.userData = new CompoundTag(); + userData = new CompoundTag(); } - return this.userData; + return userData; } public void updateUserData() { - this.changed = true; + changed = true; } public void broadcastState( boolean force ) { - if( this.hasOutputChanged() || force ) + if( hasOutputChanged() || force ) { // Send computer state to all clients MinecraftServer server = GameInstanceUtils.getServer(); if( server != null ) { - NetworkHandler.sendToAllPlayers( server, this.createComputerPacket() ); + NetworkHandler.sendToAllPlayers( server, createComputerPacket() ); } } - if( this.hasTerminalChanged() || force ) + if( hasTerminalChanged() || force ) { MinecraftServer server = GameInstanceUtils.getServer(); if( server != null ) @@ -165,11 +165,11 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput for( PlayerEntity player : server.getPlayerManager() .getPlayerList() ) { - if( this.isInteracting( player ) ) + if( isInteracting( player ) ) { if( packet == null ) { - packet = this.createTerminalPacket(); + packet = createTerminalPacket(); } NetworkHandler.sendToPlayer( player, packet ); } @@ -180,7 +180,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput public boolean hasOutputChanged() { - return this.changedLastFrame; + return changedLastFrame; } private NetworkMessage createComputerPacket() @@ -190,12 +190,12 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput protected boolean isInteracting( PlayerEntity player ) { - return this.getContainer( player ) != null; + return getContainer( player ) != null; } protected NetworkMessage createTerminalPacket() { - return new ComputerTerminalClientMessage( this.getInstanceID(), this.write() ); + return new ComputerTerminalClientMessage( getInstanceID(), write() ); } @Nullable @@ -219,14 +219,14 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput @Override public int getInstanceID() { - return this.instanceID; + return instanceID; } @Override public void turnOn() { // Turn on - this.computer.turnOn(); + computer.turnOn(); } // IComputer @@ -235,45 +235,45 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput public void shutdown() { // Shutdown - this.computer.shutdown(); + computer.shutdown(); } @Override public void reboot() { // Reboot - this.computer.reboot(); + computer.reboot(); } @Override public void queueEvent( String event, Object[] arguments ) { // Queue event - this.computer.queueEvent( event, arguments ); + computer.queueEvent( event, arguments ); } @Override public boolean isOn() { - return this.computer.isOn(); + return computer.isOn(); } @Override public boolean isCursorDisplayed() { - return this.computer.isOn() && this.computer.isBlinking(); + return computer.isOn() && computer.isBlinking(); } public void sendComputerState( PlayerEntity player ) { // Send state to client - NetworkHandler.sendToPlayer( player, this.createComputerPacket() ); + NetworkHandler.sendToPlayer( player, createComputerPacket() ); } public void sendTerminalState( PlayerEntity player ) { // Send terminal state to client - NetworkHandler.sendToPlayer( player, this.createTerminalPacket() ); + NetworkHandler.sendToPlayer( player, createTerminalPacket() ); } public void broadcastDelete() @@ -282,83 +282,83 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput MinecraftServer server = GameInstanceUtils.getServer(); if( server != null ) { - NetworkHandler.sendToAllPlayers( server, new ComputerDeletedClientMessage( this.getInstanceID() ) ); + NetworkHandler.sendToAllPlayers( server, new ComputerDeletedClientMessage( getInstanceID() ) ); } } public int getID() { - return this.computer.getID(); + return computer.getID(); } public void setID( int id ) { - this.computer.setID( id ); + computer.setID( id ); } public String getLabel() { - return this.computer.getLabel(); + return computer.getLabel(); } public void setLabel( String label ) { - this.computer.setLabel( label ); + computer.setLabel( label ); } public int getRedstoneOutput( ComputerSide side ) { - return this.computer.getEnvironment() + return computer.getEnvironment() .getExternalRedstoneOutput( side ); } public void setRedstoneInput( ComputerSide side, int level ) { - this.computer.getEnvironment() + computer.getEnvironment() .setRedstoneInput( side, level ); } public int getBundledRedstoneOutput( ComputerSide side ) { - return this.computer.getEnvironment() + return computer.getEnvironment() .getExternalBundledRedstoneOutput( side ); } public void setBundledRedstoneInput( ComputerSide side, int combination ) { - this.computer.getEnvironment() + computer.getEnvironment() .setBundledRedstoneInput( side, combination ); } public void addAPI( ILuaAPI api ) { - this.computer.addApi( api ); + computer.addApi( api ); } // IComputerEnvironment implementation public void setPeripheral( ComputerSide side, IPeripheral peripheral ) { - this.computer.getEnvironment() + computer.getEnvironment() .setPeripheral( side, peripheral ); } public IPeripheral getPeripheral( ComputerSide side ) { - return this.computer.getEnvironment() + return computer.getEnvironment() .getPeripheral( side ); } @Override public int getDay() { - return (int) ((this.world.getTimeOfDay() + 6000) / 24000) + 1; + return (int) ((world.getTimeOfDay() + 6000) / 24000) + 1; } @Override public double getTimeOfDay() { - return (this.world.getTimeOfDay() + 6000) % 24000 / 1000.0; + return (world.getTimeOfDay() + 6000) % 24000 / 1000.0; } @Override @@ -384,13 +384,13 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput @Override public int assignNewID() { - return ComputerCraftAPI.createUniqueNumberedSaveDir( this.world, "computer" ); + return ComputerCraftAPI.createUniqueNumberedSaveDir( world, "computer" ); } @Override public IWritableMount createSaveDirMount( String subPath, long capacity ) { - return ComputerCraftAPI.createSaveDirMount( this.world, subPath, capacity ); + return ComputerCraftAPI.createSaveDirMount( world, subPath, capacity ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java index 2cdcf4052..448a43571 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputerRegistry.java @@ -12,7 +12,7 @@ public class ServerComputerRegistry extends ComputerRegistry { public void update() { - Iterator it = this.getComputers().iterator(); + Iterator it = getComputers().iterator(); while( it.hasNext() ) { ServerComputer computer = it.next(); @@ -39,7 +39,7 @@ public class ServerComputerRegistry extends ComputerRegistry public void reset() { //System.out.println( "RESET SERVER COMPUTERS" ); - for( ServerComputer computer : this.getComputers() ) + for( ServerComputer computer : getComputers() ) { computer.unload(); } @@ -60,7 +60,7 @@ public class ServerComputerRegistry extends ComputerRegistry public void remove( int instanceID ) { //System.out.println( "REMOVE SERVER COMPUTER " + instanceID ); - ServerComputer computer = this.get( instanceID ); + ServerComputer computer = get( instanceID ); if( computer != null ) { computer.unload(); @@ -77,7 +77,7 @@ public class ServerComputerRegistry extends ComputerRegistry return null; } - for( ServerComputer computer : this.getComputers() ) + for( ServerComputer computer : getComputers() ) { if( computer.getID() == computerID ) { diff --git a/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerComputerBase.java index 1d317d5b4..a696c8618 100644 --- a/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerComputerBase.java @@ -64,33 +64,33 @@ public class ContainerComputerBase extends ScreenHandler implements IContainerCo @Nonnull public ComputerFamily getFamily() { - return this.family; + return family; } @Nullable @Override public IComputer getComputer() { - return this.computer; + return computer; } @Nonnull @Override public InputState getInput() { - return this.input; + return input; } @Override public void close( @Nonnull PlayerEntity player ) { super.close( player ); - this.input.close(); + input.close(); } @Override public boolean canUse( @Nonnull PlayerEntity player ) { - return this.canUse.test( player ); + return canUse.test( player ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerViewComputer.java b/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerViewComputer.java index d32722b82..c2fa650c6 100644 --- a/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerViewComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/inventory/ContainerViewComputer.java @@ -10,7 +10,6 @@ import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.computer.blocks.TileCommandComputer; import dan200.computercraft.shared.computer.core.ComputerFamily; -import dan200.computercraft.shared.computer.core.IContainerComputer; import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.network.container.ViewComputerContainerData; import net.minecraft.entity.player.PlayerEntity; @@ -19,7 +18,7 @@ import net.minecraft.network.PacketByteBuf; import javax.annotation.Nonnull; -public class ContainerViewComputer extends ContainerComputerBase implements IContainerComputer +public class ContainerViewComputer extends ContainerComputerBase { private final int width; private final int height; @@ -27,15 +26,15 @@ public class ContainerViewComputer extends ContainerComputerBase implements ICon public ContainerViewComputer( int id, ServerComputer computer ) { super( ComputerCraftRegistry.ModContainers.VIEW_COMPUTER, id, player -> canInteractWith( computer, player ), computer, computer.getFamily() ); - this.width = this.height = 0; + width = height = 0; } public ContainerViewComputer( int id, PlayerInventory player, PacketByteBuf packetByteBuf ) { super( ComputerCraftRegistry.ModContainers.VIEW_COMPUTER, id, player, packetByteBuf ); ViewComputerContainerData data = new ViewComputerContainerData( new PacketByteBuf( packetByteBuf.copy() ) ); - this.width = data.getWidth(); - this.height = data.getHeight(); + width = data.getWidth(); + height = data.getHeight(); } private static boolean canInteractWith( @Nonnull ServerComputer computer, @Nonnull PlayerEntity player ) @@ -52,11 +51,11 @@ public class ContainerViewComputer extends ContainerComputerBase implements ICon public int getWidth() { - return this.width; + return width; } public int getHeight() { - return this.height; + return height; } } diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java index 4b6da8aa2..734cf563a 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java @@ -38,7 +38,7 @@ public class ItemComputer extends ItemComputerBase @Override public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family ) { - ItemStack result = ComputerItemFactory.create( this.getComputerID( stack ), null, family ); + ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family ); if( stack.hasCustomName() ) { result.setCustomName( stack.getName() ); diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java index 395ce5b24..482e2916b 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputerBase.java @@ -32,15 +32,15 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte public ItemComputerBase( BlockComputerBase block, Settings settings ) { super( block, settings ); - this.family = block.getFamily(); + family = block.getFamily(); } @Override public void appendTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List list, @Nonnull TooltipContext options ) { - if( options.isAdvanced() || this.getLabel( stack ) == null ) + if( options.isAdvanced() || getLabel( stack ) == null ) { - int id = this.getComputerID( stack ); + int id = getComputerID( stack ); if( id >= 0 ) { list.add( new TranslatableText( "gui.computercraft.tooltip.computer_id", id ).formatted( Formatting.GRAY ) ); @@ -57,7 +57,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte @Override public final ComputerFamily getFamily() { - return this.family; + return family; } // IMedia implementation @@ -79,10 +79,10 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte @Override public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) { - ComputerFamily family = this.getFamily(); + ComputerFamily family = getFamily(); if( family != ComputerFamily.COMMAND ) { - int id = this.getComputerID( stack ); + int id = getComputerID( stack ); if( id >= 0 ) { return ComputerCraftAPI.createSaveDirMount( world, "computer/" + id, ComputerCraft.computerSpaceLimit ); diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java index 07a149301..8b4cfaa58 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerConvertRecipe.java @@ -34,7 +34,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe @Override public String getGroup() { - return this.group; + return group; } @Override @@ -67,7 +67,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe ItemStack stack = inventory.getStack( i ); if( stack.getItem() instanceof IComputerItem ) { - return this.convert( (IComputerItem) stack.getItem(), stack ); + return convert( (IComputerItem) stack.getItem(), stack ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java index 265f2900d..4e9342a49 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java @@ -32,7 +32,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe public ComputerFamily getFamily() { - return this.family; + return family; } public abstract static class Serializer implements RecipeSerializer @@ -47,7 +47,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json ); ItemStack result = getItemStack( JsonHelper.getObject( json, "result" ) ); - return this.create( identifier, group, template.width, template.height, template.ingredients, result, family ); + return create( identifier, group, template.width, template.height, template.ingredients, result, family ); } protected abstract T create( Identifier identifier, String group, int width, int height, DefaultedList ingredients, ItemStack result, @@ -69,7 +69,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe ItemStack result = buf.readItemStack(); ComputerFamily family = buf.readEnumConstant( ComputerFamily.class ); - return this.create( identifier, group, width, height, ingredients, result, family ); + return create( identifier, group, width, height, ingredients, result, family ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java index 57954114a..b22c10b14 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java @@ -19,7 +19,7 @@ import javax.annotation.Nonnull; public class ComputerUpgradeRecipe extends ComputerFamilyRecipe { public static final RecipeSerializer SERIALIZER = - new dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe.Serializer() + new ComputerFamilyRecipe.Serializer() { @Override protected ComputerUpgradeRecipe create( Identifier identifier, String group, int width, int height, DefaultedList ingredients, @@ -39,7 +39,7 @@ public class ComputerUpgradeRecipe extends ComputerFamilyRecipe @Override protected ItemStack convert( @Nonnull IComputerItem item, @Nonnull ItemStack stack ) { - return item.withFamily( stack, this.getFamily() ); + return item.withFamily( stack, getFamily() ); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java b/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java index 50220fa1c..8a45e575b 100644 --- a/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java +++ b/src/main/java/dan200/computercraft/shared/data/ConstantLootConditionSerializer.java @@ -38,6 +38,6 @@ public final class ConstantLootConditionSerializer impl @Override public T fromJson( @Nonnull JsonObject json, @Nonnull JsonDeserializationContext context ) { - return this.instance; + return instance; } } diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java index deeb80c3b..a858fd6c4 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java +++ b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java @@ -54,7 +54,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem @Override public void appendStacks( @Nonnull ItemGroup tabs, @Nonnull DefaultedList list ) { - if( !this.isIn( tabs ) ) + if( !isIn( tabs ) ) { return; } diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java b/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java index 480e8c08d..77a15ef4e 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java +++ b/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java @@ -158,7 +158,7 @@ public class ItemPrintout extends Item public Type getType() { - return this.type; + return type; } public enum Type diff --git a/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java b/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java index 304c3581d..730f8584f 100644 --- a/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java +++ b/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java @@ -30,7 +30,7 @@ public final class RecordMedia implements IMedia @Override public String getLabel( @Nonnull ItemStack stack ) { - return this.getAudioTitle( stack ); + return getAudioTitle( stack ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java index a64bce717..748e61f91 100644 --- a/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java +++ b/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java @@ -47,7 +47,7 @@ public class DiskRecipe extends SpecialCraftingRecipe if( !stack.isEmpty() ) { - if( this.paper.test( stack ) ) + if( paper.test( stack ) ) { if( paperFound ) { @@ -55,7 +55,7 @@ public class DiskRecipe extends SpecialCraftingRecipe } paperFound = true; } - else if( this.redstone.test( stack ) ) + else if( redstone.test( stack ) ) { if( redstoneFound ) { diff --git a/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java b/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java index 13e75e73b..421af7edf 100644 --- a/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java +++ b/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java @@ -22,8 +22,8 @@ import javax.annotation.Nonnull; public final class PrintoutRecipe extends SpecialCraftingRecipe { public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>( PrintoutRecipe::new ); - private final Ingredient paper = Ingredient.ofItems( net.minecraft.item.Items.PAPER ); - private final Ingredient leather = Ingredient.ofItems( net.minecraft.item.Items.LEATHER ); + private final Ingredient paper = Ingredient.ofItems( Items.PAPER ); + private final Ingredient leather = Ingredient.ofItems( Items.LEATHER ); private final Ingredient string = Ingredient.ofItems( Items.STRING ); private PrintoutRecipe( Identifier id ) @@ -41,7 +41,7 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe @Override public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world ) { - return !this.craft( inventory ).isEmpty(); + return !craft( inventory ).isEmpty(); } @Nonnull @@ -73,7 +73,7 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe numPrintouts++; printoutFound = true; } - else if( this.paper.test( stack ) ) + else if( paper.test( stack ) ) { if( printouts == null ) { @@ -83,11 +83,11 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe numPages++; numPrintouts++; } - else if( this.string.test( stack ) && !stringFound ) + else if( string.test( stack ) && !stringFound ) { stringFound = true; } - else if( this.leather.test( stack ) && !leatherFound ) + else if( leather.test( stack ) && !leatherFound ) { leatherFound = true; } diff --git a/src/main/java/dan200/computercraft/shared/network/client/ChatTableClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ChatTableClientMessage.java index 38edc15d3..0933ecdb7 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/ChatTableClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/ChatTableClientMessage.java @@ -37,20 +37,20 @@ public class ChatTableClientMessage implements NetworkMessage @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeVarInt( this.table.getId() ); - buf.writeVarInt( this.table.getColumns() ); - buf.writeBoolean( this.table.getHeaders() != null ); - if( this.table.getHeaders() != null ) + buf.writeVarInt( table.getId() ); + buf.writeVarInt( table.getColumns() ); + buf.writeBoolean( table.getHeaders() != null ); + if( table.getHeaders() != null ) { - for( Text header : this.table.getHeaders() ) + for( Text header : table.getHeaders() ) { buf.writeText( header ); } } - buf.writeVarInt( this.table.getRows() + buf.writeVarInt( table.getRows() .size() ); - for( Text[] row : this.table.getRows() ) + for( Text[] row : table.getRows() ) { for( Text column : row ) { @@ -58,7 +58,7 @@ public class ChatTableClientMessage implements NetworkMessage } } - buf.writeVarInt( this.table.getAdditional() ); + buf.writeVarInt( table.getAdditional() ); } @Override @@ -100,6 +100,6 @@ public class ChatTableClientMessage implements NetworkMessage @Environment( EnvType.CLIENT ) public void handle( PacketContext context ) { - ClientTableFormatter.INSTANCE.display( this.table ); + ClientTableFormatter.INSTANCE.display( table ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/ComputerClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ComputerClientMessage.java index 7e73f4eb5..792de6845 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/ComputerClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/ComputerClientMessage.java @@ -31,27 +31,27 @@ public abstract class ComputerClientMessage implements NetworkMessage public int getInstanceId() { - return this.instanceId; + return instanceId; } @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeVarInt( this.instanceId ); + buf.writeVarInt( instanceId ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { - this.instanceId = buf.readVarInt(); + instanceId = buf.readVarInt(); } public ClientComputer getComputer() { - ClientComputer computer = ComputerCraft.clientComputerRegistry.get( this.instanceId ); + ClientComputer computer = ComputerCraft.clientComputerRegistry.get( instanceId ); if( computer == null ) { - ComputerCraft.clientComputerRegistry.add( this.instanceId, computer = new ClientComputer( this.instanceId ) ); + ComputerCraft.clientComputerRegistry.add( instanceId, computer = new ClientComputer( instanceId ) ); } return computer; } diff --git a/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java index 4eb829cc1..ae04c5310 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java @@ -25,8 +25,8 @@ public class ComputerDataClientMessage extends ComputerClientMessage public ComputerDataClientMessage( ServerComputer computer ) { super( computer.getInstanceID() ); - this.state = computer.getState(); - this.userData = computer.getUserData(); + state = computer.getState(); + userData = computer.getUserData(); } public ComputerDataClientMessage() @@ -37,21 +37,21 @@ public class ComputerDataClientMessage extends ComputerClientMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeEnumConstant( this.state ); - buf.writeCompoundTag( this.userData ); + buf.writeEnumConstant( state ); + buf.writeCompoundTag( userData ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.state = buf.readEnumConstant( ComputerState.class ); - this.userData = buf.readCompoundTag(); + state = buf.readEnumConstant( ComputerState.class ); + userData = buf.readCompoundTag(); } @Override public void handle( PacketContext context ) { - this.getComputer().setState( this.state, this.userData ); + getComputer().setState( state, userData ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/ComputerDeletedClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ComputerDeletedClientMessage.java index 5b858d6e2..4883e6610 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/ComputerDeletedClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/ComputerDeletedClientMessage.java @@ -23,6 +23,6 @@ public class ComputerDeletedClientMessage extends ComputerClientMessage @Override public void handle( PacketContext context ) { - ComputerCraft.clientComputerRegistry.remove( this.getInstanceId() ); + ComputerCraft.clientComputerRegistry.remove( getInstanceId() ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/ComputerTerminalClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ComputerTerminalClientMessage.java index d469c8e83..75ddb5250 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/ComputerTerminalClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/ComputerTerminalClientMessage.java @@ -29,19 +29,19 @@ public class ComputerTerminalClientMessage extends ComputerClientMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - this.state.write( buf ); + state.write( buf ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.state = new TerminalState( buf ); + state = new TerminalState( buf ); } @Override public void handle( PacketContext context ) { - this.getComputer().read( this.state ); + getComputer().read( state ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/MonitorClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/MonitorClientMessage.java index c5966d88e..740171dab 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/MonitorClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/MonitorClientMessage.java @@ -29,15 +29,15 @@ public class MonitorClientMessage implements NetworkMessage public MonitorClientMessage( @Nonnull PacketByteBuf buf ) { - this.pos = buf.readBlockPos(); - this.state = new TerminalState( buf ); + pos = buf.readBlockPos(); + state = new TerminalState( buf ); } @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeBlockPos( this.pos ); - this.state.write( buf ); + buf.writeBlockPos( pos ); + state.write( buf ); } @Override @@ -49,12 +49,12 @@ public class MonitorClientMessage implements NetworkMessage return; } - BlockEntity te = player.world.getBlockEntity( this.pos ); + BlockEntity te = player.world.getBlockEntity( pos ); if( !(te instanceof TileMonitor) ) { return; } - ((TileMonitor) te).read( this.state ); + ((TileMonitor) te).read( state ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java index e8c283653..3e623a892 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java @@ -37,44 +37,44 @@ public class PlayRecordClientMessage implements NetworkMessage { this.pos = pos; this.name = name; - this.soundEvent = event; + soundEvent = event; } public PlayRecordClientMessage( BlockPos pos ) { this.pos = pos; - this.name = null; - this.soundEvent = null; + name = null; + soundEvent = null; } public PlayRecordClientMessage( PacketByteBuf buf ) { - this.pos = buf.readBlockPos(); + pos = buf.readBlockPos(); if( buf.readBoolean() ) { - this.name = buf.readString( Short.MAX_VALUE ); - this.soundEvent = Registry.SOUND_EVENT.get( buf.readIdentifier() ); + name = buf.readString( Short.MAX_VALUE ); + soundEvent = Registry.SOUND_EVENT.get( buf.readIdentifier() ); } else { - this.name = null; - this.soundEvent = null; + name = null; + soundEvent = null; } } @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeBlockPos( this.pos ); - if( this.soundEvent == null ) + buf.writeBlockPos( pos ); + if( soundEvent == null ) { buf.writeBoolean( false ); } else { buf.writeBoolean( true ); - buf.writeString( this.name ); - buf.writeIdentifier( ((SoundEventAccess) this.soundEvent).getId() ); + buf.writeString( name ); + buf.writeIdentifier( ((SoundEventAccess) soundEvent).getId() ); } } @@ -83,10 +83,10 @@ public class PlayRecordClientMessage implements NetworkMessage public void handle( PacketContext context ) { MinecraftClient mc = MinecraftClient.getInstance(); - mc.worldRenderer.playSong( this.soundEvent, this.pos ); - if( this.name != null ) + mc.worldRenderer.playSong( soundEvent, pos ); + if( name != null ) { - mc.inGameHud.setRecordPlayingOverlay( new LiteralText( this.name ) ); + mc.inGameHud.setRecordPlayingOverlay( new LiteralText( name ) ); } } } diff --git a/src/main/java/dan200/computercraft/shared/network/client/TerminalState.java b/src/main/java/dan200/computercraft/shared/network/client/TerminalState.java index 425579a4f..0ecfe413c 100644 --- a/src/main/java/dan200/computercraft/shared/network/client/TerminalState.java +++ b/src/main/java/dan200/computercraft/shared/network/client/TerminalState.java @@ -53,36 +53,36 @@ public class TerminalState if( terminal == null ) { - this.width = this.height = 0; - this.buffer = null; + width = height = 0; + buffer = null; } else { - this.width = terminal.getWidth(); - this.height = terminal.getHeight(); + width = terminal.getWidth(); + height = terminal.getHeight(); - ByteBuf buf = this.buffer = Unpooled.buffer(); + ByteBuf buf = buffer = Unpooled.buffer(); terminal.write( new PacketByteBuf( buf ) ); } } public TerminalState( PacketByteBuf buf ) { - this.colour = buf.readBoolean(); - this.compress = buf.readBoolean(); + colour = buf.readBoolean(); + compress = buf.readBoolean(); if( buf.readBoolean() ) { - this.width = buf.readVarInt(); - this.height = buf.readVarInt(); + width = buf.readVarInt(); + height = buf.readVarInt(); int length = buf.readVarInt(); - this.buffer = readCompressed( buf, length, this.compress ); + buffer = readCompressed( buf, length, compress ); } else { - this.width = this.height = 0; - this.buffer = null; + width = height = 0; + buffer = null; } } @@ -126,16 +126,16 @@ public class TerminalState public void write( PacketByteBuf buf ) { - buf.writeBoolean( this.colour ); - buf.writeBoolean( this.compress ); + buf.writeBoolean( colour ); + buf.writeBoolean( compress ); - buf.writeBoolean( this.buffer != null ); - if( this.buffer != null ) + buf.writeBoolean( buffer != null ); + if( buffer != null ) { - buf.writeVarInt( this.width ); - buf.writeVarInt( this.height ); + buf.writeVarInt( width ); + buf.writeVarInt( height ); - ByteBuf sendBuffer = this.getCompressed(); + ByteBuf sendBuffer = getCompressed(); buf.writeVarInt( sendBuffer.readableBytes() ); buf.writeBytes( sendBuffer, sendBuffer.readerIndex(), sendBuffer.readableBytes() ); } @@ -143,17 +143,17 @@ public class TerminalState private ByteBuf getCompressed() { - if( this.buffer == null ) + if( buffer == null ) { throw new NullPointerException( "buffer" ); } - if( !this.compress ) + if( !compress ) { - return this.buffer; + return buffer; } - if( this.compressed != null ) + if( compressed != null ) { - return this.compressed; + return compressed; } ByteBuf compressed = Unpooled.directBuffer(); @@ -161,7 +161,7 @@ public class TerminalState try { stream = new GZIPOutputStream( new ByteBufOutputStream( compressed ) ); - stream.write( this.buffer.array(), this.buffer.arrayOffset(), this.buffer.readableBytes() ); + stream.write( buffer.array(), buffer.arrayOffset(), buffer.readableBytes() ); } catch( IOException e ) { @@ -177,20 +177,20 @@ public class TerminalState public boolean hasTerminal() { - return this.buffer != null; + return buffer != null; } public int size() { - return this.buffer == null ? 0 : this.buffer.readableBytes(); + return buffer == null ? 0 : buffer.readableBytes(); } public void apply( Terminal terminal ) { - if( this.buffer == null ) + if( buffer == null ) { throw new NullPointerException( "buffer" ); } - terminal.read( new PacketByteBuf( this.buffer ) ); + terminal.read( new PacketByteBuf( buffer ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/container/ComputerContainerData.java b/src/main/java/dan200/computercraft/shared/network/container/ComputerContainerData.java index b19bb2c55..5b97cca97 100644 --- a/src/main/java/dan200/computercraft/shared/network/container/ComputerContainerData.java +++ b/src/main/java/dan200/computercraft/shared/network/container/ComputerContainerData.java @@ -20,19 +20,19 @@ public class ComputerContainerData implements ContainerData public ComputerContainerData( ServerComputer computer ) { - this.id = computer.getInstanceID(); - this.family = computer.getFamily(); + id = computer.getInstanceID(); + family = computer.getFamily(); } public ComputerContainerData( PacketByteBuf byteBuf ) { - this.fromBytes( byteBuf ); + fromBytes( byteBuf ); } public void fromBytes( PacketByteBuf buf ) { - this.id = buf.readInt(); - this.family = buf.readEnumConstant( ComputerFamily.class ); + id = buf.readInt(); + family = buf.readEnumConstant( ComputerFamily.class ); } public Identifier getId() @@ -43,17 +43,17 @@ public class ComputerContainerData implements ContainerData @Override public void toBytes( PacketByteBuf buf ) { - buf.writeInt( this.id ); - buf.writeEnumConstant( this.family ); + buf.writeInt( id ); + buf.writeEnumConstant( family ); } public int getInstanceId() { - return this.id; + return id; } public ComputerFamily getFamily() { - return this.family; + return family; } } diff --git a/src/main/java/dan200/computercraft/shared/network/container/HeldItemContainerData.java b/src/main/java/dan200/computercraft/shared/network/container/HeldItemContainerData.java index 63ae39df6..a32e35af0 100644 --- a/src/main/java/dan200/computercraft/shared/network/container/HeldItemContainerData.java +++ b/src/main/java/dan200/computercraft/shared/network/container/HeldItemContainerData.java @@ -29,18 +29,18 @@ public class HeldItemContainerData implements ContainerData public HeldItemContainerData( PacketByteBuf buffer ) { - this.hand = buffer.readEnumConstant( Hand.class ); + hand = buffer.readEnumConstant( Hand.class ); } @Override public void toBytes( PacketByteBuf buf ) { - buf.writeEnumConstant( this.hand ); + buf.writeEnumConstant( hand ); } @Nonnull public Hand getHand() { - return this.hand; + return hand; } } diff --git a/src/main/java/dan200/computercraft/shared/network/container/ViewComputerContainerData.java b/src/main/java/dan200/computercraft/shared/network/container/ViewComputerContainerData.java index 99ca13879..7d5943804 100644 --- a/src/main/java/dan200/computercraft/shared/network/container/ViewComputerContainerData.java +++ b/src/main/java/dan200/computercraft/shared/network/container/ViewComputerContainerData.java @@ -31,27 +31,27 @@ public class ViewComputerContainerData extends ComputerContainerData Terminal terminal = computer.getTerminal(); if( terminal != null ) { - this.width = terminal.getWidth(); - this.height = terminal.getHeight(); + width = terminal.getWidth(); + height = terminal.getHeight(); } else { - this.width = this.height = 0; + width = height = 0; } } public ViewComputerContainerData( PacketByteBuf packetByteBuf ) { super( new PacketByteBuf( packetByteBuf.copy() ) ); - this.fromBytes( packetByteBuf ); + fromBytes( packetByteBuf ); } @Override public void fromBytes( PacketByteBuf buf ) { super.fromBytes( buf ); - this.width = buf.readVarInt(); - this.height = buf.readVarInt(); + width = buf.readVarInt(); + height = buf.readVarInt(); } @Override @@ -64,17 +64,17 @@ public class ViewComputerContainerData extends ComputerContainerData public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeVarInt( this.width ); - buf.writeVarInt( this.height ); + buf.writeVarInt( width ); + buf.writeVarInt( height ); } public int getWidth() { - return this.width; + return width; } public int getHeight() { - return this.height; + return height; } } diff --git a/src/main/java/dan200/computercraft/shared/network/server/ComputerActionServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/ComputerActionServerMessage.java index 8f3ac121a..0bdc624e8 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/ComputerActionServerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/ComputerActionServerMessage.java @@ -30,20 +30,20 @@ public class ComputerActionServerMessage extends ComputerServerMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeEnumConstant( this.action ); + buf.writeEnumConstant( action ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.action = buf.readEnumConstant( Action.class ); + action = buf.readEnumConstant( Action.class ); } @Override protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) { - switch( this.action ) + switch( action ) { case TURN_ON: computer.turnOn(); diff --git a/src/main/java/dan200/computercraft/shared/network/server/ComputerServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/ComputerServerMessage.java index 2a13e607f..a97bc299b 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/ComputerServerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/ComputerServerMessage.java @@ -36,19 +36,19 @@ public abstract class ComputerServerMessage implements NetworkMessage @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeVarInt( this.instanceId ); + buf.writeVarInt( instanceId ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { - this.instanceId = buf.readVarInt(); + instanceId = buf.readVarInt(); } @Override public void handle( PacketContext context ) { - ServerComputer computer = ComputerCraft.serverComputerRegistry.get( this.instanceId ); + ServerComputer computer = ComputerCraft.serverComputerRegistry.get( instanceId ); if( computer == null ) { return; @@ -60,7 +60,7 @@ public abstract class ComputerServerMessage implements NetworkMessage return; } - this.handle( computer, container ); + handle( computer, container ); } protected abstract void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ); diff --git a/src/main/java/dan200/computercraft/shared/network/server/KeyEventServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/KeyEventServerMessage.java index 5d6811d11..03b7c11f2 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/KeyEventServerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/KeyEventServerMessage.java @@ -37,29 +37,29 @@ public class KeyEventServerMessage extends ComputerServerMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeByte( this.type ); - buf.writeVarInt( this.key ); + buf.writeByte( type ); + buf.writeVarInt( key ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.type = buf.readByte(); - this.key = buf.readVarInt(); + type = buf.readByte(); + key = buf.readVarInt(); } @Override protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) { InputState input = container.getInput(); - if( this.type == TYPE_UP ) + if( type == TYPE_UP ) { - input.keyUp( this.key ); + input.keyUp( key ); } else { - input.keyDown( this.key, this.type == TYPE_REPEAT ); + input.keyDown( key, type == TYPE_REPEAT ); } } } diff --git a/src/main/java/dan200/computercraft/shared/network/server/MouseEventServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/MouseEventServerMessage.java index 763e36ca1..fbccad974 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/MouseEventServerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/MouseEventServerMessage.java @@ -42,39 +42,39 @@ public class MouseEventServerMessage extends ComputerServerMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeByte( this.type ); - buf.writeVarInt( this.arg ); - buf.writeVarInt( this.x ); - buf.writeVarInt( this.y ); + buf.writeByte( type ); + buf.writeVarInt( arg ); + buf.writeVarInt( x ); + buf.writeVarInt( y ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.type = buf.readByte(); - this.arg = buf.readVarInt(); - this.x = buf.readVarInt(); - this.y = buf.readVarInt(); + type = buf.readByte(); + arg = buf.readVarInt(); + x = buf.readVarInt(); + y = buf.readVarInt(); } @Override protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) { InputState input = container.getInput(); - switch( this.type ) + switch( type ) { case TYPE_CLICK: - input.mouseClick( this.arg, this.x, this.y ); + input.mouseClick( arg, x, y ); break; case TYPE_DRAG: - input.mouseDrag( this.arg, this.x, this.y ); + input.mouseDrag( arg, x, y ); break; case TYPE_UP: - input.mouseUp( this.arg, this.x, this.y ); + input.mouseUp( arg, x, y ); break; case TYPE_SCROLL: - input.mouseScroll( this.arg, this.x, this.y ); + input.mouseScroll( arg, x, y ); break; } } diff --git a/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java index dfa262b05..d5efb130e 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java @@ -41,15 +41,15 @@ public class QueueEventServerMessage extends ComputerServerMessage public void toBytes( @Nonnull PacketByteBuf buf ) { super.toBytes( buf ); - buf.writeString( this.event ); - buf.writeCompoundTag( this.args == null ? null : NBTUtil.encodeObjects( this.args ) ); + buf.writeString( event ); + buf.writeCompoundTag( args == null ? null : NBTUtil.encodeObjects( args ) ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { super.fromBytes( buf ); - this.event = buf.readString( Short.MAX_VALUE ); + event = buf.readString( Short.MAX_VALUE ); CompoundTag args = buf.readCompoundTag(); this.args = args == null ? null : NBTUtil.decodeObjects( args ); @@ -58,6 +58,6 @@ public class QueueEventServerMessage extends ComputerServerMessage @Override protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) { - computer.queueEvent( this.event, this.args ); + computer.queueEvent( event, args ); } } diff --git a/src/main/java/dan200/computercraft/shared/network/server/RequestComputerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/RequestComputerMessage.java index 0b086ad7d..2a0afddac 100644 --- a/src/main/java/dan200/computercraft/shared/network/server/RequestComputerMessage.java +++ b/src/main/java/dan200/computercraft/shared/network/server/RequestComputerMessage.java @@ -30,19 +30,19 @@ public class RequestComputerMessage implements NetworkMessage @Override public void toBytes( @Nonnull PacketByteBuf buf ) { - buf.writeVarInt( this.instance ); + buf.writeVarInt( instance ); } @Override public void fromBytes( @Nonnull PacketByteBuf buf ) { - this.instance = buf.readVarInt(); + instance = buf.readVarInt(); } @Override public void handle( PacketContext context ) { - ServerComputer computer = ComputerCraft.serverComputerRegistry.get( this.instance ); + ServerComputer computer = ComputerCraft.serverComputerRegistry.get( instance ); if( computer != null ) { computer.sendComputerState( context.getPlayer() ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/commandblock/CommandBlockPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/commandblock/CommandBlockPeripheral.java index 9b9b78bb8..c812dd91b 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/commandblock/CommandBlockPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/commandblock/CommandBlockPeripheral.java @@ -46,13 +46,13 @@ public class CommandBlockPeripheral implements IPeripheral @Override public Object getTarget() { - return this.commandBlock; + return commandBlock; } @Override public boolean equals( IPeripheral other ) { - return other != null && other.getClass() == this.getClass(); + return other != null && other.getClass() == getClass(); } /** @@ -63,7 +63,7 @@ public class CommandBlockPeripheral implements IPeripheral @LuaFunction( mainThread = true ) public final String getCommand() { - return this.commandBlock.getCommandExecutor() + return commandBlock.getCommandExecutor() .getCommand(); } @@ -75,9 +75,9 @@ public class CommandBlockPeripheral implements IPeripheral @LuaFunction( mainThread = true ) public final void setCommand( String command ) { - this.commandBlock.getCommandExecutor() + commandBlock.getCommandExecutor() .setCommand( command ); - this.commandBlock.getCommandExecutor() + commandBlock.getCommandExecutor() .markDirty(); } @@ -91,9 +91,9 @@ public class CommandBlockPeripheral implements IPeripheral @LuaFunction( mainThread = true ) public final Object[] runCommand() { - this.commandBlock.getCommandExecutor() - .execute( this.commandBlock.getWorld() ); - int result = this.commandBlock.getCommandExecutor() + commandBlock.getCommandExecutor() + .execute( commandBlock.getWorld() ); + int result = commandBlock.getCommandExecutor() .getSuccessCount(); return result > 0 ? new Object[] { true } : new Object[] { false, "Command failed" }; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java index 238ea300e..35ec91d6f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java @@ -36,7 +36,7 @@ public class BlockDiskDrive extends BlockGeneric public BlockDiskDrive( Settings settings ) { super( settings, ComputerCraftRegistry.ModTiles.DISK_DRIVE ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( FACING, Direction.NORTH ) .with( STATE, DiskDriveState.EMPTY ) ); } @@ -45,7 +45,7 @@ public class BlockDiskDrive extends BlockGeneric @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, placement.getPlayerFacing() .getOpposite() ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/ContainerDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/ContainerDiskDrive.java index 41ba16eef..385fe16b1 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/ContainerDiskDrive.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/ContainerDiskDrive.java @@ -32,19 +32,19 @@ public class ContainerDiskDrive extends ScreenHandler this.inventory = inventory; - this.addSlot( new Slot( this.inventory, 0, 8 + 4 * 18, 35 ) ); + addSlot( new Slot( this.inventory, 0, 8 + 4 * 18, 35 ) ); for( int y = 0; y < 3; y++ ) { for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18 ) ); + addSlot( new Slot( player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18 ) ); } } for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( player, x, 8 + x * 18, 142 ) ); + addSlot( new Slot( player, x, 8 + x * 18, 142 ) ); } } @@ -52,7 +52,7 @@ public class ContainerDiskDrive extends ScreenHandler @Override public ItemStack transferSlot( @Nonnull PlayerEntity player, int slotIndex ) { - Slot slot = this.slots.get( slotIndex ); + Slot slot = slots.get( slotIndex ); if( slot == null || !slot.hasStack() ) { return ItemStack.EMPTY; @@ -64,7 +64,7 @@ public class ContainerDiskDrive extends ScreenHandler if( slotIndex == 0 ) { // Insert into player inventory - if( !this.insertItem( existing, 1, 37, true ) ) + if( !insertItem( existing, 1, 37, true ) ) { return ItemStack.EMPTY; } @@ -72,7 +72,7 @@ public class ContainerDiskDrive extends ScreenHandler else { // Insert into drive inventory - if( !this.insertItem( existing, 0, 1, false ) ) + if( !insertItem( existing, 0, 1, false ) ) { return ItemStack.EMPTY; } @@ -99,6 +99,6 @@ public class ContainerDiskDrive extends ScreenHandler @Override public boolean canUse( @Nonnull PlayerEntity player ) { - return this.inventory.canPlayerUse( player ); + return inventory.canPlayerUse( player ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java index 6ab85c4ae..91ee5bc82 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java @@ -51,26 +51,26 @@ public class DiskDrivePeripheral implements IPeripheral @Override public void attach( @Nonnull IComputerAccess computer ) { - this.diskDrive.mount( computer ); + diskDrive.mount( computer ); } @Override public void detach( @Nonnull IComputerAccess computer ) { - this.diskDrive.unmount( computer ); + diskDrive.unmount( computer ); } @Nonnull @Override public Object getTarget() { - return this.diskDrive; + return diskDrive; } @Override public boolean equals( IPeripheral other ) { - return this == other || other instanceof DiskDrivePeripheral && ((DiskDrivePeripheral) other).diskDrive == this.diskDrive; + return this == other || other instanceof DiskDrivePeripheral && ((DiskDrivePeripheral) other).diskDrive == diskDrive; } /** @@ -81,7 +81,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final boolean isDiskPresent() { - return !this.diskDrive.getDiskStack() + return !diskDrive.getDiskStack() .isEmpty(); } @@ -94,7 +94,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final Object[] getDiskLabel() { - ItemStack stack = this.diskDrive.getDiskStack(); + ItemStack stack = diskDrive.getDiskStack(); IMedia media = MediaProviders.get( stack ); return media == null ? null : new Object[] { media.getLabel( stack ) }; } @@ -113,7 +113,7 @@ public class DiskDrivePeripheral implements IPeripheral public final void setDiskLabel( Optional labelA ) throws LuaException { String label = labelA.orElse( null ); - ItemStack stack = this.diskDrive.getDiskStack(); + ItemStack stack = diskDrive.getDiskStack(); IMedia media = MediaProviders.get( stack ); if( media == null ) { @@ -124,7 +124,7 @@ public class DiskDrivePeripheral implements IPeripheral { throw new LuaException( "Disk label cannot be changed" ); } - this.diskDrive.setDiskStack( stack ); + diskDrive.setDiskStack( stack ); } /** @@ -136,7 +136,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final boolean hasData( IComputerAccess computer ) { - return this.diskDrive.getDiskMountPath( computer ) != null; + return diskDrive.getDiskMountPath( computer ) != null; } /** @@ -149,7 +149,7 @@ public class DiskDrivePeripheral implements IPeripheral @Nullable public final String getMountPath( IComputerAccess computer ) { - return this.diskDrive.getDiskMountPath( computer ); + return diskDrive.getDiskMountPath( computer ); } /** @@ -160,7 +160,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final boolean hasAudio() { - ItemStack stack = this.diskDrive.getDiskStack(); + ItemStack stack = diskDrive.getDiskStack(); IMedia media = MediaProviders.get( stack ); return media != null && media.getAudio( stack ) != null; } @@ -175,7 +175,7 @@ public class DiskDrivePeripheral implements IPeripheral @Nullable public final Object getAudioTitle() { - ItemStack stack = this.diskDrive.getDiskStack(); + ItemStack stack = diskDrive.getDiskStack(); IMedia media = MediaProviders.get( stack ); return media != null ? media.getAudioTitle( stack ) : false; } @@ -186,7 +186,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final void playAudio() { - this.diskDrive.playDiskAudio(); + diskDrive.playDiskAudio(); } /** @@ -197,7 +197,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final void stopAudio() { - this.diskDrive.stopDiskAudio(); + diskDrive.stopDiskAudio(); } /** @@ -206,7 +206,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final void ejectDisk() { - this.diskDrive.ejectDisk(); + diskDrive.ejectDisk(); } /** @@ -218,7 +218,7 @@ public class DiskDrivePeripheral implements IPeripheral @LuaFunction public final Object[] getDiskID() { - ItemStack disk = this.diskDrive.getDiskStack(); + ItemStack disk = diskDrive.getDiskStack(); return disk.getItem() instanceof ItemDisk ? new Object[] { ItemDisk.getDiskID( disk ) } : null; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java index 56543796d..1e146c3c7 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveState.java @@ -25,6 +25,6 @@ public enum DiskDriveState implements StringIdentifiable @Nonnull public String asString() { - return this.name; + return name; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java index 25066fbec..4fafe3edd 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java @@ -65,10 +65,10 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public void destroy() { - this.ejectContents( true ); - if( this.recordPlaying ) + ejectContents( true ); + if( recordPlaying ) { - this.stopRecord(); + stopRecord(); } } @@ -84,9 +84,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { return ActionResult.PASS; } - if( !this.getWorld().isClient && this.getStack( 0 ).isEmpty() && MediaProviders.get( disk ) != null ) + if( !getWorld().isClient && getStack( 0 ).isEmpty() && MediaProviders.get( disk ) != null ) { - this.setDiskStack( disk ); + setDiskStack( disk ); player.setStackInHand( hand, ItemStack.EMPTY ); } return ActionResult.SUCCESS; @@ -94,7 +94,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory else { // Open the GUI - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { player.openHandledScreen( this ); } @@ -104,19 +104,19 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory public Direction getDirection() { - return this.getCachedState().get( BlockDiskDrive.FACING ); + return getCachedState().get( BlockDiskDrive.FACING ); } @Override public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt ) { super.fromTag( state, nbt ); - this.customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; + customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; if( nbt.contains( NBT_ITEM ) ) { CompoundTag item = nbt.getCompound( NBT_ITEM ); - this.diskStack = ItemStack.fromTag( item ); - this.diskMount = null; + diskStack = ItemStack.fromTag( item ); + diskMount = null; } } @@ -124,15 +124,15 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public CompoundTag toTag( @Nonnull CompoundTag nbt ) { - if( this.customName != null ) + if( customName != null ) { - nbt.putString( NBT_NAME, Text.Serializer.toJson( this.customName ) ); + nbt.putString( NBT_NAME, Text.Serializer.toJson( customName ) ); } - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { CompoundTag item = new CompoundTag(); - this.diskStack.toTag( item ); + diskStack.toTag( item ); nbt.put( NBT_ITEM, item ); } return super.toTag( nbt ); @@ -141,9 +141,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public void markDirty() { - if( !this.world.isClient ) + if( !world.isClient ) { - this.updateBlockState(); + updateBlockState(); } super.markDirty(); } @@ -152,36 +152,36 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory public void tick() { // Ejection - if( this.ejectQueued ) + if( ejectQueued ) { - this.ejectContents( false ); - this.ejectQueued = false; + ejectContents( false ); + ejectQueued = false; } // Music synchronized( this ) { - if( !this.world.isClient && this.recordPlaying != this.recordQueued || this.restartRecord ) + if( !world.isClient && recordPlaying != recordQueued || restartRecord ) { - this.restartRecord = false; - if( this.recordQueued ) + restartRecord = false; + if( recordQueued ) { - IMedia contents = this.getDiskMedia(); - SoundEvent record = contents != null ? contents.getAudio( this.diskStack ) : null; + IMedia contents = getDiskMedia(); + SoundEvent record = contents != null ? contents.getAudio( diskStack ) : null; if( record != null ) { - this.recordPlaying = true; - this.playRecord(); + recordPlaying = true; + playRecord(); } else { - this.recordQueued = false; + recordQueued = false; } } else { - this.stopRecord(); - this.recordPlaying = false; + stopRecord(); + recordPlaying = false; } } } @@ -198,34 +198,34 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public boolean isEmpty() { - return this.diskStack.isEmpty(); + return diskStack.isEmpty(); } @Nonnull @Override public ItemStack getStack( int slot ) { - return this.diskStack; + return diskStack; } @Nonnull @Override public ItemStack removeStack( int slot, int count ) { - if( this.diskStack.isEmpty() ) + if( diskStack.isEmpty() ) { return ItemStack.EMPTY; } - if( this.diskStack.getCount() <= count ) + if( diskStack.getCount() <= count ) { - ItemStack disk = this.diskStack; - this.setStack( slot, ItemStack.EMPTY ); + ItemStack disk = diskStack; + setStack( slot, ItemStack.EMPTY ); return disk; } - ItemStack part = this.diskStack.split( count ); - this.setStack( slot, this.diskStack.isEmpty() ? ItemStack.EMPTY : this.diskStack ); + ItemStack part = diskStack.split( count ); + setStack( slot, diskStack.isEmpty() ? ItemStack.EMPTY : diskStack ); return part; } @@ -233,9 +233,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public ItemStack removeStack( int slot ) { - ItemStack result = this.diskStack; - this.diskStack = ItemStack.EMPTY; - this.diskMount = null; + ItemStack result = diskStack; + diskStack = ItemStack.EMPTY; + diskMount = null; return result; } @@ -243,53 +243,53 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public void setStack( int slot, @Nonnull ItemStack stack ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { - this.diskStack = stack; - this.diskMount = null; - this.markDirty(); + diskStack = stack; + diskMount = null; + markDirty(); return; } synchronized( this ) { - if( InventoryUtil.areItemsStackable( stack, this.diskStack ) ) + if( InventoryUtil.areItemsStackable( stack, diskStack ) ) { - this.diskStack = stack; + diskStack = stack; return; } // Unmount old disk - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { // TODO: Is this iteration thread safe? Set computers = this.computers.keySet(); for( IComputerAccess computer : computers ) { - this.unmountDisk( computer ); + unmountDisk( computer ); } } // Stop music - if( this.recordPlaying ) + if( recordPlaying ) { - this.stopRecord(); - this.recordPlaying = false; - this.recordQueued = false; + stopRecord(); + recordPlaying = false; + recordQueued = false; } // Swap disk over - this.diskStack = stack; - this.diskMount = null; - this.markDirty(); + diskStack = stack; + diskMount = null; + markDirty(); // Mount new disk - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { Set computers = this.computers.keySet(); for( IComputerAccess computer : computers ) { - this.mountDisk( computer ); + mountDisk( computer ); } } } @@ -298,13 +298,13 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public boolean canPlayerUse( @Nonnull PlayerEntity player ) { - return this.isUsable( player, false ); + return isUsable( player, false ); } @Override public void clear() { - this.setStack( 0, ItemStack.EMPTY ); + setStack( 0, ItemStack.EMPTY ); } @Nonnull @@ -318,7 +318,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { synchronized( this ) { - MountInfo info = this.computers.get( computer ); + MountInfo info = computers.get( computer ); return info != null ? info.mountPath : null; } } @@ -327,32 +327,32 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { synchronized( this ) { - this.computers.put( computer, new MountInfo() ); - this.mountDisk( computer ); + computers.put( computer, new MountInfo() ); + mountDisk( computer ); } } private synchronized void mountDisk( IComputerAccess computer ) { - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { - MountInfo info = this.computers.get( computer ); - IMedia contents = this.getDiskMedia(); + MountInfo info = computers.get( computer ); + IMedia contents = getDiskMedia(); if( contents != null ) { - if( this.diskMount == null ) + if( diskMount == null ) { - this.diskMount = contents.createDataMount( this.diskStack, this.getWorld() ); + diskMount = contents.createDataMount( diskStack, getWorld() ); } - if( this.diskMount != null ) + if( diskMount != null ) { - if( this.diskMount instanceof IWritableMount ) + if( diskMount instanceof IWritableMount ) { // Try mounting at the lowest numbered "disk" name we can int n = 1; while( info.mountPath == null ) { - info.mountPath = computer.mountWritable( n == 1 ? "disk" : "disk" + n, (IWritableMount) this.diskMount ); + info.mountPath = computer.mountWritable( n == 1 ? "disk" : "disk" + n, (IWritableMount) diskMount ); n++; } } @@ -362,7 +362,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory int n = 1; while( info.mountPath == null ) { - info.mountPath = computer.mount( n == 1 ? "disk" : "disk" + n, this.diskMount ); + info.mountPath = computer.mount( n == 1 ? "disk" : "disk" + n, diskMount ); n++; } } @@ -378,34 +378,34 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory private IMedia getDiskMedia() { - return MediaProviders.get( this.getDiskStack() ); + return MediaProviders.get( getDiskStack() ); } @Nonnull ItemStack getDiskStack() { - return this.getStack( 0 ); + return getStack( 0 ); } void setDiskStack( @Nonnull ItemStack stack ) { - this.setStack( 0, stack ); + setStack( 0, stack ); } void unmount( IComputerAccess computer ) { synchronized( this ) { - this.unmountDisk( computer ); - this.computers.remove( computer ); + unmountDisk( computer ); + computers.remove( computer ); } } private synchronized void unmountDisk( IComputerAccess computer ) { - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { - MountInfo info = this.computers.get( computer ); + MountInfo info = computers.get( computer ); assert info != null; if( info.mountPath != null ) { @@ -420,11 +420,11 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { synchronized( this ) { - IMedia media = this.getDiskMedia(); - if( media != null && media.getAudioTitle( this.diskStack ) != null ) + IMedia media = getDiskMedia(); + if( media != null && media.getAudioTitle( diskStack ) != null ) { - this.recordQueued = true; - this.restartRecord = this.recordPlaying; + recordQueued = true; + restartRecord = recordPlaying; } } } @@ -433,8 +433,8 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { synchronized( this ) { - this.recordQueued = false; - this.restartRecord = false; + recordQueued = false; + restartRecord = false; } } @@ -444,85 +444,85 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory { synchronized( this ) { - this.ejectQueued = true; + ejectQueued = true; } } private void updateBlockState() { - if( this.removed ) + if( removed ) { return; } - if( !this.diskStack.isEmpty() ) + if( !diskStack.isEmpty() ) { - IMedia contents = this.getDiskMedia(); - this.updateBlockState( contents != null ? DiskDriveState.FULL : DiskDriveState.INVALID ); + IMedia contents = getDiskMedia(); + updateBlockState( contents != null ? DiskDriveState.FULL : DiskDriveState.INVALID ); } else { - this.updateBlockState( DiskDriveState.EMPTY ); + updateBlockState( DiskDriveState.EMPTY ); } } private void updateBlockState( DiskDriveState state ) { - BlockState blockState = this.getCachedState(); + BlockState blockState = getCachedState(); if( blockState.get( BlockDiskDrive.STATE ) == state ) { return; } - this.getWorld().setBlockState( this.getPos(), blockState.with( BlockDiskDrive.STATE, state ) ); + getWorld().setBlockState( getPos(), blockState.with( BlockDiskDrive.STATE, state ) ); } private synchronized void ejectContents( boolean destroyed ) { - if( this.getWorld().isClient || this.diskStack.isEmpty() ) + if( getWorld().isClient || diskStack.isEmpty() ) { return; } // Remove the disks from the inventory - ItemStack disks = this.diskStack; - this.setDiskStack( ItemStack.EMPTY ); + ItemStack disks = diskStack; + setDiskStack( ItemStack.EMPTY ); // Spawn the item in the world int xOff = 0; int zOff = 0; if( !destroyed ) { - Direction dir = this.getDirection(); + Direction dir = getDirection(); xOff = dir.getOffsetX(); zOff = dir.getOffsetZ(); } - BlockPos pos = this.getPos(); + BlockPos pos = getPos(); double x = pos.getX() + 0.5 + xOff * 0.5; double y = pos.getY() + 0.75; double z = pos.getZ() + 0.5 + zOff * 0.5; - ItemEntity entityitem = new ItemEntity( this.getWorld(), x, y, z, disks ); + ItemEntity entityitem = new ItemEntity( getWorld(), x, y, z, disks ); entityitem.setVelocity( xOff * 0.15, 0, zOff * 0.15 ); - this.getWorld().spawnEntity( entityitem ); + getWorld().spawnEntity( entityitem ); if( !destroyed ) { - this.getWorld().syncGlobalEvent( 1000, this.getPos(), 0 ); + getWorld().syncGlobalEvent( 1000, getPos(), 0 ); } } private void playRecord() { - IMedia contents = this.getDiskMedia(); - SoundEvent record = contents != null ? contents.getAudio( this.diskStack ) : null; + IMedia contents = getDiskMedia(); + SoundEvent record = contents != null ? contents.getAudio( diskStack ) : null; if( record != null ) { - RecordUtil.playRecord( record, contents.getAudioTitle( this.diskStack ), this.getWorld(), this.getPos() ); + RecordUtil.playRecord( record, contents.getAudioTitle( diskStack ), getWorld(), getPos() ); } else { - RecordUtil.playRecord( null, null, this.getWorld(), this.getPos() ); + RecordUtil.playRecord( null, null, getWorld(), getPos() ); } } @@ -530,21 +530,21 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory private void stopRecord() { - RecordUtil.playRecord( null, null, this.getWorld(), this.getPos() ); + RecordUtil.playRecord( null, null, getWorld(), getPos() ); } @Nonnull @Override public Text getName() { - return this.customName != null ? this.customName : new TranslatableText( this.getCachedState().getBlock() + return customName != null ? customName : new TranslatableText( getCachedState().getBlock() .getTranslationKey() ); } @Override public boolean hasCustomName() { - return this.customName != null; + return customName != null; } @Nonnull @@ -558,7 +558,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory @Override public Text getCustomName() { - return this.customName; + return customName; } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/SaturatedMethod.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/SaturatedMethod.java index 31a120e52..eca38e63f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/SaturatedMethod.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/SaturatedMethod.java @@ -24,7 +24,7 @@ final class SaturatedMethod SaturatedMethod( Object target, NamedMethod method ) { this.target = target; - this.name = method.getName(); + name = method.getName(); this.method = method.getMethod(); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java index 0bc394f4e..27e02f18f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java @@ -39,25 +39,25 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa public ModemState getModemState() { - return this.state; + return state; } public void destroy() { - this.setNetwork( null ); + setNetwork( null ); } @Override public void receiveSameDimension( @Nonnull Packet packet, double distance ) { - if( packet.getSender() == this || !this.state.isOpen( packet.getChannel() ) ) + if( packet.getSender() == this || !state.isOpen( packet.getChannel() ) ) { return; } - synchronized( this.computers ) + synchronized( computers ) { - for( IComputerAccess computer : this.computers ) + for( IComputerAccess computer : computers ) { computer.queueEvent( "modem_message", computer.getAttachmentName(), @@ -72,14 +72,14 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @Override public void receiveDifferentDimension( @Nonnull Packet packet ) { - if( packet.getSender() == this || !this.state.isOpen( packet.getChannel() ) ) + if( packet.getSender() == this || !state.isOpen( packet.getChannel() ) ) { return; } - synchronized( this.computers ) + synchronized( computers ) { - for( IComputerAccess computer : this.computers ) + for( IComputerAccess computer : computers ) { computer.queueEvent( "modem_message", computer.getAttachmentName(), packet.getChannel(), packet.getReplyChannel(), packet.getPayload() ); } @@ -96,12 +96,12 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @Override public synchronized void attach( @Nonnull IComputerAccess computer ) { - synchronized( this.computers ) + synchronized( computers ) { - this.computers.add( computer ); + computers.add( computer ); } - this.setNetwork( this.getNetwork() ); + setNetwork( getNetwork() ); } protected abstract IPacketNetwork getNetwork(); @@ -133,15 +133,15 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa public synchronized void detach( @Nonnull IComputerAccess computer ) { boolean empty; - synchronized( this.computers ) + synchronized( computers ) { - this.computers.remove( computer ); - empty = this.computers.isEmpty(); + computers.remove( computer ); + empty = computers.isEmpty(); } if( empty ) { - this.setNetwork( null ); + setNetwork( null ); } } @@ -155,7 +155,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @LuaFunction public final void open( int channel ) throws LuaException { - this.state.open( parseChannel( channel ) ); + state.open( parseChannel( channel ) ); } private static int parseChannel( int channel ) throws LuaException @@ -177,7 +177,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @LuaFunction public final boolean isOpen( int channel ) throws LuaException { - return this.state.isOpen( parseChannel( channel ) ); + return state.isOpen( parseChannel( channel ) ); } /** @@ -189,7 +189,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @LuaFunction public final void close( int channel ) throws LuaException { - this.state.close( parseChannel( channel ) ); + state.close( parseChannel( channel ) ); } /** @@ -198,7 +198,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @LuaFunction public final void closeAll() { - this.state.closeAll(); + state.closeAll(); } /** @@ -217,8 +217,8 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa parseChannel( channel ); parseChannel( replyChannel ); - World world = this.getWorld(); - Vec3d position = this.getPosition(); + World world = getWorld(); + Vec3d position = getPosition(); IPacketNetwork network = this.network; if( world == null || position == null || network == null ) @@ -227,13 +227,13 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa } Packet packet = new Packet( channel, replyChannel, payload, this ); - if( this.isInterdimensional() ) + if( isInterdimensional() ) { network.transmitInterdimensional( packet ); } else { - network.transmitSameDimension( packet, this.getRange() ); + network.transmitSameDimension( packet, getRange() ); } } @@ -255,15 +255,15 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa @Override public String getSenderID() { - synchronized( this.computers ) + synchronized( computers ) { - if( this.computers.size() != 1 ) + if( computers.size() != 1 ) { return "unknown"; } else { - IComputerAccess computer = this.computers.iterator() + IComputerAccess computer = computers.iterator() .next(); return computer.getID() + "_" + computer.getAttachmentName(); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemState.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemState.java index 5d56ef3ae..95f52550b 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemState.java @@ -21,7 +21,7 @@ public class ModemState public ModemState() { - this.onChanged = null; + onChanged = null; } public ModemState( Runnable onChanged ) @@ -31,12 +31,12 @@ public class ModemState public boolean pollChanged() { - return this.changed.getAndSet( false ); + return changed.getAndSet( false ); } public boolean isOpen() { - return this.open; + return open; } private void setOpen( boolean open ) @@ -46,54 +46,54 @@ public class ModemState return; } this.open = open; - if( !this.changed.getAndSet( true ) && this.onChanged != null ) + if( !changed.getAndSet( true ) && onChanged != null ) { - this.onChanged.run(); + onChanged.run(); } } public boolean isOpen( int channel ) { - synchronized( this.channels ) + synchronized( channels ) { - return this.channels.contains( channel ); + return channels.contains( channel ); } } public void open( int channel ) throws LuaException { - synchronized( this.channels ) + synchronized( channels ) { - if( !this.channels.contains( channel ) ) + if( !channels.contains( channel ) ) { - if( this.channels.size() >= 128 ) + if( channels.size() >= 128 ) { throw new LuaException( "Too many open channels" ); } - this.channels.add( channel ); - this.setOpen( true ); + channels.add( channel ); + setOpen( true ); } } } public void close( int channel ) { - synchronized( this.channels ) + synchronized( channels ) { - this.channels.remove( channel ); - if( this.channels.isEmpty() ) + channels.remove( channel ); + if( channels.isEmpty() ) { - this.setOpen( false ); + setOpen( false ); } } } public void closeAll() { - synchronized( this.channels ) + synchronized( channels ) { - this.channels.clear(); - this.setOpen( false ); + channels.clear(); + setOpen( false ); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java index 4e958b69c..27874fc9f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java @@ -66,7 +66,7 @@ public class BlockCable extends BlockGeneric implements Waterloggable { super( settings, ComputerCraftRegistry.ModTiles.CABLE ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( MODEM, CableModemVariant.None ) .with( CABLE, false ) .with( NORTH, false ) @@ -94,7 +94,7 @@ public class BlockCable extends BlockGeneric implements Waterloggable // Should never happen, but handle the case where we've no modem or cable. if( !state.get( CABLE ) && state.get( MODEM ) == CableModemVariant.None ) { - return this.getFluidState( state ).getBlockState(); + return getFluidState( state ).getBlockState(); } return state.with( CONNECTIONS.get( side ), doesConnectVisually( state, world, pos, side ) ); @@ -211,7 +211,7 @@ public class BlockCable extends BlockGeneric implements Waterloggable @Override public BlockState getPlacementState( @Nonnull ItemPlacementContext context ) { - BlockState state = this.getDefaultState().with( WATERLOGGED, getWaterloggedStateForPlacement( context ) ); + BlockState state = getDefaultState().with( WATERLOGGED, getWaterloggedStateForPlacement( context ) ); if( context.getStack() .getItem() instanceof ItemBlockCable.Cable ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockWiredModemFull.java index fc6572cc3..bdc49847e 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockWiredModemFull.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockWiredModemFull.java @@ -21,7 +21,7 @@ public class BlockWiredModemFull extends BlockGeneric public BlockWiredModemFull( Settings settings, BlockEntityType type ) { super( settings, type ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( MODEM_ON, false ) .with( PERIPHERAL_ON, false ) ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java index 5c6fc398d..a45f27db7 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableModemVariant.java @@ -68,18 +68,18 @@ public enum CableModemVariant implements StringIdentifiable @Override public String asString() { - return this.name; + return name; } @Nullable public Direction getFacing() { - return this.facing; + return facing; } @Override public String toString() { - return this.name; + return name; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java index d866b41c7..8e6cc47e7 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/ItemBlockCable.java @@ -39,7 +39,7 @@ public abstract class ItemBlockCable extends BlockItem boolean placeAtCorrected( World world, BlockPos pos, BlockState state ) { - return this.placeAt( world, pos, correctConnections( world, pos, state ), null ); + return placeAt( world, pos, correctConnections( world, pos, state ), null ); } boolean placeAt( World world, BlockPos pos, BlockState state, PlayerEntity player ) @@ -70,17 +70,17 @@ public abstract class ItemBlockCable extends BlockItem @Override public String getTranslationKey() { - if( this.translationKey == null ) + if( translationKey == null ) { - this.translationKey = Util.createTranslationKey( "block", Registry.ITEM.getId( this ) ); + translationKey = Util.createTranslationKey( "block", Registry.ITEM.getId( this ) ); } - return this.translationKey; + return translationKey; } @Override public void appendStacks( @Nonnull ItemGroup group, @Nonnull DefaultedList list ) { - if( this.isIn( group ) ) + if( isIn( group ) ) { list.add( new ItemStack( this ) ); } @@ -114,7 +114,7 @@ public abstract class ItemBlockCable extends BlockItem .getOpposite(); BlockState newState = existingState.with( MODEM, CableModemVariant.from( side ) ) .with( CONNECTIONS.get( side ), existingState.get( CABLE ) ); - if( this.placeAt( world, pos, newState, context.getPlayer() ) ) + if( placeAt( world, pos, newState, context.getPlayer() ) ) { stack.decrement( 1 ); return ActionResult.SUCCESS; @@ -149,7 +149,7 @@ public abstract class ItemBlockCable extends BlockItem BlockPos insidePos = pos.offset( context.getSide() .getOpposite() ); BlockState insideState = world.getBlockState( insidePos ); - if( insideState.getBlock() == ComputerCraftRegistry.ModBlocks.CABLE && !insideState.get( BlockCable.CABLE ) && this.placeAtCorrected( world, + if( insideState.getBlock() == ComputerCraftRegistry.ModBlocks.CABLE && !insideState.get( BlockCable.CABLE ) && placeAtCorrected( world, insidePos, insideState.with( BlockCable.CABLE, @@ -161,7 +161,7 @@ public abstract class ItemBlockCable extends BlockItem // Try to add a cable to a modem adjacent to this block BlockState existingState = world.getBlockState( pos ); - if( existingState.getBlock() == ComputerCraftRegistry.ModBlocks.CABLE && !existingState.get( BlockCable.CABLE ) && this.placeAtCorrected( world, + if( existingState.getBlock() == ComputerCraftRegistry.ModBlocks.CABLE && !existingState.get( BlockCable.CABLE ) && placeAtCorrected( world, pos, existingState.with( BlockCable.CABLE, diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java index 6ac352b89..60ff2bf1d 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileCable.java @@ -43,24 +43,24 @@ public class TileCable extends TileGeneric implements IPeripheralTile private static final String NBT_PERIPHERAL_ENABLED = "PeirpheralAccess"; private final WiredModemLocalPeripheral peripheral = new WiredModemLocalPeripheral(); private final WiredModemElement cable = new CableElement(); - private final IWiredNode node = this.cable.getNode(); + private final IWiredNode node = cable.getNode(); private boolean peripheralAccessAllowed; private boolean destroyed = false; private Direction modemDirection = Direction.NORTH; - private final WiredModemPeripheral modem = new WiredModemPeripheral( new ModemState( () -> TickScheduler.schedule( this ) ), this.cable ) + private final WiredModemPeripheral modem = new WiredModemPeripheral( new ModemState( () -> TickScheduler.schedule( this ) ), cable ) { @Nonnull @Override protected WiredModemLocalPeripheral getLocalPeripheral() { - return TileCable.this.peripheral; + return peripheral; } @Nonnull @Override public Vec3d getPosition() { - BlockPos pos = TileCable.this.getPos().offset( TileCable.this.modemDirection ); + BlockPos pos = getPos().offset( modemDirection ); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @@ -82,11 +82,11 @@ public class TileCable extends TileGeneric implements IPeripheralTile @Override public void destroy() { - if( !this.destroyed ) + if( !destroyed ) { - this.destroyed = true; - this.modem.destroy(); - this.onRemove(); + destroyed = true; + modem.destroy(); + onRemove(); } } @@ -99,10 +99,10 @@ public class TileCable extends TileGeneric implements IPeripheralTile private void onRemove() { - if( this.world == null || !this.world.isClient ) + if( world == null || !world.isClient ) { - this.node.remove(); - this.connectionsFormed = false; + node.remove(); + connectionsFormed = false; } } @@ -114,19 +114,19 @@ public class TileCable extends TileGeneric implements IPeripheralTile { return ActionResult.PASS; } - if( !this.canAttachPeripheral() ) + if( !canAttachPeripheral() ) { return ActionResult.FAIL; } - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return ActionResult.SUCCESS; } - String oldName = this.peripheral.getConnectedName(); - this.togglePeripheralAccess(); - String newName = this.peripheral.getConnectedName(); + String oldName = peripheral.getConnectedName(); + togglePeripheralAccess(); + String newName = peripheral.getConnectedName(); if( !Objects.equal( newName, oldName ) ) { if( oldName != null ) @@ -147,79 +147,79 @@ public class TileCable extends TileGeneric implements IPeripheralTile @Override public void onNeighbourChange( @Nonnull BlockPos neighbour ) { - Direction dir = this.getDirection(); - if( neighbour.equals( this.getPos().offset( dir ) ) && this.hasModem() && !this.getCachedState().canPlaceAt( this.getWorld(), this.getPos() ) ) + Direction dir = getDirection(); + if( neighbour.equals( getPos().offset( dir ) ) && hasModem() && !getCachedState().canPlaceAt( getWorld(), getPos() ) ) { - if( this.hasCable() ) + if( hasCable() ) { // Drop the modem and convert to cable - Block.dropStack( this.getWorld(), this.getPos(), new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM ) ); - this.getWorld().setBlockState( this.getPos(), - this.getCachedState().with( BlockCable.MODEM, CableModemVariant.None ) ); - this.modemChanged(); - this.connectionsChanged(); + Block.dropStack( getWorld(), getPos(), new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM ) ); + getWorld().setBlockState( getPos(), + getCachedState().with( BlockCable.MODEM, CableModemVariant.None ) ); + modemChanged(); + connectionsChanged(); } else { // Drop everything and remove block - Block.dropStack( this.getWorld(), this.getPos(), new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM ) ); - this.getWorld().removeBlock( this.getPos(), false ); + Block.dropStack( getWorld(), getPos(), new ItemStack( ComputerCraftRegistry.ModItems.WIRED_MODEM ) ); + getWorld().removeBlock( getPos(), false ); // This'll call #destroy(), so we don't need to reset the network here. } return; } - this.onNeighbourTileEntityChange( neighbour ); + onNeighbourTileEntityChange( neighbour ); } @Nonnull private Direction getDirection() { - this.refreshDirection(); - return this.modemDirection == null ? Direction.NORTH : this.modemDirection; + refreshDirection(); + return modemDirection == null ? Direction.NORTH : modemDirection; } public boolean hasModem() { - return this.getCachedState().get( BlockCable.MODEM ) != CableModemVariant.None; + return getCachedState().get( BlockCable.MODEM ) != CableModemVariant.None; } boolean hasCable() { - return this.getCachedState().get( BlockCable.CABLE ); + return getCachedState().get( BlockCable.CABLE ); } void modemChanged() { // Tell anyone who cares that the connection state has changed - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return; } // If we can no longer attach peripherals, then detach any // which may have existed - if( !this.canAttachPeripheral() && this.peripheralAccessAllowed ) + if( !canAttachPeripheral() && peripheralAccessAllowed ) { - this.peripheralAccessAllowed = false; - this.peripheral.detach(); - this.node.updatePeripherals( Collections.emptyMap() ); - this.markDirty(); - this.updateBlockState(); + peripheralAccessAllowed = false; + peripheral.detach(); + node.updatePeripherals( Collections.emptyMap() ); + markDirty(); + updateBlockState(); } } void connectionsChanged() { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return; } - BlockState state = this.getCachedState(); - World world = this.getWorld(); - BlockPos current = this.getPos(); + BlockState state = getCachedState(); + World world = getWorld(); + BlockPos current = getPos(); for( Direction facing : DirectionUtil.FACINGS ) { BlockPos offset = current.offset( facing ); @@ -252,54 +252,54 @@ public class TileCable extends TileGeneric implements IPeripheralTile private boolean canAttachPeripheral() { - return this.hasCable() && this.hasModem(); + return hasCable() && hasModem(); } private void updateBlockState() { - BlockState state = this.getCachedState(); + BlockState state = getCachedState(); CableModemVariant oldVariant = state.get( BlockCable.MODEM ); - CableModemVariant newVariant = CableModemVariant.from( oldVariant.getFacing(), this.modem.getModemState() - .isOpen(), this.peripheralAccessAllowed ); + CableModemVariant newVariant = CableModemVariant.from( oldVariant.getFacing(), modem.getModemState() + .isOpen(), peripheralAccessAllowed ); if( oldVariant != newVariant ) { - this.world.setBlockState( this.getPos(), state.with( BlockCable.MODEM, newVariant ) ); + world.setBlockState( getPos(), state.with( BlockCable.MODEM, newVariant ) ); } } private void refreshPeripheral() { - if( this.world != null && !this.isRemoved() && this.peripheral.attach( this.world, this.getPos(), this.getDirection() ) ) + if( world != null && !isRemoved() && peripheral.attach( world, getPos(), getDirection() ) ) { - this.updateConnectedPeripherals(); + updateConnectedPeripherals(); } } private void updateConnectedPeripherals() { - Map peripherals = this.peripheral.toMap(); + Map peripherals = peripheral.toMap(); if( peripherals.isEmpty() ) { // If there are no peripherals then disable access and update the display state. - this.peripheralAccessAllowed = false; - this.updateBlockState(); + peripheralAccessAllowed = false; + updateBlockState(); } - this.node.updatePeripherals( peripherals ); + node.updatePeripherals( peripherals ); } @Override public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) { super.onNeighbourTileEntityChange( neighbour ); - if( !this.world.isClient && this.peripheralAccessAllowed ) + if( !world.isClient && peripheralAccessAllowed ) { - Direction facing = this.getDirection(); - if( this.getPos().offset( facing ) + Direction facing = getDirection(); + if( getPos().offset( facing ) .equals( neighbour ) ) { - this.refreshPeripheral(); + refreshPeripheral(); } } } @@ -307,72 +307,72 @@ public class TileCable extends TileGeneric implements IPeripheralTile @Override public void blockTick() { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return; } - this.refreshDirection(); + refreshDirection(); - if( this.modem.getModemState() + if( modem.getModemState() .pollChanged() ) { - this.updateBlockState(); + updateBlockState(); } - if( !this.connectionsFormed ) + if( !connectionsFormed ) { - this.connectionsFormed = true; + connectionsFormed = true; - this.connectionsChanged(); - if( this.peripheralAccessAllowed ) + connectionsChanged(); + if( peripheralAccessAllowed ) { - this.peripheral.attach( this.world, this.pos, this.modemDirection ); - this.updateConnectedPeripherals(); + peripheral.attach( world, pos, modemDirection ); + updateConnectedPeripherals(); } } } private void togglePeripheralAccess() { - if( !this.peripheralAccessAllowed ) + if( !peripheralAccessAllowed ) { - this.peripheral.attach( this.world, this.getPos(), this.getDirection() ); - if( !this.peripheral.hasPeripheral() ) + peripheral.attach( world, getPos(), getDirection() ); + if( !peripheral.hasPeripheral() ) { return; } - this.peripheralAccessAllowed = true; - this.node.updatePeripherals( this.peripheral.toMap() ); + peripheralAccessAllowed = true; + node.updatePeripherals( peripheral.toMap() ); } else { - this.peripheral.detach(); + peripheral.detach(); - this.peripheralAccessAllowed = false; - this.node.updatePeripherals( Collections.emptyMap() ); + peripheralAccessAllowed = false; + node.updatePeripherals( Collections.emptyMap() ); } - this.updateBlockState(); + updateBlockState(); } @Nullable private Direction getMaybeDirection() { - this.refreshDirection(); - return this.modemDirection; + refreshDirection(); + return modemDirection; } private void refreshDirection() { - if( this.hasModemDirection ) + if( hasModemDirection ) { return; } - this.hasModemDirection = true; - this.modemDirection = this.getCachedState().get( BlockCable.MODEM ) + hasModemDirection = true; + modemDirection = getCachedState().get( BlockCable.MODEM ) .getFacing(); } @@ -380,16 +380,16 @@ public class TileCable extends TileGeneric implements IPeripheralTile public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt ) { super.fromTag( state, nbt ); - this.peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); - this.peripheral.read( nbt, "" ); + peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); + peripheral.read( nbt, "" ); } @Nonnull @Override public CompoundTag toTag( CompoundTag nbt ) { - nbt.putBoolean( NBT_PERIPHERAL_ENABLED, this.peripheralAccessAllowed ); - this.peripheral.write( nbt, "" ); + nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed ); + peripheral.write( nbt, "" ); return super.toTag( nbt ); } @@ -397,7 +397,7 @@ public class TileCable extends TileGeneric implements IPeripheralTile public void markRemoved() { super.markRemoved(); - this.onRemove(); + onRemove(); } @Override @@ -411,25 +411,25 @@ public class TileCable extends TileGeneric implements IPeripheralTile public void resetBlock() { super.resetBlock(); - this.hasModemDirection = false; - if( !this.world.isClient ) + hasModemDirection = false; + if( !world.isClient ) { - this.world.getBlockTickScheduler() - .schedule( this.pos, - this.getCachedState().getBlock(), 0 ); + world.getBlockTickScheduler() + .schedule( pos, + getCachedState().getBlock(), 0 ); } } public IWiredElement getElement( Direction facing ) { - return BlockCable.canConnectIn( this.getCachedState(), facing ) ? this.cable : null; + return BlockCable.canConnectIn( getCachedState(), facing ) ? cable : null; } @Nonnull @Override public IPeripheral getPeripheral( Direction side ) { - return !this.destroyed && this.hasModem() && side == this.getDirection() ? this.modem : null; + return !destroyed && hasModem() && side == getDirection() ? modem : null; } private class CableElement extends WiredModemElement @@ -445,20 +445,20 @@ public class TileCable extends TileGeneric implements IPeripheralTile @Override public Vec3d getPosition() { - BlockPos pos = TileCable.this.getPos(); + BlockPos pos = getPos(); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Override protected void attachPeripheral( String name, IPeripheral peripheral ) { - TileCable.this.modem.attachPeripheral( name, peripheral ); + modem.attachPeripheral( name, peripheral ); } @Override protected void detachPeripheral( String name ) { - TileCable.this.modem.detachPeripheral( name ); + modem.detachPeripheral( name ); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java index 634f529fd..d6c36d23d 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/TileWiredModemFull.java @@ -44,7 +44,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile private final WiredModemLocalPeripheral[] peripherals = new WiredModemLocalPeripheral[6]; private final ModemState modemState = new ModemState( () -> TickScheduler.schedule( this ) ); private final WiredModemElement element = new FullElement( this ); - private final IWiredNode node = this.element.getNode(); + private final IWiredNode node = element.getNode(); private boolean peripheralAccessAllowed = false; private boolean destroyed = false; private boolean connectionsFormed = false; @@ -52,20 +52,20 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile public TileWiredModemFull( BlockEntityType type ) { super( type ); - for( int i = 0; i < this.peripherals.length; i++ ) + for( int i = 0; i < peripherals.length; i++ ) { Direction facing = Direction.byId( i ); - this.peripherals[i] = new WiredModemLocalPeripheral(); + peripherals[i] = new WiredModemLocalPeripheral(); } } @Override public void destroy() { - if( !this.destroyed ) + if( !destroyed ) { - this.destroyed = true; - this.doRemove(); + destroyed = true; + doRemove(); } super.destroy(); } @@ -79,10 +79,10 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile private void doRemove() { - if( this.world == null || !this.world.isClient ) + if( world == null || !world.isClient ) { - this.node.remove(); - this.connectionsFormed = false; + node.remove(); + connectionsFormed = false; } } @@ -90,15 +90,15 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public ActionResult onActivate( PlayerEntity player, Hand hand, BlockHitResult hit ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return ActionResult.SUCCESS; } // On server, we interacted if a peripheral was found - Set oldPeriphNames = this.getConnectedPeripheralNames(); - this.togglePeripheralAccess(); - Set periphNames = this.getConnectedPeripheralNames(); + Set oldPeriphNames = getConnectedPeripheralNames(); + togglePeripheralAccess(); + Set periphNames = getConnectedPeripheralNames(); if( !Objects.equal( periphNames, oldPeriphNames ) ) { @@ -112,20 +112,20 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public void onNeighbourChange( @Nonnull BlockPos neighbour ) { - this.onNeighbourTileEntityChange( neighbour ); + onNeighbourTileEntityChange( neighbour ); } @Override public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) { - if( !this.world.isClient && this.peripheralAccessAllowed ) + if( !world.isClient && peripheralAccessAllowed ) { for( Direction facing : DirectionUtil.FACINGS ) { - if( this.getPos().offset( facing ) + if( getPos().offset( facing ) .equals( neighbour ) ) { - this.refreshPeripheral( facing ); + refreshPeripheral( facing ); } } } @@ -134,41 +134,41 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public void blockTick() { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return; } - if( this.modemState.pollChanged() ) + if( modemState.pollChanged() ) { - this.updateBlockState(); + updateBlockState(); } - if( !this.connectionsFormed ) + if( !connectionsFormed ) { - this.connectionsFormed = true; + connectionsFormed = true; - this.connectionsChanged(); - if( this.peripheralAccessAllowed ) + connectionsChanged(); + if( peripheralAccessAllowed ) { for( Direction facing : DirectionUtil.FACINGS ) { - this.peripherals[facing.ordinal()].attach( this.world, this.getPos(), facing ); + peripherals[facing.ordinal()].attach( world, getPos(), facing ); } - this.updateConnectedPeripherals(); + updateConnectedPeripherals(); } } } private void connectionsChanged() { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { return; } - World world = this.getWorld(); - BlockPos current = this.getPos(); + World world = getWorld(); + BlockPos current = getPos(); for( Direction facing : DirectionUtil.FACINGS ) { BlockPos offset = current.offset( facing ); @@ -183,35 +183,35 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile continue; } - this.node.connectTo( element.getNode() ); + node.connectTo( element.getNode() ); } } private void refreshPeripheral( @Nonnull Direction facing ) { - WiredModemLocalPeripheral peripheral = this.peripherals[facing.ordinal()]; - if( this.world != null && !this.isRemoved() && peripheral.attach( this.world, this.getPos(), facing ) ) + WiredModemLocalPeripheral peripheral = peripherals[facing.ordinal()]; + if( world != null && !isRemoved() && peripheral.attach( world, getPos(), facing ) ) { - this.updateConnectedPeripherals(); + updateConnectedPeripherals(); } } private void updateConnectedPeripherals() { - Map peripherals = this.getConnectedPeripherals(); + Map peripherals = getConnectedPeripherals(); if( peripherals.isEmpty() ) { // If there are no peripherals then disable access and update the display state. - this.peripheralAccessAllowed = false; - this.updateBlockState(); + peripheralAccessAllowed = false; + updateBlockState(); } - this.node.updatePeripherals( peripherals ); + node.updatePeripherals( peripherals ); } private Map getConnectedPeripherals() { - if( !this.peripheralAccessAllowed ) + if( !peripheralAccessAllowed ) { return Collections.emptyMap(); } @@ -226,21 +226,21 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile private void updateBlockState() { - BlockState state = this.getCachedState(); - boolean modemOn = this.modemState.isOpen(), peripheralOn = this.peripheralAccessAllowed; + BlockState state = getCachedState(); + boolean modemOn = modemState.isOpen(), peripheralOn = peripheralAccessAllowed; if( state.get( MODEM_ON ) == modemOn && state.get( PERIPHERAL_ON ) == peripheralOn ) { return; } - this.getWorld().setBlockState( this.getPos(), + getWorld().setBlockState( getPos(), state.with( MODEM_ON, modemOn ) .with( PERIPHERAL_ON, peripheralOn ) ); } private Set getConnectedPeripheralNames() { - if( !this.peripheralAccessAllowed ) + if( !peripheralAccessAllowed ) { return Collections.emptySet(); } @@ -259,13 +259,13 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile private void togglePeripheralAccess() { - if( !this.peripheralAccessAllowed ) + if( !peripheralAccessAllowed ) { boolean hasAny = false; for( Direction facing : DirectionUtil.FACINGS ) { - WiredModemLocalPeripheral peripheral = this.peripherals[facing.ordinal()]; - peripheral.attach( this.world, this.getPos(), facing ); + WiredModemLocalPeripheral peripheral = peripherals[facing.ordinal()]; + peripheral.attach( world, getPos(), facing ); hasAny |= peripheral.hasPeripheral(); } @@ -274,21 +274,21 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile return; } - this.peripheralAccessAllowed = true; - this.node.updatePeripherals( this.getConnectedPeripherals() ); + peripheralAccessAllowed = true; + node.updatePeripherals( getConnectedPeripherals() ); } else { - this.peripheralAccessAllowed = false; + peripheralAccessAllowed = false; - for( WiredModemLocalPeripheral peripheral : this.peripherals ) + for( WiredModemLocalPeripheral peripheral : peripherals ) { peripheral.detach(); } - this.node.updatePeripherals( Collections.emptyMap() ); + node.updatePeripherals( Collections.emptyMap() ); } - this.updateBlockState(); + updateBlockState(); } private static void sendPeripheralChanges( PlayerEntity player, String kind, Collection peripherals ) @@ -318,10 +318,10 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt ) { super.fromTag( state, nbt ); - this.peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); - for( int i = 0; i < this.peripherals.length; i++ ) + peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED ); + for( int i = 0; i < peripherals.length; i++ ) { - this.peripherals[i].read( nbt, Integer.toString( i ) ); + peripherals[i].read( nbt, Integer.toString( i ) ); } } @@ -329,10 +329,10 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public CompoundTag toTag( CompoundTag nbt ) { - nbt.putBoolean( NBT_PERIPHERAL_ENABLED, this.peripheralAccessAllowed ); - for( int i = 0; i < this.peripherals.length; i++ ) + nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed ); + for( int i = 0; i < peripherals.length; i++ ) { - this.peripherals[i].write( nbt, Integer.toString( i ) ); + peripherals[i].write( nbt, Integer.toString( i ) ); } return super.toTag( nbt ); } @@ -341,7 +341,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile public void markRemoved() { super.markRemoved(); - this.doRemove(); + doRemove(); } @Override @@ -353,21 +353,21 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile public IWiredElement getElement() { - return this.element; + return element; } @Nonnull @Override public IPeripheral getPeripheral( Direction side ) { - WiredModemPeripheral peripheral = this.modems[side.ordinal()]; + WiredModemPeripheral peripheral = modems[side.ordinal()]; if( peripheral != null ) { return peripheral; } - WiredModemLocalPeripheral localPeripheral = this.peripherals[side.ordinal()]; - return this.modems[side.ordinal()] = new WiredModemPeripheral( this.modemState, this.element ) + WiredModemLocalPeripheral localPeripheral = peripherals[side.ordinal()]; + return modems[side.ordinal()] = new WiredModemPeripheral( modemState, element ) { @Nonnull @Override @@ -380,7 +380,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public Vec3d getPosition() { - BlockPos pos = TileWiredModemFull.this.getPos().offset( side ); + BlockPos pos = getPos().offset( side ); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @@ -407,7 +407,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile { for( int i = 0; i < 6; i++ ) { - WiredModemPeripheral modem = this.entity.modems[i]; + WiredModemPeripheral modem = entity.modems[i]; if( modem != null ) { modem.detachPeripheral( name ); @@ -420,7 +420,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile { for( int i = 0; i < 6; i++ ) { - WiredModemPeripheral modem = this.entity.modems[i]; + WiredModemPeripheral modem = entity.modems[i]; if( modem != null ) { modem.attachPeripheral( name, peripheral ); @@ -432,14 +432,14 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile @Override public World getWorld() { - return this.entity.getWorld(); + return entity.getWorld(); } @Nonnull @Override public Vec3d getPosition() { - BlockPos pos = this.entity.getPos(); + BlockPos pos = entity.getPos(); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java index 3eb19e6d6..a5b3d3e85 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java @@ -25,7 +25,7 @@ public abstract class WiredModemElement implements IWiredElement @Override public IWiredNode getNode() { - return this.node; + return node; } @Nonnull @@ -38,23 +38,23 @@ public abstract class WiredModemElement implements IWiredElement @Override public void networkChanged( @Nonnull IWiredNetworkChange change ) { - synchronized( this.remotePeripherals ) + synchronized( remotePeripherals ) { - this.remotePeripherals.keySet() + remotePeripherals.keySet() .removeAll( change.peripheralsRemoved() .keySet() ); for( String name : change.peripheralsRemoved() .keySet() ) { - this.detachPeripheral( name ); + detachPeripheral( name ); } for( Map.Entry peripheral : change.peripheralsAdded() .entrySet() ) { - this.attachPeripheral( peripheral.getKey(), peripheral.getValue() ); + attachPeripheral( peripheral.getKey(), peripheral.getValue() ); } - this.remotePeripherals.putAll( change.peripheralsAdded() ); + remotePeripherals.putAll( change.peripheralsAdded() ); } } @@ -64,6 +64,6 @@ public abstract class WiredModemElement implements IWiredElement public Map getRemotePeripherals() { - return this.remotePeripherals; + return remotePeripherals; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java index 271a10ed5..ba16697d1 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java @@ -47,8 +47,8 @@ public final class WiredModemLocalPeripheral */ public boolean attach( @Nonnull World world, @Nonnull BlockPos origin, @Nonnull Direction direction ) { - IPeripheral oldPeripheral = this.peripheral; - IPeripheral peripheral = this.peripheral = this.getPeripheralFrom( world, origin, direction ); + IPeripheral oldPeripheral = peripheral; + IPeripheral peripheral = this.peripheral = getPeripheralFrom( world, origin, direction ); if( peripheral == null ) { @@ -97,60 +97,60 @@ public final class WiredModemLocalPeripheral */ public boolean detach() { - if( this.peripheral == null ) + if( peripheral == null ) { return false; } - this.peripheral = null; + peripheral = null; return true; } @Nullable public String getConnectedName() { - return this.peripheral != null ? this.type + "_" + this.id : null; + return peripheral != null ? type + "_" + id : null; } @Nullable public IPeripheral getPeripheral() { - return this.peripheral; + return peripheral; } public boolean hasPeripheral() { - return this.peripheral != null; + return peripheral != null; } public void extendMap( @Nonnull Map peripherals ) { - if( this.peripheral != null ) + if( peripheral != null ) { - peripherals.put( this.type + "_" + this.id, this.peripheral ); + peripherals.put( type + "_" + id, peripheral ); } } public Map toMap() { - return this.peripheral == null ? Collections.emptyMap() : Collections.singletonMap( this.type + "_" + this.id, this.peripheral ); + return peripheral == null ? Collections.emptyMap() : Collections.singletonMap( type + "_" + id, peripheral ); } public void write( @Nonnull CompoundTag tag, @Nonnull String suffix ) { - if( this.id >= 0 ) + if( id >= 0 ) { - tag.putInt( NBT_PERIPHERAL_ID + suffix, this.id ); + tag.putInt( NBT_PERIPHERAL_ID + suffix, id ); } - if( this.type != null ) + if( type != null ) { - tag.putString( NBT_PERIPHERAL_TYPE + suffix, this.type ); + tag.putString( NBT_PERIPHERAL_TYPE + suffix, type ); } } public void read( @Nonnull CompoundTag tag, @Nonnull String suffix ) { - this.id = tag.contains( NBT_PERIPHERAL_ID + suffix, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_PERIPHERAL_ID + suffix ) : -1; + id = tag.contains( NBT_PERIPHERAL_ID + suffix, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_PERIPHERAL_ID + suffix ) : -1; - this.type = tag.contains( NBT_PERIPHERAL_TYPE + suffix, NBTUtil.TAG_STRING ) ? tag.getString( NBT_PERIPHERAL_TYPE + suffix ) : null; + type = tag.contains( NBT_PERIPHERAL_TYPE + suffix, NBTUtil.TAG_STRING ) ? tag.getString( NBT_PERIPHERAL_TYPE + suffix ) : null; } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java index 147e956dd..90b7555b5 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java @@ -59,7 +59,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override protected IPacketNetwork getNetwork() { - return this.modem.getNode(); + return modem.getNode(); } @Override @@ -68,21 +68,21 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW super.attach( computer ); ConcurrentMap wrappers; - synchronized( this.peripheralWrappers ) + synchronized( peripheralWrappers ) { - wrappers = this.peripheralWrappers.get( computer ); + wrappers = peripheralWrappers.get( computer ); if( wrappers == null ) { - this.peripheralWrappers.put( computer, wrappers = new ConcurrentHashMap<>() ); + peripheralWrappers.put( computer, wrappers = new ConcurrentHashMap<>() ); } } - synchronized( this.modem.getRemotePeripherals() ) + synchronized( modem.getRemotePeripherals() ) { - for( Map.Entry entry : this.modem.getRemotePeripherals() + for( Map.Entry entry : modem.getRemotePeripherals() .entrySet() ) { - this.attachPeripheralImpl( computer, wrappers, entry.getKey(), entry.getValue() ); + attachPeripheralImpl( computer, wrappers, entry.getKey(), entry.getValue() ); } } } @@ -91,9 +91,9 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW public void detach( @Nonnull IComputerAccess computer ) { Map wrappers; - synchronized( this.peripheralWrappers ) + synchronized( peripheralWrappers ) { - wrappers = this.peripheralWrappers.remove( computer ); + wrappers = peripheralWrappers.remove( computer ); } if( wrappers != null ) { @@ -113,9 +113,9 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW private void attachPeripheralImpl( IComputerAccess computer, ConcurrentMap peripherals, String periphName, IPeripheral peripheral ) { - if( !peripherals.containsKey( periphName ) && !periphName.equals( this.getLocalPeripheral().getConnectedName() ) ) + if( !peripherals.containsKey( periphName ) && !periphName.equals( getLocalPeripheral().getConnectedName() ) ) { - RemotePeripheralWrapper wrapper = new RemotePeripheralWrapper( this.modem, peripheral, computer, periphName ); + RemotePeripheralWrapper wrapper = new RemotePeripheralWrapper( modem, peripheral, computer, periphName ); peripherals.put( periphName, wrapper ); wrapper.attach(); } @@ -125,7 +125,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override public World getWorld() { - return this.modem.getWorld(); + return modem.getWorld(); } /** @@ -142,14 +142,14 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @LuaFunction public final Collection getNamesRemote( IComputerAccess computer ) { - return this.getWrappers( computer ).keySet(); + return getWrappers( computer ).keySet(); } private ConcurrentMap getWrappers( IComputerAccess computer ) { - synchronized( this.peripheralWrappers ) + synchronized( peripheralWrappers ) { - return this.peripheralWrappers.get( computer ); + return peripheralWrappers.get( computer ); } } @@ -167,12 +167,12 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @LuaFunction public final boolean isPresentRemote( IComputerAccess computer, String name ) { - return this.getWrapper( computer, name ) != null; + return getWrapper( computer, name ) != null; } private RemotePeripheralWrapper getWrapper( IComputerAccess computer, String remoteName ) { - ConcurrentMap wrappers = this.getWrappers( computer ); + ConcurrentMap wrappers = getWrappers( computer ); return wrappers == null ? null : wrappers.get( remoteName ); } @@ -191,7 +191,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @LuaFunction public final Object[] getTypeRemote( IComputerAccess computer, String name ) { - RemotePeripheralWrapper wrapper = this.getWrapper( computer, name ); + RemotePeripheralWrapper wrapper = getWrapper( computer, name ); return wrapper != null ? new Object[] { wrapper.getType() } : null; } @@ -210,7 +210,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @LuaFunction public final Object[] getMethodsRemote( IComputerAccess computer, String name ) { - RemotePeripheralWrapper wrapper = this.getWrapper( computer, name ); + RemotePeripheralWrapper wrapper = getWrapper( computer, name ); if( wrapper == null ) { return null; @@ -241,7 +241,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW { String remoteName = arguments.getString( 0 ); String methodName = arguments.getString( 1 ); - RemotePeripheralWrapper wrapper = this.getWrapper( computer, remoteName ); + RemotePeripheralWrapper wrapper = getWrapper( computer, remoteName ); if( wrapper == null ) { throw new LuaException( "No peripheral: " + remoteName ); @@ -264,7 +264,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @LuaFunction public final Object[] getNameLocal() { - String local = this.getLocalPeripheral().getConnectedName(); + String local = getLocalPeripheral().getConnectedName(); return local == null ? null : new Object[] { local }; } @@ -277,7 +277,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW if( other instanceof WiredModemPeripheral ) { WiredModemPeripheral otherModem = (WiredModemPeripheral) other; - return otherModem.modem == this.modem; + return otherModem.modem == modem; } return false; } @@ -286,25 +286,25 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override public IWiredNode getNode() { - return this.modem.getNode(); + return modem.getNode(); } public void attachPeripheral( String name, IPeripheral peripheral ) { - synchronized( this.peripheralWrappers ) + synchronized( peripheralWrappers ) { - for( Map.Entry> entry : this.peripheralWrappers.entrySet() ) + for( Map.Entry> entry : peripheralWrappers.entrySet() ) { - this.attachPeripheralImpl( entry.getKey(), entry.getValue(), name, peripheral ); + attachPeripheralImpl( entry.getKey(), entry.getValue(), name, peripheral ); } } } public void detachPeripheral( String name ) { - synchronized( this.peripheralWrappers ) + synchronized( peripheralWrappers ) { - for( ConcurrentMap wrappers : this.peripheralWrappers.values() ) + for( ConcurrentMap wrappers : peripheralWrappers.values() ) { RemotePeripheralWrapper wrapper = wrappers.remove( name ); if( wrapper != null ) @@ -333,40 +333,40 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW this.computer = computer; this.name = name; - this.type = Objects.requireNonNull( peripheral.getType(), "Peripheral type cannot be null" ); - this.methodMap = PeripheralAPI.getMethods( peripheral ); + type = Objects.requireNonNull( peripheral.getType(), "Peripheral type cannot be null" ); + methodMap = PeripheralAPI.getMethods( peripheral ); } public void attach() { - this.peripheral.attach( this ); - this.computer.queueEvent( "peripheral", this.getAttachmentName() ); + peripheral.attach( this ); + computer.queueEvent( "peripheral", getAttachmentName() ); } public void detach() { - this.peripheral.detach( this ); - this.computer.queueEvent( "peripheral_detach", this.getAttachmentName() ); + peripheral.detach( this ); + computer.queueEvent( "peripheral_detach", getAttachmentName() ); } public String getType() { - return this.type; + return type; } public Collection getMethodNames() { - return this.methodMap.keySet(); + return methodMap.keySet(); } public MethodResult callMethod( ILuaContext context, String methodName, IArguments arguments ) throws LuaException { - PeripheralMethod method = this.methodMap.get( methodName ); + PeripheralMethod method = methodMap.get( methodName ); if( method == null ) { throw new LuaException( "No such method " + methodName ); } - return method.apply( this.peripheral, context, this, arguments ); + return method.apply( peripheral, context, this, arguments ); } // IComputerAccess implementation @@ -374,59 +374,59 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount ) { - return this.computer.mount( desiredLocation, mount, this.name ); + return computer.mount( desiredLocation, mount, name ); } @Override public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount, @Nonnull String driveName ) { - return this.computer.mount( desiredLocation, mount, driveName ); + return computer.mount( desiredLocation, mount, driveName ); } @Nonnull @Override public String getAttachmentName() { - return this.name; + return name; } @Override public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount ) { - return this.computer.mountWritable( desiredLocation, mount, this.name ); + return computer.mountWritable( desiredLocation, mount, name ); } @Override public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount, @Nonnull String driveName ) { - return this.computer.mountWritable( desiredLocation, mount, driveName ); + return computer.mountWritable( desiredLocation, mount, driveName ); } @Override public void unmount( String location ) { - this.computer.unmount( location ); + computer.unmount( location ); } @Override public int getID() { - return this.computer.getID(); + return computer.getID(); } @Override public void queueEvent( @Nonnull String event, Object... arguments ) { - this.computer.queueEvent( event, arguments ); + computer.queueEvent( event, arguments ); } @Nonnull @Override public Map getAvailablePeripherals() { - synchronized( this.element.getRemotePeripherals() ) + synchronized( element.getRemotePeripherals() ) { - return ImmutableMap.copyOf( this.element.getRemotePeripherals() ); + return ImmutableMap.copyOf( element.getRemotePeripherals() ); } } @@ -434,9 +434,9 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override public IPeripheral getAvailablePeripheral( @Nonnull String name ) { - synchronized( this.element.getRemotePeripherals() ) + synchronized( element.getRemotePeripherals() ) { - return this.element.getRemotePeripherals() + return element.getRemotePeripherals() .get( name ); } } @@ -445,7 +445,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW @Override public IWorkMonitor getMainThreadMonitor() { - return this.computer.getMainThreadMonitor(); + return computer.getMainThreadMonitor(); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java index abdf324d5..9ffeeab88 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java @@ -39,7 +39,7 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable public BlockWirelessModem( Settings settings, BlockEntityType type ) { super( settings, type ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( FACING, Direction.NORTH ) .with( ON, false ) .with( WATERLOGGED, false ) ); @@ -84,7 +84,7 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, placement.getSide() .getOpposite() ) .with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java index 1f761a583..ac3f9e401 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/TileWirelessModem.java @@ -33,7 +33,7 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile { super( type ); this.advanced = advanced; - this.modem = new Peripheral( this ); + modem = new Peripheral( this ); } @Override @@ -47,56 +47,56 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile public void resetBlock() { super.resetBlock(); - this.hasModemDirection = false; - this.world.getBlockTickScheduler() - .schedule( this.getPos(), - this.getCachedState().getBlock(), 0 ); + hasModemDirection = false; + world.getBlockTickScheduler() + .schedule( getPos(), + getCachedState().getBlock(), 0 ); } @Override public void destroy() { - if( !this.destroyed ) + if( !destroyed ) { - this.modem.destroy(); - this.destroyed = true; + modem.destroy(); + destroyed = true; } } @Override public void blockTick() { - Direction currentDirection = this.modemDirection; - this.refreshDirection(); + Direction currentDirection = modemDirection; + refreshDirection(); // Invalidate the capability if the direction has changed. I'm not 100% happy with this implementation // - ideally we'd do it within refreshDirection or updateContainingBlockInfo, but this seems the _safest_ // place. - if( this.modem.getModemState() + if( modem.getModemState() .pollChanged() ) { - this.updateBlockState(); + updateBlockState(); } } private void refreshDirection() { - if( this.hasModemDirection ) + if( hasModemDirection ) { return; } - this.hasModemDirection = true; - this.modemDirection = this.getCachedState().get( BlockWirelessModem.FACING ); + hasModemDirection = true; + modemDirection = getCachedState().get( BlockWirelessModem.FACING ); } private void updateBlockState() { - boolean on = this.modem.getModemState() + boolean on = modem.getModemState() .isOpen(); - BlockState state = this.getCachedState(); + BlockState state = getCachedState(); if( state.get( BlockWirelessModem.ON ) != on ) { - this.getWorld().setBlockState( this.getPos(), state.with( BlockWirelessModem.ON, on ) ); + getWorld().setBlockState( getPos(), state.with( BlockWirelessModem.ON, on ) ); } } @@ -104,8 +104,8 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile @Override public IPeripheral getPeripheral( Direction side ) { - this.refreshDirection(); - return side == this.modemDirection ? this.modem : null; + refreshDirection(); + return side == modemDirection ? modem : null; } private static class Peripheral extends WirelessModemPeripheral @@ -122,15 +122,15 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile @Override public World getWorld() { - return this.entity.getWorld(); + return entity.getWorld(); } @Nonnull @Override public Vec3d getPosition() { - BlockPos pos = this.entity.getPos() - .offset( this.entity.modemDirection ); + BlockPos pos = entity.getPos() + .offset( entity.modemDirection ); return new Vec3d( pos.getX(), pos.getY(), pos.getZ() ); } @@ -138,13 +138,13 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile @Override public Object getTarget() { - return this.entity; + return entity; } @Override public boolean equals( IPeripheral other ) { - return this == other || (other instanceof Peripheral && this.entity == ((Peripheral) other).entity); + return this == other || (other instanceof Peripheral && entity == ((Peripheral) other).entity); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java index 9350c21e5..a628cadf0 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java @@ -26,16 +26,16 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral @Override public double getRange() { - if( this.advanced ) + if( advanced ) { return Integer.MAX_VALUE; } else { - World world = this.getWorld(); + World world = getWorld(); if( world != null ) { - Vec3d position = this.getPosition(); + Vec3d position = getPosition(); double minRange = ComputerCraft.modemRange; double maxRange = ComputerCraft.modemHighAltitudeRange; if( world.isRaining() && world.isThundering() ) @@ -56,7 +56,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral @Override public boolean isInterdimensional() { - return this.advanced; + return advanced; } @Override diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java index e2466966a..14f809156 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java @@ -40,14 +40,14 @@ public class WirelessNetwork implements IPacketNetwork public void addReceiver( @Nonnull IPacketReceiver receiver ) { Objects.requireNonNull( receiver, "device cannot be null" ); - this.receivers.add( receiver ); + receivers.add( receiver ); } @Override public void removeReceiver( @Nonnull IPacketReceiver receiver ) { Objects.requireNonNull( receiver, "device cannot be null" ); - this.receivers.remove( receiver ); + receivers.remove( receiver ); } @Override @@ -60,7 +60,7 @@ public class WirelessNetwork implements IPacketNetwork public void transmitSameDimension( @Nonnull Packet packet, double range ) { Objects.requireNonNull( packet, "packet cannot be null" ); - for( IPacketReceiver device : this.receivers ) + for( IPacketReceiver device : receivers ) { tryTransmit( device, packet, range, false ); } @@ -70,7 +70,7 @@ public class WirelessNetwork implements IPacketNetwork public void transmitInterdimensional( @Nonnull Packet packet ) { Objects.requireNonNull( packet, "packet cannot be null" ); - for( IPacketReceiver device : this.receivers ) + for( IPacketReceiver device : receivers ) { tryTransmit( device, packet, 0, true ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java index 897ea62e0..cd427e379 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java @@ -38,7 +38,7 @@ public class BlockMonitor extends BlockGeneric { super( settings, type ); // TODO: Test underwater - do we need isSolid at all? - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( ORIENTATION, Direction.NORTH ) .with( FACING, Direction.NORTH ) .with( STATE, MonitorEdgeState.NONE ) ); @@ -65,7 +65,7 @@ public class BlockMonitor extends BlockGeneric orientation = Direction.NORTH; } - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, context.getPlayerFacing() .getOpposite() ) .with( ORIENTATION, orientation ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/ClientMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/ClientMonitor.java index d7b682f84..eabaafb6f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/ClientMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/ClientMonitor.java @@ -60,7 +60,7 @@ public final class ClientMonitor extends ClientTerminal public TileMonitor getOrigin() { - return this.origin; + return origin; } /** @@ -75,37 +75,35 @@ public final class ClientMonitor extends ClientTerminal switch( renderer ) { case TBO: - { - if( this.tboBuffer != 0 ) + if( tboBuffer != 0 ) { return false; } - this.deleteBuffers(); + deleteBuffers(); - this.tboBuffer = GlStateManager.genBuffers(); - GlStateManager.bindBuffers( GL31.GL_TEXTURE_BUFFER, this.tboBuffer ); + tboBuffer = GlStateManager.genBuffers(); + GlStateManager.bindBuffers( GL31.GL_TEXTURE_BUFFER, tboBuffer ); GL15.glBufferData( GL31.GL_TEXTURE_BUFFER, 0, GL15.GL_STATIC_DRAW ); - this.tboTexture = GlStateManager.genTextures(); - GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, this.tboTexture ); - GL31.glTexBuffer( GL31.GL_TEXTURE_BUFFER, GL30.GL_R8UI, this.tboBuffer ); + tboTexture = GlStateManager.genTextures(); + GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, tboTexture ); + GL31.glTexBuffer( GL31.GL_TEXTURE_BUFFER, GL30.GL_R8UI, tboBuffer ); GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, 0 ); GlStateManager.bindBuffers( GL31.GL_TEXTURE_BUFFER, 0 ); - this.addMonitor(); + addMonitor(); return true; - } case VBO: - if( this.buffer != null ) + if( buffer != null ) { return false; } - this.deleteBuffers(); - this.buffer = new VertexBuffer( FixedWidthFontRenderer.TYPE.getVertexFormat() ); - this.addMonitor(); + deleteBuffers(); + buffer = new VertexBuffer( FixedWidthFontRenderer.TYPE.getVertexFormat() ); + addMonitor(); return true; default: @@ -116,22 +114,22 @@ public final class ClientMonitor extends ClientTerminal private void deleteBuffers() { - if( this.tboBuffer != 0 ) + if( tboBuffer != 0 ) { - RenderSystem.glDeleteBuffers( this.tboBuffer ); - this.tboBuffer = 0; + RenderSystem.glDeleteBuffers( tboBuffer ); + tboBuffer = 0; } - if( this.tboTexture != 0 ) + if( tboTexture != 0 ) { - GlStateManager.deleteTexture( this.tboTexture ); - this.tboTexture = 0; + GlStateManager.deleteTexture( tboTexture ); + tboTexture = 0; } - if( this.buffer != null ) + if( buffer != null ) { - this.buffer.close(); - this.buffer = null; + buffer.close(); + buffer = null; } } @@ -146,14 +144,14 @@ public final class ClientMonitor extends ClientTerminal @Environment( EnvType.CLIENT ) public void destroy() { - if( this.tboBuffer != 0 || this.buffer != null ) + if( tboBuffer != 0 || buffer != null ) { synchronized( allMonitors ) { allMonitors.remove( this ); } - this.deleteBuffers(); + deleteBuffers(); } } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java index 6e2e83bbd..1c4a0a87e 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java @@ -62,7 +62,7 @@ public enum MonitorEdgeState implements StringIdentifiable @Override public String asString() { - return this.name; + return name; } static final class Flags diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorPeripheral.java index ee0191b03..2ca3c7da9 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorPeripheral.java @@ -53,26 +53,26 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral @Override public void attach( @Nonnull IComputerAccess computer ) { - this.monitor.addComputer( computer ); + monitor.addComputer( computer ); } @Override public void detach( @Nonnull IComputerAccess computer ) { - this.monitor.removeComputer( computer ); + monitor.removeComputer( computer ); } @Nullable @Override public Object getTarget() { - return this.monitor; + return monitor; } @Override public boolean equals( IPeripheral other ) { - return other instanceof MonitorPeripheral && this.monitor == ((MonitorPeripheral) other).monitor; + return other instanceof MonitorPeripheral && monitor == ((MonitorPeripheral) other).monitor; } /** @@ -84,7 +84,7 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral @LuaFunction public final double getTextScale() throws LuaException { - return this.getMonitor().getTextScale() / 2.0; + return getMonitor().getTextScale() / 2.0; } /** @@ -102,7 +102,7 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral { throw new LuaException( "Expected number in range 0.5-5" ); } - this.getMonitor().setTextScale( scale ); + getMonitor().setTextScale( scale ); } @Nonnull @@ -120,7 +120,7 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral @Override public Terminal getTerminal() throws LuaException { - Terminal terminal = this.getMonitor().getTerminal(); + Terminal terminal = getMonitor().getTerminal(); if( terminal == null ) { throw new LuaException( "Monitor has been detached" ); @@ -131,6 +131,6 @@ public class MonitorPeripheral extends TermMethods implements IPeripheral @Override public boolean isColour() throws LuaException { - return this.getMonitor().isColour(); + return getMonitor().isColour(); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorRenderer.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorRenderer.java index 90980336e..14aec1173 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorRenderer.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorRenderer.java @@ -75,11 +75,11 @@ public enum MonitorRenderer private static MonitorRenderer best() { - if ( !initialised ) + if( !initialised ) { checkCapabilities(); checkForShaderMods(); - if ( textureBuffer && shaderMod ) + if( textureBuffer && shaderMod ) { ComputerCraft.log.warn( "Shader mod detected. Enabling VBO renderer for compatibility." ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java index fb338fc27..f5225574c 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java @@ -29,25 +29,25 @@ public class ServerMonitor extends ServerTerminal protected void markTerminalChanged() { super.markTerminalChanged(); - this.markChanged(); + markChanged(); } private void markChanged() { - if( !this.changed.getAndSet( true ) ) + if( !changed.getAndSet( true ) ) { - TickScheduler.schedule( this.origin ); + TickScheduler.schedule( origin ); } } protected void clearChanged() { - this.changed.set( false ); + changed.set( false ); } public int getTextScale() { - return this.textScale; + return textScale; } public synchronized void setTextScale( int textScale ) @@ -57,40 +57,40 @@ public class ServerMonitor extends ServerTerminal return; } this.textScale = textScale; - this.rebuild(); + rebuild(); } public synchronized void rebuild() { - Terminal oldTerm = this.getTerminal(); + Terminal oldTerm = getTerminal(); int oldWidth = oldTerm == null ? -1 : oldTerm.getWidth(); int oldHeight = oldTerm == null ? -1 : oldTerm.getHeight(); double textScale = this.textScale * 0.5; int termWidth = - (int) Math.max( Math.round( (this.origin.getWidth() - 2.0 * (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN)) / (textScale * 6.0 * TileMonitor.RENDER_PIXEL_SCALE) ), + (int) Math.max( Math.round( (origin.getWidth() - 2.0 * (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN)) / (textScale * 6.0 * TileMonitor.RENDER_PIXEL_SCALE) ), 1.0 ); int termHeight = - (int) Math.max( Math.round( (this.origin.getHeight() - 2.0 * (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN)) / (textScale * 9.0 * TileMonitor.RENDER_PIXEL_SCALE) ), + (int) Math.max( Math.round( (origin.getHeight() - 2.0 * (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN)) / (textScale * 9.0 * TileMonitor.RENDER_PIXEL_SCALE) ), 1.0 ); - this.resize( termWidth, termHeight ); + resize( termWidth, termHeight ); if( oldWidth != termWidth || oldHeight != termHeight ) { - this.getTerminal().clear(); - this.resized.set( true ); - this.markChanged(); + getTerminal().clear(); + resized.set( true ); + markChanged(); } } public boolean pollResized() { - return this.resized.getAndSet( false ); + return resized.getAndSet( false ); } public boolean pollTerminalChanged() { - this.update(); - return this.hasTerminalChanged(); + update(); + return hasTerminalChanged(); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index e398b3356..546941d57 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -68,14 +68,14 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile public void destroy() { // TODO: Call this before using the block - if( this.destroyed ) + if( destroyed ) { return; } - this.destroyed = true; - if( !this.getWorld().isClient ) + destroyed = true; + if( !getWorld().isClient ) { - this.contractNeighbours(); + contractNeighbours(); } } @@ -83,9 +83,9 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile public void markRemoved() { super.markRemoved(); - if( this.clientMonitor != null && this.xIndex == 0 && this.yIndex == 0 ) + if( clientMonitor != null && xIndex == 0 && yIndex == 0 ) { - this.clientMonitor.destroy(); + clientMonitor.destroy(); } } @@ -93,22 +93,22 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile public void onChunkUnloaded() { super.onChunkUnloaded(); - if( this.clientMonitor != null && this.xIndex == 0 && this.yIndex == 0 ) + if( clientMonitor != null && xIndex == 0 && yIndex == 0 ) { - this.clientMonitor.destroy(); + clientMonitor.destroy(); } - this.clientMonitor = null; + clientMonitor = null; } @Nonnull @Override public ActionResult onActivate( PlayerEntity player, Hand hand, BlockHitResult hit ) { - if( !player.isInSneakingPose() && this.getFront() == hit.getSide() ) + if( !player.isInSneakingPose() && getFront() == hit.getSide() ) { - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - this.monitorTouched( (float) (hit.getPos().x - hit.getBlockPos() + monitorTouched( (float) (hit.getPos().x - hit.getBlockPos() .getX()), (float) (hit.getPos().y - hit.getBlockPos() .getY()), @@ -130,20 +130,20 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile updateNeighbors(); } - if( this.xIndex != 0 || this.yIndex != 0 || this.serverMonitor == null ) + if( xIndex != 0 || yIndex != 0 || serverMonitor == null ) { return; } - this.serverMonitor.clearChanged(); + serverMonitor.clearChanged(); - if( this.serverMonitor.pollResized() ) + if( serverMonitor.pollResized() ) { - for( int x = 0; x < this.width; x++ ) + for( int x = 0; x < width; x++ ) { - for( int y = 0; y < this.height; y++ ) + for( int y = 0; y < height; y++ ) { - TileMonitor monitor = this.getNeighbour( x, y ); + TileMonitor monitor = getNeighbour( x, y ); if( monitor == null ) { continue; @@ -157,9 +157,9 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile } } - if( this.serverMonitor.pollTerminalChanged() ) + if( serverMonitor.pollTerminalChanged() ) { - this.updateBlock(); + updateBlock(); } } @@ -168,41 +168,41 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile { super.readDescription( nbt ); - int oldXIndex = this.xIndex; - int oldYIndex = this.yIndex; - int oldWidth = this.width; - int oldHeight = this.height; + int oldXIndex = xIndex; + int oldYIndex = yIndex; + int oldWidth = width; + int oldHeight = height; - this.xIndex = nbt.getInt( NBT_X ); - this.yIndex = nbt.getInt( NBT_Y ); - this.width = nbt.getInt( NBT_WIDTH ); - this.height = nbt.getInt( NBT_HEIGHT ); + xIndex = nbt.getInt( NBT_X ); + yIndex = nbt.getInt( NBT_Y ); + width = nbt.getInt( NBT_WIDTH ); + height = nbt.getInt( NBT_HEIGHT ); - if( oldXIndex != this.xIndex || oldYIndex != this.yIndex ) + if( oldXIndex != xIndex || oldYIndex != yIndex ) { // If our index has changed then it's possible the origin monitor has changed. Thus // we'll clear our cache. If we're the origin then we'll need to remove the glList as well. - if( oldXIndex == 0 && oldYIndex == 0 && this.clientMonitor != null ) + if( oldXIndex == 0 && oldYIndex == 0 && clientMonitor != null ) { - this.clientMonitor.destroy(); + clientMonitor.destroy(); } - this.clientMonitor = null; + clientMonitor = null; } - if( this.xIndex == 0 && this.yIndex == 0 ) + if( xIndex == 0 && yIndex == 0 ) { // If we're the origin terminal then create it. - if( this.clientMonitor == null ) + if( clientMonitor == null ) { - this.clientMonitor = new ClientMonitor( this.advanced, this ); + clientMonitor = new ClientMonitor( advanced, this ); } - this.clientMonitor.readDescription( nbt ); + clientMonitor.readDescription( nbt ); } - if( oldXIndex != this.xIndex || oldYIndex != this.yIndex || oldWidth != this.width || oldHeight != this.height ) + if( oldXIndex != xIndex || oldYIndex != yIndex || oldWidth != width || oldHeight != height ) { // One of our properties has changed, so ensure we redraw the block - this.updateBlock(); + updateBlock(); } } @@ -210,52 +210,52 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile protected void writeDescription( @Nonnull CompoundTag nbt ) { super.writeDescription( nbt ); - nbt.putInt( NBT_X, this.xIndex ); - nbt.putInt( NBT_Y, this.yIndex ); - nbt.putInt( NBT_WIDTH, this.width ); - nbt.putInt( NBT_HEIGHT, this.height ); + nbt.putInt( NBT_X, xIndex ); + nbt.putInt( NBT_Y, yIndex ); + nbt.putInt( NBT_WIDTH, width ); + nbt.putInt( NBT_HEIGHT, height ); - if( this.xIndex == 0 && this.yIndex == 0 && this.serverMonitor != null ) + if( xIndex == 0 && yIndex == 0 && serverMonitor != null ) { - this.serverMonitor.writeDescription( nbt ); + serverMonitor.writeDescription( nbt ); } } private TileMonitor getNeighbour( int x, int y ) { - BlockPos pos = this.getPos(); - Direction right = this.getRight(); - Direction down = this.getDown(); - int xOffset = -this.xIndex + x; - int yOffset = -this.yIndex + y; - return this.getSimilarMonitorAt( pos.offset( right, xOffset ) + BlockPos pos = getPos(); + Direction right = getRight(); + Direction down = getDown(); + int xOffset = -xIndex + x; + int yOffset = -yIndex + y; + return getSimilarMonitorAt( pos.offset( right, xOffset ) .offset( down, yOffset ) ); } public Direction getRight() { - return this.getDirection().rotateYCounterclockwise(); + return getDirection().rotateYCounterclockwise(); } public Direction getDown() { - Direction orientation = this.getOrientation(); + Direction orientation = getOrientation(); if( orientation == Direction.NORTH ) { return Direction.UP; } - return orientation == Direction.DOWN ? this.getDirection() : this.getDirection().getOpposite(); + return orientation == Direction.DOWN ? getDirection() : getDirection().getOpposite(); } private TileMonitor getSimilarMonitorAt( BlockPos pos ) { - if( pos.equals( this.getPos() ) ) + if( pos.equals( getPos() ) ) { return this; } int y = pos.getY(); - World world = this.getWorld(); + World world = getWorld(); if( world == null || !world.isChunkLoaded( pos ) ) { return null; @@ -268,7 +268,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile } TileMonitor monitor = (TileMonitor) tile; - return !monitor.visiting && !monitor.destroyed && this.advanced == monitor.advanced && this.getDirection() == monitor.getDirection() && this.getOrientation() == monitor.getOrientation() ? monitor : null; + return !monitor.visiting && !monitor.destroyed && advanced == monitor.advanced && getDirection() == monitor.getDirection() && getOrientation() == monitor.getOrientation() ? monitor : null; } // region Sizing and placement stuff @@ -282,7 +282,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile public Direction getOrientation() { - return this.getCachedState().get( BlockMonitor.ORIENTATION ); + return getCachedState().get( BlockMonitor.ORIENTATION ); } @Override @@ -290,10 +290,10 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile { super.fromTag( state, nbt ); - this.xIndex = nbt.getInt( NBT_X ); - this.yIndex = nbt.getInt( NBT_Y ); - this.width = nbt.getInt( NBT_WIDTH ); - this.height = nbt.getInt( NBT_HEIGHT ); + xIndex = nbt.getInt( NBT_X ); + yIndex = nbt.getInt( NBT_Y ); + width = nbt.getInt( NBT_WIDTH ); + height = nbt.getInt( NBT_HEIGHT ); } // Networking stuff @@ -302,10 +302,10 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile @Override public CompoundTag toTag( CompoundTag tag ) { - tag.putInt( NBT_X, this.xIndex ); - tag.putInt( NBT_Y, this.yIndex ); - tag.putInt( NBT_WIDTH, this.width ); - tag.putInt( NBT_HEIGHT, this.height ); + tag.putInt( NBT_X, xIndex ); + tag.putInt( NBT_Y, yIndex ); + tag.putInt( NBT_WIDTH, width ); + tag.putInt( NBT_HEIGHT, height ); return super.toTag( tag ); } @@ -328,162 +328,162 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile @Override public IPeripheral getPeripheral( Direction side ) { - this.createServerMonitor(); // Ensure the monitor is created before doing anything else. - if( this.peripheral == null ) + createServerMonitor(); // Ensure the monitor is created before doing anything else. + if( peripheral == null ) { - this.peripheral = new MonitorPeripheral( this ); + peripheral = new MonitorPeripheral( this ); } - return this.peripheral; + return peripheral; } public ServerMonitor getCachedServerMonitor() { - return this.serverMonitor; + return serverMonitor; } private ServerMonitor getServerMonitor() { - if( this.serverMonitor != null ) + if( serverMonitor != null ) { - return this.serverMonitor; + return serverMonitor; } - TileMonitor origin = this.getOrigin(); + TileMonitor origin = getOrigin(); if( origin == null ) { return null; } - return this.serverMonitor = origin.serverMonitor; + return serverMonitor = origin.serverMonitor; } private ServerMonitor createServerMonitor() { - if( this.serverMonitor != null ) + if( serverMonitor != null ) { - return this.serverMonitor; + return serverMonitor; } - if( this.xIndex == 0 && this.yIndex == 0 ) + if( xIndex == 0 && yIndex == 0 ) { // If we're the origin, set up the new monitor - this.serverMonitor = new ServerMonitor( this.advanced, this ); - this.serverMonitor.rebuild(); + serverMonitor = new ServerMonitor( advanced, this ); + serverMonitor.rebuild(); // And propagate it to child monitors - for( int x = 0; x < this.width; x++ ) + for( int x = 0; x < width; x++ ) { - for( int y = 0; y < this.height; y++ ) + for( int y = 0; y < height; y++ ) { - TileMonitor monitor = this.getNeighbour( x, y ); + TileMonitor monitor = getNeighbour( x, y ); if( monitor != null ) { - monitor.serverMonitor = this.serverMonitor; + monitor.serverMonitor = serverMonitor; } } } - return this.serverMonitor; + return serverMonitor; } else { // Otherwise fetch the origin and attempt to get its monitor // Note this may load chunks, but we don't really have a choice here. - BlockPos pos = this.getPos(); - BlockEntity te = this.world.getBlockEntity( pos.offset( this.getRight(), -this.xIndex ) - .offset( this.getDown(), -this.yIndex ) ); + BlockPos pos = getPos(); + BlockEntity te = world.getBlockEntity( pos.offset( getRight(), -xIndex ) + .offset( getDown(), -yIndex ) ); if( !(te instanceof TileMonitor) ) { return null; } - return this.serverMonitor = ((TileMonitor) te).createServerMonitor(); + return serverMonitor = ((TileMonitor) te).createServerMonitor(); } } public ClientMonitor getClientMonitor() { - if( this.clientMonitor != null ) + if( clientMonitor != null ) { - return this.clientMonitor; + return clientMonitor; } - BlockPos pos = this.getPos(); - BlockEntity te = this.world.getBlockEntity( pos.offset( this.getRight(), -this.xIndex ) - .offset( this.getDown(), -this.yIndex ) ); + BlockPos pos = getPos(); + BlockEntity te = world.getBlockEntity( pos.offset( getRight(), -xIndex ) + .offset( getDown(), -yIndex ) ); if( !(te instanceof TileMonitor) ) { return null; } - return this.clientMonitor = ((TileMonitor) te).clientMonitor; + return clientMonitor = ((TileMonitor) te).clientMonitor; } public final void read( TerminalState state ) { - if( this.xIndex != 0 || this.yIndex != 0 ) + if( xIndex != 0 || yIndex != 0 ) { - ComputerCraft.log.warn( "Receiving monitor state for non-origin terminal at {}", this.getPos() ); + ComputerCraft.log.warn( "Receiving monitor state for non-origin terminal at {}", getPos() ); return; } - if( this.clientMonitor == null ) + if( clientMonitor == null ) { - this.clientMonitor = new ClientMonitor( this.advanced, this ); + clientMonitor = new ClientMonitor( advanced, this ); } - this.clientMonitor.read( state ); + clientMonitor.read( state ); } private void updateBlockState() { - this.getWorld().setBlockState( this.getPos(), - this.getCachedState().with( BlockMonitor.STATE, - MonitorEdgeState.fromConnections( this.yIndex < this.height - 1, - this.yIndex > 0, this.xIndex > 0, this.xIndex < this.width - 1 ) ), + getWorld().setBlockState( getPos(), + getCachedState().with( BlockMonitor.STATE, + MonitorEdgeState.fromConnections( yIndex < height - 1, + yIndex > 0, xIndex > 0, xIndex < width - 1 ) ), 2 ); } public Direction getFront() { - Direction orientation = this.getOrientation(); - return orientation == Direction.NORTH ? this.getDirection() : orientation; + Direction orientation = getOrientation(); + return orientation == Direction.NORTH ? getDirection() : orientation; } public int getWidth() { - return this.width; + return width; } public int getHeight() { - return this.height; + return height; } public int getXIndex() { - return this.xIndex; + return xIndex; } public int getYIndex() { - return this.yIndex; + return yIndex; } private TileMonitor getOrigin() { - return this.getNeighbour( 0, 0 ); + return getNeighbour( 0, 0 ); } private void resize( int width, int height ) { // If we're not already the origin then we'll need to generate a new terminal. - if( this.xIndex != 0 || this.yIndex != 0 ) + if( xIndex != 0 || yIndex != 0 ) { - this.serverMonitor = null; + serverMonitor = null; } - this.xIndex = 0; - this.yIndex = 0; + xIndex = 0; + yIndex = 0; this.width = width; this.height = height; @@ -496,7 +496,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile { for( int y = 0; y < height; y++ ) { - TileMonitor monitor = this.getNeighbour( x, y ); + TileMonitor monitor = getNeighbour( x, y ); if( monitor != null && monitor.peripheral != null ) { needsTerminal = true; @@ -508,21 +508,21 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile // Either delete the current monitor or sync a new one. if( needsTerminal ) { - if( this.serverMonitor == null ) + if( serverMonitor == null ) { - this.serverMonitor = new ServerMonitor( this.advanced, this ); + serverMonitor = new ServerMonitor( advanced, this ); } } else { - this.serverMonitor = null; + serverMonitor = null; } // Update the terminal's width and height and rebuild it. This ensures the monitor // is consistent when syncing it to other monitors. - if( this.serverMonitor != null ) + if( serverMonitor != null ) { - this.serverMonitor.rebuild(); + serverMonitor.rebuild(); } // Update the other monitors, setting coordinates, dimensions and the server terminal @@ -530,7 +530,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile { for( int y = 0; y < height; y++ ) { - TileMonitor monitor = this.getNeighbour( x, y ); + TileMonitor monitor = getNeighbour( x, y ); if( monitor == null ) { continue; @@ -540,7 +540,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile monitor.yIndex = y; monitor.width = width; monitor.height = height; - monitor.serverMonitor = this.serverMonitor; + monitor.serverMonitor = serverMonitor; monitor.updateBlockState(); monitor.updateBlock(); } @@ -549,8 +549,8 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile private boolean mergeLeft() { - TileMonitor left = this.getNeighbour( -1, 0 ); - if( left == null || left.yIndex != 0 || left.height != this.height ) + TileMonitor left = getNeighbour( -1, 0 ); + if( left == null || left.yIndex != 0 || left.height != height ) { return false; } @@ -564,7 +564,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile TileMonitor origin = left.getOrigin(); if( origin != null ) { - origin.resize( width, this.height ); + origin.resize( width, height ); } left.expand(); return true; @@ -572,8 +572,8 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile private boolean mergeRight() { - TileMonitor right = this.getNeighbour( this.width, 0 ); - if( right == null || right.yIndex != 0 || right.height != this.height ) + TileMonitor right = getNeighbour( width, 0 ); + if( right == null || right.yIndex != 0 || right.height != height ) { return false; } @@ -584,19 +584,19 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile return false; } - TileMonitor origin = this.getOrigin(); + TileMonitor origin = getOrigin(); if( origin != null ) { - origin.resize( width, this.height ); + origin.resize( width, height ); } - this.expand(); + expand(); return true; } private boolean mergeUp() { - TileMonitor above = this.getNeighbour( 0, this.height ); - if( above == null || above.xIndex != 0 || above.width != this.width ) + TileMonitor above = getNeighbour( 0, height ); + if( above == null || above.xIndex != 0 || above.width != width ) { return false; } @@ -607,19 +607,19 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile return false; } - TileMonitor origin = this.getOrigin(); + TileMonitor origin = getOrigin(); if( origin != null ) { - origin.resize( this.width, height ); + origin.resize( width, height ); } - this.expand(); + expand(); return true; } private boolean mergeDown() { - TileMonitor below = this.getNeighbour( 0, -1 ); - if( below == null || below.xIndex != 0 || below.width != this.width ) + TileMonitor below = getNeighbour( 0, -1 ); + if( below == null || below.xIndex != 0 || below.width != width ) { return false; } @@ -633,7 +633,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile TileMonitor origin = below.getOrigin(); if( origin != null ) { - origin.resize( this.width, height ); + origin.resize( width, height ); } below.expand(); return true; @@ -654,45 +654,45 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile @SuppressWarnings( "StatementWithEmptyBody" ) void expand() { - while( this.mergeLeft() || this.mergeRight() || this.mergeUp() || this.mergeDown() ) ; + while( mergeLeft() || mergeRight() || mergeUp() || mergeDown() ) ; } void contractNeighbours() { - this.visiting = true; - if( this.xIndex > 0 ) + visiting = true; + if( xIndex > 0 ) { - TileMonitor left = this.getNeighbour( this.xIndex - 1, this.yIndex ); + TileMonitor left = getNeighbour( xIndex - 1, yIndex ); if( left != null ) { left.contract(); } } - if( this.xIndex + 1 < this.width ) + if( xIndex + 1 < width ) { - TileMonitor right = this.getNeighbour( this.xIndex + 1, this.yIndex ); + TileMonitor right = getNeighbour( xIndex + 1, yIndex ); if( right != null ) { right.contract(); } } - if( this.yIndex > 0 ) + if( yIndex > 0 ) { - TileMonitor below = this.getNeighbour( this.xIndex, this.yIndex - 1 ); + TileMonitor below = getNeighbour( xIndex, yIndex - 1 ); if( below != null ) { below.contract(); } } - if( this.yIndex + 1 < this.height ) + if( yIndex + 1 < height ) { - TileMonitor above = this.getNeighbour( this.xIndex, this.yIndex + 1 ); + TileMonitor above = getNeighbour( xIndex, yIndex + 1 ); if( above != null ) { above.contract(); } } - this.visiting = false; + visiting = false; } void contract() @@ -700,11 +700,11 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile int height = this.height; int width = this.width; - TileMonitor origin = this.getOrigin(); + TileMonitor origin = getOrigin(); if( origin == null ) { - TileMonitor right = width > 1 ? this.getNeighbour( 1, 0 ) : null; - TileMonitor below = height > 1 ? this.getNeighbour( 0, 1 ) : null; + TileMonitor right = width > 1 ? getNeighbour( 1, 0 ) : null; + TileMonitor below = height > 1 ? getNeighbour( 0, 1 ) : null; if( right != null ) { @@ -788,15 +788,15 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile private void monitorTouched( float xPos, float yPos, float zPos ) { - XYPair pair = XYPair.of( xPos, yPos, zPos, this.getDirection(), this.getOrientation() ) - .add( this.xIndex, this.height - this.yIndex - 1 ); + XYPair pair = XYPair.of( xPos, yPos, zPos, getDirection(), getOrientation() ) + .add( xIndex, height - yIndex - 1 ); - if( pair.x > this.width - RENDER_BORDER || pair.y > this.height - RENDER_BORDER || pair.x < RENDER_BORDER || pair.y < RENDER_BORDER ) + if( pair.x > width - RENDER_BORDER || pair.y > height - RENDER_BORDER || pair.x < RENDER_BORDER || pair.y < RENDER_BORDER ) { return; } - ServerTerminal serverTerminal = this.getServerMonitor(); + ServerTerminal serverTerminal = getServerMonitor(); if( serverTerminal == null || !serverTerminal.isColour() ) { return; @@ -808,17 +808,17 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile return; } - double xCharWidth = (this.width - (RENDER_BORDER + RENDER_MARGIN) * 2.0) / originTerminal.getWidth(); - double yCharHeight = (this.height - (RENDER_BORDER + RENDER_MARGIN) * 2.0) / originTerminal.getHeight(); + double xCharWidth = (width - (RENDER_BORDER + RENDER_MARGIN) * 2.0) / originTerminal.getWidth(); + double yCharHeight = (height - (RENDER_BORDER + RENDER_MARGIN) * 2.0) / originTerminal.getHeight(); int xCharPos = (int) Math.min( originTerminal.getWidth(), Math.max( (pair.x - RENDER_BORDER - RENDER_MARGIN) / xCharWidth + 1.0, 1.0 ) ); int yCharPos = (int) Math.min( originTerminal.getHeight(), Math.max( (pair.y - RENDER_BORDER - RENDER_MARGIN) / yCharHeight + 1.0, 1.0 ) ); - for( int y = 0; y < this.height; y++ ) + for( int y = 0; y < height; y++ ) { - for( int x = 0; x < this.width; x++ ) + for( int x = 0; x < width; x++ ) { - TileMonitor monitor = this.getNeighbour( x, y ); + TileMonitor monitor = getNeighbour( x, y ); if( monitor == null ) { continue; @@ -834,7 +834,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile void addComputer( IComputerAccess computer ) { - this.computers.add( computer ); + computers.add( computer ); } // @Nonnull @@ -864,6 +864,6 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile void removeComputer( IComputerAccess computer ) { - this.computers.remove( computer ); + computers.remove( computer ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/BlockPrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/BlockPrinter.java index e8d4bfc56..e2c6ff778 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/BlockPrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/BlockPrinter.java @@ -37,7 +37,7 @@ public class BlockPrinter extends BlockGeneric public BlockPrinter( Settings settings ) { super( settings, ComputerCraftRegistry.ModTiles.PRINTER ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( FACING, Direction.NORTH ) .with( TOP, false ) .with( BOTTOM, false ) ); @@ -47,7 +47,7 @@ public class BlockPrinter extends BlockGeneric @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, placement.getPlayerFacing() .getOpposite() ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/ContainerPrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/ContainerPrinter.java index f2f322e7e..4b94cb54d 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/ContainerPrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/ContainerPrinter.java @@ -36,21 +36,21 @@ public class ContainerPrinter extends ScreenHandler this.properties = properties; this.inventory = inventory; - this.addProperties( properties ); + addProperties( properties ); // Ink slot - this.addSlot( new Slot( inventory, 0, 13, 35 ) ); + addSlot( new Slot( inventory, 0, 13, 35 ) ); // In-tray for( int x = 0; x < 6; x++ ) { - this.addSlot( new Slot( inventory, x + 1, 61 + x * 18, 22 ) ); + addSlot( new Slot( inventory, x + 1, 61 + x * 18, 22 ) ); } // Out-tray for( int x = 0; x < 6; x++ ) { - this.addSlot( new Slot( inventory, x + 7, 61 + x * 18, 49 ) ); + addSlot( new Slot( inventory, x + 7, 61 + x * 18, 49 ) ); } // Player inv @@ -58,32 +58,32 @@ public class ContainerPrinter extends ScreenHandler { for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18 ) ); + addSlot( new Slot( player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18 ) ); } } // Player hotbar for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( player, x, 8 + x * 18, 142 ) ); + addSlot( new Slot( player, x, 8 + x * 18, 142 ) ); } } public ContainerPrinter( int id, PlayerInventory player, TilePrinter printer ) { - this( id, player, printer, (SingleIntArray) (() -> printer.isPrinting() ? 1 : 0) ); + this( id, player, printer, (SingleIntArray) () -> printer.isPrinting() ? 1 : 0 ); } public boolean isPrinting() { - return this.properties.get( 0 ) != 0; + return properties.get( 0 ) != 0; } @Nonnull @Override public ItemStack transferSlot( @Nonnull PlayerEntity player, int index ) { - Slot slot = this.slots.get( index ); + Slot slot = slots.get( index ); if( slot == null || !slot.hasStack() ) { return ItemStack.EMPTY; @@ -93,7 +93,7 @@ public class ContainerPrinter extends ScreenHandler if( index < 13 ) { // Transfer from printer to inventory - if( !this.insertItem( stack, 13, 49, true ) ) + if( !insertItem( stack, 13, 49, true ) ) { return ItemStack.EMPTY; } @@ -103,14 +103,14 @@ public class ContainerPrinter extends ScreenHandler // Transfer from inventory to printer if( TilePrinter.isInk( stack ) ) { - if( !this.insertItem( stack, 0, 1, false ) ) + if( !insertItem( stack, 0, 1, false ) ) { return ItemStack.EMPTY; } } else //if is paper { - if( !this.insertItem( stack, 1, 13, false ) ) + if( !insertItem( stack, 1, 13, false ) ) { return ItemStack.EMPTY; } @@ -138,6 +138,6 @@ public class ContainerPrinter extends ScreenHandler @Override public boolean canUse( @Nonnull PlayerEntity player ) { - return this.inventory.canPlayerUse( player ); + return inventory.canPlayerUse( player ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java index a1dfdb3bd..3627af739 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterPeripheral.java @@ -47,13 +47,13 @@ public class PrinterPeripheral implements IPeripheral @Override public Object getTarget() { - return this.printer; + return printer; } @Override public boolean equals( IPeripheral other ) { - return other instanceof PrinterPeripheral && ((PrinterPeripheral) other).printer == this.printer; + return other instanceof PrinterPeripheral && ((PrinterPeripheral) other).printer == printer; } /** @@ -67,7 +67,7 @@ public class PrinterPeripheral implements IPeripheral public final void write( IArguments arguments ) throws LuaException { String text = StringUtil.toString( arguments.get( 0 ) ); - Terminal page = this.getCurrentPage(); + Terminal page = getCurrentPage(); page.write( text ); page.setCursorPos( page.getCursorX() + text.length(), page.getCursorY() ); } @@ -75,7 +75,7 @@ public class PrinterPeripheral implements IPeripheral @Nonnull private Terminal getCurrentPage() throws LuaException { - Terminal currentPage = this.printer.getCurrentPage(); + Terminal currentPage = printer.getCurrentPage(); if( currentPage == null ) { throw new LuaException( "Page not started" ); @@ -94,7 +94,7 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final Object[] getCursorPos() throws LuaException { - Terminal page = this.getCurrentPage(); + Terminal page = getCurrentPage(); int x = page.getCursorX(); int y = page.getCursorY(); return new Object[] { x + 1, y + 1 }; @@ -110,7 +110,7 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final void setCursorPos( int x, int y ) throws LuaException { - Terminal page = this.getCurrentPage(); + Terminal page = getCurrentPage(); page.setCursorPos( x - 1, y - 1 ); } @@ -125,7 +125,7 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final Object[] getPageSize() throws LuaException { - Terminal page = this.getCurrentPage(); + Terminal page = getCurrentPage(); int width = page.getWidth(); int height = page.getHeight(); return new Object[] { width, height }; @@ -139,7 +139,7 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction( mainThread = true ) public final boolean newPage() { - return this.printer.startNewPage(); + return printer.startNewPage(); } /** @@ -151,8 +151,8 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction( mainThread = true ) public final boolean endPage() throws LuaException { - this.getCurrentPage(); - return this.printer.endCurrentPage(); + getCurrentPage(); + return printer.endCurrentPage(); } /** @@ -164,8 +164,8 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final void setPageTitle( Optional title ) throws LuaException { - this.getCurrentPage(); - this.printer.setPageTitle( StringUtil.normaliseLabel( title.orElse( "" ) ) ); + getCurrentPage(); + printer.setPageTitle( StringUtil.normaliseLabel( title.orElse( "" ) ) ); } /** @@ -176,7 +176,7 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final int getInkLevel() { - return this.printer.getInkLevel(); + return printer.getInkLevel(); } /** @@ -187,6 +187,6 @@ public class PrinterPeripheral implements IPeripheral @LuaFunction public final int getPaperLevel() { - return this.printer.getPaperLevel(); + return printer.getPaperLevel(); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java index 78fd08741..aeef621e5 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/printer/TilePrinter.java @@ -78,7 +78,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public void destroy() { - this.ejectContents(); + ejectContents(); } @Nonnull @@ -90,7 +90,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent return ActionResult.PASS; } - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { player.openHandledScreen( this ); } @@ -101,15 +101,15 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent { for( int i = 0; i < 13; i++ ) { - ItemStack stack = this.inventory.get( i ); + ItemStack stack = inventory.get( i ); if( !stack.isEmpty() ) { // Remove the stack from the inventory - this.setStack( i, ItemStack.EMPTY ); + setStack( i, ItemStack.EMPTY ); // Spawn the item in the world - WorldUtil.dropItemStack( stack, this.getWorld(), - Vec3d.of( this.getPos() ) + WorldUtil.dropItemStack( stack, getWorld(), + Vec3d.of( getPos() ) .add( 0.5, 0.75, 0.5 ) ); } } @@ -120,7 +120,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent boolean top = false, bottom = false; for( int i = 1; i < 7; i++ ) { - ItemStack stack = this.inventory.get( i ); + ItemStack stack = inventory.get( i ); if( !stack.isEmpty() && isPaper( stack ) ) { top = true; @@ -129,7 +129,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent } for( int i = 7; i < 13; i++ ) { - ItemStack stack = this.inventory.get( i ); + ItemStack stack = inventory.get( i ); if( !stack.isEmpty() && isPaper( stack ) ) { bottom = true; @@ -137,7 +137,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent } } - this.updateBlockState( top, bottom ); + updateBlockState( top, bottom ); } private static boolean isPaper( @Nonnull ItemStack stack ) @@ -148,18 +148,18 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent private void updateBlockState( boolean top, boolean bottom ) { - if( this.removed ) + if( removed ) { return; } - BlockState state = this.getCachedState(); + BlockState state = getCachedState(); if( state.get( BlockPrinter.TOP ) == top & state.get( BlockPrinter.BOTTOM ) == bottom ) { return; } - this.getWorld().setBlockState( this.getPos(), + getWorld().setBlockState( getPos(), state.with( BlockPrinter.TOP, top ) .with( BlockPrinter.BOTTOM, bottom ) ); } @@ -169,59 +169,59 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent { super.fromTag( state, nbt ); - this.customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; + customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; // Read page - synchronized( this.page ) + synchronized( page ) { - this.printing = nbt.getBoolean( NBT_PRINTING ); - this.pageTitle = nbt.getString( NBT_PAGE_TITLE ); - this.page.readFromNBT( nbt ); + printing = nbt.getBoolean( NBT_PRINTING ); + pageTitle = nbt.getString( NBT_PAGE_TITLE ); + page.readFromNBT( nbt ); } // Read inventory - Inventories.fromTag( nbt, this.inventory ); + Inventories.fromTag( nbt, inventory ); } @Nonnull @Override public CompoundTag toTag( @Nonnull CompoundTag nbt ) { - if( this.customName != null ) + if( customName != null ) { - nbt.putString( NBT_NAME, Text.Serializer.toJson( this.customName ) ); + nbt.putString( NBT_NAME, Text.Serializer.toJson( customName ) ); } // Write page - synchronized( this.page ) + synchronized( page ) { - nbt.putBoolean( NBT_PRINTING, this.printing ); - nbt.putString( NBT_PAGE_TITLE, this.pageTitle ); - this.page.writeToNBT( nbt ); + nbt.putBoolean( NBT_PRINTING, printing ); + nbt.putString( NBT_PAGE_TITLE, pageTitle ); + page.writeToNBT( nbt ); } // Write inventory - Inventories.toTag( nbt, this.inventory ); + Inventories.toTag( nbt, inventory ); return super.toTag( nbt ); } boolean isPrinting() { - return this.printing; + return printing; } // IInventory implementation @Override public int size() { - return this.inventory.size(); + return inventory.size(); } @Override public boolean isEmpty() { - for( ItemStack stack : this.inventory ) + for( ItemStack stack : inventory ) { if( !stack.isEmpty() ) { @@ -235,14 +235,14 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public ItemStack getStack( int slot ) { - return this.inventory.get( slot ); + return inventory.get( slot ); } @Nonnull @Override public ItemStack removeStack( int slot, int count ) { - ItemStack stack = this.inventory.get( slot ); + ItemStack stack = inventory.get( slot ); if( stack.isEmpty() ) { return ItemStack.EMPTY; @@ -250,18 +250,18 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent if( stack.getCount() <= count ) { - this.setStack( slot, ItemStack.EMPTY ); + setStack( slot, ItemStack.EMPTY ); return stack; } ItemStack part = stack.split( count ); - if( this.inventory.get( slot ) + if( inventory.get( slot ) .isEmpty() ) { - this.inventory.set( slot, ItemStack.EMPTY ); - this.updateBlockState(); + inventory.set( slot, ItemStack.EMPTY ); + updateBlockState(); } - this.markDirty(); + markDirty(); return part; } @@ -269,10 +269,10 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public ItemStack removeStack( int slot ) { - ItemStack result = this.inventory.get( slot ); - this.inventory.set( slot, ItemStack.EMPTY ); - this.markDirty(); - this.updateBlockState(); + ItemStack result = inventory.get( slot ); + inventory.set( slot, ItemStack.EMPTY ); + markDirty(); + updateBlockState(); return result; } @@ -281,26 +281,26 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public void setStack( int slot, @Nonnull ItemStack stack ) { - this.inventory.set( slot, stack ); - this.markDirty(); - this.updateBlockState(); + inventory.set( slot, stack ); + markDirty(); + updateBlockState(); } @Override public boolean canPlayerUse( @Nonnull PlayerEntity playerEntity ) { - return this.isUsable( playerEntity, false ); + return isUsable( playerEntity, false ); } @Override public void clear() { - for( int i = 0; i < this.inventory.size(); i++ ) + for( int i = 0; i < inventory.size(); i++ ) { - this.inventory.set( i, ItemStack.EMPTY ); + inventory.set( i, ItemStack.EMPTY ); } - this.markDirty(); - this.updateBlockState(); + markDirty(); + updateBlockState(); } @Override @@ -350,57 +350,57 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Nullable Terminal getCurrentPage() { - synchronized( this.page ) + synchronized( page ) { - return this.printing ? this.page : null; + return printing ? page : null; } } boolean startNewPage() { - synchronized( this.page ) + synchronized( page ) { - if( !this.canInputPage() ) + if( !canInputPage() ) { return false; } - if( this.printing && !this.outputPage() ) + if( printing && !outputPage() ) { return false; } - return this.inputPage(); + return inputPage(); } } boolean endCurrentPage() { - synchronized( this.page ) + synchronized( page ) { - return this.printing && this.outputPage(); + return printing && outputPage(); } } private boolean outputPage() { - int height = this.page.getHeight(); + int height = page.getHeight(); String[] lines = new String[height]; String[] colours = new String[height]; for( int i = 0; i < height; i++ ) { - lines[i] = this.page.getLine( i ) + lines[i] = page.getLine( i ) .toString(); - colours[i] = this.page.getTextColourLine( i ) + colours[i] = page.getTextColourLine( i ) .toString(); } - ItemStack stack = ItemPrintout.createSingleFromTitleAndText( this.pageTitle, lines, colours ); + ItemStack stack = ItemPrintout.createSingleFromTitleAndText( pageTitle, lines, colours ); for( int slot : BOTTOM_SLOTS ) { - if( this.inventory.get( slot ) + if( inventory.get( slot ) .isEmpty() ) { - this.setStack( slot, stack ); - this.printing = false; + setStack( slot, stack ); + printing = false; return true; } } @@ -409,7 +409,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent int getInkLevel() { - ItemStack inkStack = this.inventory.get( 0 ); + ItemStack inkStack = inventory.get( 0 ); return isInk( inkStack ) ? inkStack.getCount() : 0; } @@ -418,7 +418,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent int count = 0; for( int i = 1; i < 7; i++ ) { - ItemStack paperStack = this.inventory.get( i ); + ItemStack paperStack = inventory.get( i ); if( isPaper( paperStack ) ) { count += paperStack.getCount(); @@ -429,30 +429,30 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent void setPageTitle( String title ) { - synchronized( this.page ) + synchronized( page ) { - if( this.printing ) + if( printing ) { - this.pageTitle = title; + pageTitle = title; } } } private boolean canInputPage() { - ItemStack inkStack = this.inventory.get( 0 ); - return !inkStack.isEmpty() && isInk( inkStack ) && this.getPaperLevel() > 0; + ItemStack inkStack = inventory.get( 0 ); + return !inkStack.isEmpty() && isInk( inkStack ) && getPaperLevel() > 0; } private boolean inputPage() { - ItemStack inkStack = this.inventory.get( 0 ); + ItemStack inkStack = inventory.get( 0 ); DyeColor dye = ColourUtils.getStackColour( inkStack ); if( dye == null ) return false; for( int i = 1; i < 7; i++ ) { - ItemStack paperStack = this.inventory.get( i ); + ItemStack paperStack = inventory.get( i ); if( paperStack.isEmpty() || !isPaper( paperStack ) ) { continue; @@ -461,40 +461,40 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent // Setup the new page page.setTextColour( dye.getId() ); - this.page.clear(); + page.clear(); if( paperStack.getItem() instanceof ItemPrintout ) { - this.pageTitle = ItemPrintout.getTitle( paperStack ); + pageTitle = ItemPrintout.getTitle( paperStack ); String[] text = ItemPrintout.getText( paperStack ); String[] textColour = ItemPrintout.getColours( paperStack ); - for( int y = 0; y < this.page.getHeight(); y++ ) + for( int y = 0; y < page.getHeight(); y++ ) { - this.page.setLine( y, text[y], textColour[y], "" ); + page.setLine( y, text[y], textColour[y], "" ); } } else { - this.pageTitle = ""; + pageTitle = ""; } - this.page.setCursorPos( 0, 0 ); + page.setCursorPos( 0, 0 ); // Decrement ink inkStack.decrement( 1 ); if( inkStack.isEmpty() ) { - this.inventory.set( 0, ItemStack.EMPTY ); + inventory.set( 0, ItemStack.EMPTY ); } // Decrement paper paperStack.decrement( 1 ); if( paperStack.isEmpty() ) { - this.inventory.set( i, ItemStack.EMPTY ); - this.updateBlockState(); + inventory.set( i, ItemStack.EMPTY ); + updateBlockState(); } - this.markDirty(); - this.printing = true; + markDirty(); + printing = true; return true; } return false; @@ -504,14 +504,14 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public Text getName() { - return this.customName != null ? this.customName : new TranslatableText( this.getCachedState().getBlock() + return customName != null ? customName : new TranslatableText( getCachedState().getBlock() .getTranslationKey() ); } @Override public boolean hasCustomName() { - return this.customName != null; + return customName != null; } @Override @@ -524,7 +524,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent @Override public Text getCustomName() { - return this.customName; + return customName; } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/BlockSpeaker.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/BlockSpeaker.java index 366d82d76..50d6c08cd 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/BlockSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/BlockSpeaker.java @@ -25,7 +25,7 @@ public class BlockSpeaker extends BlockGeneric public BlockSpeaker( Settings settings ) { super( settings, ComputerCraftRegistry.ModTiles.SPEAKER ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( FACING, Direction.NORTH ) ); } @@ -33,7 +33,7 @@ public class BlockSpeaker extends BlockGeneric @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, + return getDefaultState().with( FACING, placement.getPlayerFacing() .getOpposite() ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java index 72d45ba85..c44653cbd 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java @@ -40,13 +40,13 @@ public abstract class SpeakerPeripheral implements IPeripheral public void update() { - this.clock++; - this.notesThisTick.set( 0 ); + clock++; + notesThisTick.set( 0 ); } public boolean madeSound( long ticks ) { - return this.clock - this.lastPlayTime <= ticks; + return clock - lastPlayTime <= ticks; } @Nonnull @@ -85,20 +85,20 @@ public abstract class SpeakerPeripheral implements IPeripheral throw new LuaException( "Malformed sound name '" + name + "' " ); } - return this.playSound( context, identifier, volume, pitch, false ); + return playSound( context, identifier, volume, pitch, false ); } private synchronized boolean playSound( ILuaContext context, Identifier name, float volume, float pitch, boolean isNote ) throws LuaException { - if( this.clock - this.lastPlayTime < TileSpeaker.MIN_TICKS_BETWEEN_SOUNDS && (!isNote || this.clock - this.lastPlayTime != 0 || this.notesThisTick.get() >= ComputerCraft.maxNotesPerTick) ) + if( clock - lastPlayTime < TileSpeaker.MIN_TICKS_BETWEEN_SOUNDS && (!isNote || clock - lastPlayTime != 0 || notesThisTick.get() >= ComputerCraft.maxNotesPerTick) ) { // Rate limiting occurs when we've already played a sound within the last tick, or we've // played more notes than allowable within the current tick. return false; } - World world = this.getWorld(); - Vec3d pos = this.getPosition(); + World world = getWorld(); + Vec3d pos = getPosition(); context.issueMainThreadTask( () -> { MinecraftServer server = world.getServer(); @@ -119,7 +119,7 @@ public abstract class SpeakerPeripheral implements IPeripheral return null; } ); - this.lastPlayTime = this.clock; + lastPlayTime = clock; return true; } @@ -166,14 +166,14 @@ public abstract class SpeakerPeripheral implements IPeripheral } // If the resource location for note block notes changes, this method call will need to be updated - boolean success = this.playSound( context, + boolean success = playSound( context, ((SoundEventAccess) instrument.getSound()).getId(), volume, (float) Math.pow( 2.0, (pitch - 12.0) / 12.0 ), true ); if( success ) { - this.notesThisTick.incrementAndGet(); + notesThisTick.incrementAndGet(); } return success; } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java index 9b0bda5a3..08d1e8a41 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/TileSpeaker.java @@ -28,20 +28,20 @@ public class TileSpeaker extends TileGeneric implements Tickable, IPeripheralTil public TileSpeaker( BlockEntityType type ) { super( type ); - this.peripheral = new Peripheral( this ); + peripheral = new Peripheral( this ); } @Override public void tick() { - this.peripheral.update(); + peripheral.update(); } @Nonnull @Override public IPeripheral getPeripheral( Direction side ) { - return this.peripheral; + return peripheral; } private static final class Peripheral extends SpeakerPeripheral @@ -56,20 +56,20 @@ public class TileSpeaker extends TileGeneric implements Tickable, IPeripheralTil @Override public World getWorld() { - return this.speaker.getWorld(); + return speaker.getWorld(); } @Override public Vec3d getPosition() { - BlockPos pos = this.speaker.getPos(); + BlockPos pos = speaker.getPos(); return new Vec3d( pos.getX(), pos.getY(), pos.getZ() ); } @Override public boolean equals( @Nullable IPeripheral other ) { - return this == other || (other instanceof Peripheral && this.speaker == ((Peripheral) other).speaker); + return this == other || (other instanceof Peripheral && speaker == ((Peripheral) other).speaker); } } } diff --git a/src/main/java/dan200/computercraft/shared/pocket/apis/PocketAPI.java b/src/main/java/dan200/computercraft/shared/pocket/apis/PocketAPI.java index e6f27a8d4..d14c9b4ec 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/apis/PocketAPI.java +++ b/src/main/java/dan200/computercraft/shared/pocket/apis/PocketAPI.java @@ -62,14 +62,14 @@ public class PocketAPI implements ILuaAPI @LuaFunction( mainThread = true ) public final Object[] equipBack() { - Entity entity = this.computer.getEntity(); + Entity entity = computer.getEntity(); if( !(entity instanceof PlayerEntity) ) { return new Object[] { false, "Cannot find player" }; } PlayerEntity player = (PlayerEntity) entity; PlayerInventory inventory = player.inventory; - IPocketUpgrade previousUpgrade = this.computer.getUpgrade(); + IPocketUpgrade previousUpgrade = computer.getUpgrade(); // Attempt to find the upgrade, starting in the main segment, and then looking in the opposite // one. We start from the position the item is currently in and loop round to the start. @@ -98,7 +98,7 @@ public class PocketAPI implements ILuaAPI } // Set the new upgrade - this.computer.setUpgrade( newUpgrade ); + computer.setUpgrade( newUpgrade ); return new Object[] { true }; } @@ -137,21 +137,21 @@ public class PocketAPI implements ILuaAPI @LuaFunction( mainThread = true ) public final Object[] unequipBack() { - Entity entity = this.computer.getEntity(); + Entity entity = computer.getEntity(); if( !(entity instanceof PlayerEntity) ) { return new Object[] { false, "Cannot find player" }; } PlayerEntity player = (PlayerEntity) entity; PlayerInventory inventory = player.inventory; - IPocketUpgrade previousUpgrade = this.computer.getUpgrade(); + IPocketUpgrade previousUpgrade = computer.getUpgrade(); if( previousUpgrade == null ) { return new Object[] { false, "Nothing to unequip" }; } - this.computer.setUpgrade( null ); + computer.setUpgrade( null ); ItemStack stack = previousUpgrade.getCraftingItem(); if( !stack.isEmpty() ) diff --git a/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java b/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java index af090de6a..8c6c21625 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/core/PocketServerComputer.java @@ -50,7 +50,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces public Entity getEntity() { Entity entity = this.entity; - if( entity == null || this.stack == null || !entity.isAlive() ) + if( entity == null || stack == null || !entity.isAlive() ) { return null; } @@ -58,12 +58,12 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces if( entity instanceof PlayerEntity ) { PlayerInventory inventory = ((PlayerEntity) entity).inventory; - return inventory.main.contains( this.stack ) || inventory.offHand.contains( this.stack ) ? entity : null; + return inventory.main.contains( stack ) || inventory.offHand.contains( stack ) ? entity : null; } else if( entity instanceof LivingEntity ) { LivingEntity living = (LivingEntity) entity; - return living.getMainHandStack() == this.stack || living.getOffHandStack() == this.stack ? entity : null; + return living.getMainHandStack() == stack || living.getOffHandStack() == stack ? entity : null; } else { @@ -74,39 +74,39 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces @Override public int getColour() { - return IColouredItem.getColourBasic( this.stack ); + return IColouredItem.getColourBasic( stack ); } @Override public void setColour( int colour ) { - IColouredItem.setColourBasic( this.stack, colour ); - this.updateUpgradeNBTData(); + IColouredItem.setColourBasic( stack, colour ); + updateUpgradeNBTData(); } @Override public int getLight() { - CompoundTag tag = this.getUserData(); + CompoundTag tag = getUserData(); return tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1; } @Override public void setLight( int colour ) { - CompoundTag tag = this.getUserData(); + CompoundTag tag = getUserData(); if( colour >= 0 && colour <= 0xFFFFFF ) { if( !tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour ) { tag.putInt( NBT_LIGHT, colour ); - this.updateUserData(); + updateUserData(); } } else if( tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ) { tag.remove( NBT_LIGHT ); - this.updateUserData(); + updateUserData(); } } @@ -114,35 +114,35 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces @Override public CompoundTag getUpgradeNBTData() { - return ItemPocketComputer.getUpgradeInfo( this.stack ); + return ItemPocketComputer.getUpgradeInfo( stack ); } @Override public void updateUpgradeNBTData() { - if( this.entity instanceof PlayerEntity ) + if( entity instanceof PlayerEntity ) { - ((PlayerEntity) this.entity).inventory.markDirty(); + ((PlayerEntity) entity).inventory.markDirty(); } } @Override public void invalidatePeripheral() { - IPeripheral peripheral = this.upgrade == null ? null : this.upgrade.createPeripheral( this ); - this.setPeripheral( ComputerSide.BACK, peripheral ); + IPeripheral peripheral = upgrade == null ? null : upgrade.createPeripheral( this ); + setPeripheral( ComputerSide.BACK, peripheral ); } @Nonnull @Override public Map getUpgrades() { - return this.upgrade == null ? Collections.emptyMap() : Collections.singletonMap( this.upgrade.getUpgradeID(), this.getPeripheral( ComputerSide.BACK ) ); + return upgrade == null ? Collections.emptyMap() : Collections.singletonMap( upgrade.getUpgradeID(), getPeripheral( ComputerSide.BACK ) ); } public IPocketUpgrade getUpgrade() { - return this.upgrade; + return upgrade; } /** @@ -161,10 +161,10 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces synchronized( this ) { - ItemPocketComputer.setUpgrade( this.stack, upgrade ); - this.updateUpgradeNBTData(); + ItemPocketComputer.setUpgrade( stack, upgrade ); + updateUpgradeNBTData(); this.upgrade = upgrade; - this.invalidatePeripheral(); + invalidatePeripheral(); } } @@ -172,14 +172,14 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces { if( entity != null ) { - this.setWorld( entity.getEntityWorld() ); - this.setPosition( entity.getBlockPos() ); + setWorld( entity.getEntityWorld() ); + setPosition( entity.getBlockPos() ); } // If a new entity has picked it up then rebroadcast the terminal to them if( entity != this.entity && entity instanceof ServerPlayerEntity ) { - this.markTerminalChanged(); + markTerminalChanged(); } this.entity = entity; @@ -188,7 +188,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces if( this.upgrade != upgrade ) { this.upgrade = upgrade; - this.invalidatePeripheral(); + invalidatePeripheral(); } } @@ -197,13 +197,13 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces { super.broadcastState( force ); - if( (this.hasTerminalChanged() || force) && this.entity instanceof ServerPlayerEntity ) + if( (hasTerminalChanged() || force) && entity instanceof ServerPlayerEntity ) { // Broadcast the state to the current entity if they're not already interacting with it. - ServerPlayerEntity player = (ServerPlayerEntity) this.entity; - if( player.networkHandler != null && !this.isInteracting( player ) ) + ServerPlayerEntity player = (ServerPlayerEntity) entity; + if( player.networkHandler != null && !isInteracting( player ) ) { - NetworkHandler.sendToPlayer( player, this.createTerminalPacket() ); + NetworkHandler.sendToPlayer( player, createTerminalPacket() ); } } } diff --git a/src/main/java/dan200/computercraft/shared/pocket/inventory/ContainerPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/inventory/ContainerPocketComputer.java index 9a41f3a5a..8149d9199 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/inventory/ContainerPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/inventory/ContainerPocketComputer.java @@ -15,7 +15,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.screen.ScreenHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -39,7 +38,7 @@ public final class ContainerPocketComputer extends ContainerComputerBase super( ComputerCraftRegistry.ModContainers.POCKET_COMPUTER, id, player, packetByteBuf ); } - public static class Factory implements NamedScreenHandlerFactory, ExtendedScreenHandlerFactory + public static class Factory implements ExtendedScreenHandlerFactory { private final ServerComputer computer; private final Text name; @@ -49,7 +48,7 @@ public final class ContainerPocketComputer extends ContainerComputerBase public Factory( ServerComputer computer, ItemStack stack, ItemPocketComputer item, Hand hand ) { this.computer = computer; - this.name = stack.getName(); + name = stack.getName(); this.item = item; this.hand = hand; } @@ -59,21 +58,21 @@ public final class ContainerPocketComputer extends ContainerComputerBase @Override public Text getDisplayName() { - return this.name; + return name; } @Nullable @Override public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity entity ) { - return new ContainerPocketComputer( id, this.computer, this.item, this.hand ); + return new ContainerPocketComputer( id, computer, item, hand ); } @Override public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf ) { - packetByteBuf.writeInt( this.computer.getInstanceID() ); - packetByteBuf.writeEnumConstant( this.computer.getFamily() ); + packetByteBuf.writeInt( computer.getInstanceID() ); + packetByteBuf.writeEnumConstant( computer.getFamily() ); } } } diff --git a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java index 7eda82a58..c3f17547a 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java @@ -147,7 +147,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I ItemStack stack = player.getStackInHand( hand ); if( !world.isClient ) { - PocketServerComputer computer = this.createServerComputer( world, player.inventory, player, stack ); + PocketServerComputer computer = createServerComputer( world, player.inventory, player, stack ); boolean stop = false; if( computer != null ) @@ -178,7 +178,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I { // Server side Inventory inventory = entity instanceof PlayerEntity ? ((PlayerEntity) entity).inventory : null; - PocketServerComputer computer = this.createServerComputer( world, inventory, entity, stack ); + PocketServerComputer computer = createServerComputer( world, inventory, entity, stack ); if( computer != null ) { IPocketUpgrade upgrade = getUpgrade( stack ); @@ -190,7 +190,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I // Sync ID int id = computer.getID(); - if( id != this.getComputerID( stack ) ) + if( id != getComputerID( stack ) ) { setComputerID( stack, id ); if( inventory != null ) @@ -201,9 +201,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I // Sync label String label = computer.getLabel(); - if( !Objects.equal( label, this.getLabel( stack ) ) ) + if( !Objects.equal( label, getLabel( stack ) ) ) { - this.setLabel( stack, label ); + setLabel( stack, label ); if( inventory != null ) { inventory.markDirty(); @@ -227,9 +227,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public void appendTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List list, TooltipContext flag ) { - if( flag.isAdvanced() || this.getLabel( stack ) == null ) + if( flag.isAdvanced() || getLabel( stack ) == null ) { - int id = this.getComputerID( stack ); + int id = getComputerID( stack ); if( id >= 0 ) { list.add( new TranslatableText( "gui.computercraft.tooltip.computer_id", id ).formatted( Formatting.GRAY ) ); @@ -241,7 +241,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public Text getName( @Nonnull ItemStack stack ) { - String baseString = this.getTranslationKey( stack ); + String baseString = getTranslationKey( stack ); IPocketUpgrade upgrade = getUpgrade( stack ); if( upgrade != null ) { @@ -258,14 +258,14 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public void appendStacks( @Nonnull ItemGroup group, @Nonnull DefaultedList stacks ) { - if( !this.isIn( group ) ) + if( !isIn( group ) ) { return; } - stacks.add( this.create( -1, null, -1, null ) ); + stacks.add( create( -1, null, -1, null ) ); for( IPocketUpgrade upgrade : PocketUpgrades.getVanillaUpgrades() ) { - stacks.add( this.create( -1, null, -1, upgrade ) ); + stacks.add( create( -1, null, -1, upgrade ) ); } } @@ -320,13 +320,13 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I setInstanceID( stack, instanceID ); setSessionID( stack, correctSessionID ); } - int computerID = this.getComputerID( stack ); + int computerID = getComputerID( stack ); if( computerID < 0 ) { computerID = ComputerCraftAPI.createUniqueNumberedSaveDir( world, "computer" ); setComputerID( stack, computerID ); } - computer = new PocketServerComputer( world, computerID, this.getLabel( stack ), instanceID, this.getFamily() ); + computer = new PocketServerComputer( world, computerID, getLabel( stack ), instanceID, getFamily() ); computer.updateValues( entity, stack, getUpgrade( stack ) ); computer.addAPI( new PocketAPI( computer ) ); ComputerCraft.serverComputerRegistry.add( instanceID, computer ); @@ -363,13 +363,13 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public ComputerFamily getFamily() { - return this.family; + return family; } @Override public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family ) { - return PocketComputerItemFactory.create( this.getComputerID( stack ), this.getLabel( stack ), this.getColour( stack ), family, getUpgrade( stack ) ); + return PocketComputerItemFactory.create( getComputerID( stack ), getLabel( stack ), getColour( stack ), family, getUpgrade( stack ) ); } @Override @@ -427,7 +427,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I @Override public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) { - int id = this.getComputerID( stack ); + int id = getComputerID( stack ); if( id >= 0 ) { return ComputerCraftAPI.createSaveDirMount( world, "computer/" + id, ComputerCraft.computerSpaceLimit ); diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModem.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModem.java index d4e9e1929..6ba68d559 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModem.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModem.java @@ -32,7 +32,7 @@ public class PocketModem extends AbstractPocketUpgrade @Override public IPeripheral createPeripheral( @Nonnull IPocketAccess access ) { - return new PocketModemPeripheral( this.advanced ); + return new PocketModemPeripheral( advanced ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java index e4a9c1ff8..d43c860b4 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketModemPeripheral.java @@ -34,14 +34,14 @@ public class PocketModemPeripheral extends WirelessModemPeripheral @Override public World getWorld() { - return this.world; + return world; } @Nonnull @Override public Vec3d getPosition() { - return this.position; + return position; } @Override diff --git a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java index b1a451b78..dcec95bb9 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/pocket/peripherals/PocketSpeakerPeripheral.java @@ -25,13 +25,13 @@ public class PocketSpeakerPeripheral extends SpeakerPeripheral @Override public World getWorld() { - return this.world; + return world; } @Override public Vec3d getPosition() { - return this.world != null ? this.position : null; + return world != null ? position : null; } @Override diff --git a/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java index 79faf31e1..279a2ad1c 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java @@ -40,7 +40,7 @@ public final class PocketComputerUpgradeRecipe extends SpecialCraftingRecipe @Override public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world ) { - return !this.craft( inventory ).isEmpty(); + return !craft( inventory ).isEmpty(); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index 200a21c84..801f62d12 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -57,13 +57,13 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult forward() { - return this.trackCommand( new TurtleMoveCommand( MoveDirection.FORWARD ) ); + return trackCommand( new TurtleMoveCommand( MoveDirection.FORWARD ) ); } private MethodResult trackCommand( ITurtleCommand command ) { - this.environment.addTrackingChange( TrackingField.TURTLE_OPS ); - return this.turtle.executeCommand( command ); + environment.addTrackingChange( TrackingField.TURTLE_OPS ); + return turtle.executeCommand( command ); } /** @@ -76,7 +76,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult back() { - return this.trackCommand( new TurtleMoveCommand( MoveDirection.BACK ) ); + return trackCommand( new TurtleMoveCommand( MoveDirection.BACK ) ); } /** @@ -89,7 +89,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult up() { - return this.trackCommand( new TurtleMoveCommand( MoveDirection.UP ) ); + return trackCommand( new TurtleMoveCommand( MoveDirection.UP ) ); } /** @@ -102,7 +102,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult down() { - return this.trackCommand( new TurtleMoveCommand( MoveDirection.DOWN ) ); + return trackCommand( new TurtleMoveCommand( MoveDirection.DOWN ) ); } /** @@ -115,7 +115,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult turnLeft() { - return this.trackCommand( new TurtleTurnCommand( TurnDirection.LEFT ) ); + return trackCommand( new TurtleTurnCommand( TurnDirection.LEFT ) ); } /** @@ -128,7 +128,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult turnRight() { - return this.trackCommand( new TurtleTurnCommand( TurnDirection.RIGHT ) ); + return trackCommand( new TurtleTurnCommand( TurnDirection.RIGHT ) ); } /** @@ -145,8 +145,8 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult dig( Optional side ) { - this.environment.addTrackingChange( TrackingField.TURTLE_OPS ); - return this.trackCommand( TurtleToolCommand.dig( InteractDirection.FORWARD, side.orElse( null ) ) ); + environment.addTrackingChange( TrackingField.TURTLE_OPS ); + return trackCommand( TurtleToolCommand.dig( InteractDirection.FORWARD, side.orElse( null ) ) ); } /** @@ -160,8 +160,8 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult digUp( Optional side ) { - this.environment.addTrackingChange( TrackingField.TURTLE_OPS ); - return this.trackCommand( TurtleToolCommand.dig( InteractDirection.UP, side.orElse( null ) ) ); + environment.addTrackingChange( TrackingField.TURTLE_OPS ); + return trackCommand( TurtleToolCommand.dig( InteractDirection.UP, side.orElse( null ) ) ); } /** @@ -175,8 +175,8 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult digDown( Optional side ) { - this.environment.addTrackingChange( TrackingField.TURTLE_OPS ); - return this.trackCommand( TurtleToolCommand.dig( InteractDirection.DOWN, side.orElse( null ) ) ); + environment.addTrackingChange( TrackingField.TURTLE_OPS ); + return trackCommand( TurtleToolCommand.dig( InteractDirection.DOWN, side.orElse( null ) ) ); } /** @@ -195,7 +195,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult place( IArguments args ) { - return this.trackCommand( new TurtlePlaceCommand( InteractDirection.FORWARD, args.getAll() ) ); + return trackCommand( new TurtlePlaceCommand( InteractDirection.FORWARD, args.getAll() ) ); } /** @@ -211,7 +211,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult placeUp( IArguments args ) { - return this.trackCommand( new TurtlePlaceCommand( InteractDirection.UP, args.getAll() ) ); + return trackCommand( new TurtlePlaceCommand( InteractDirection.UP, args.getAll() ) ); } /** @@ -227,7 +227,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult placeDown( IArguments args ) { - return this.trackCommand( new TurtlePlaceCommand( InteractDirection.DOWN, args.getAll() ) ); + return trackCommand( new TurtlePlaceCommand( InteractDirection.DOWN, args.getAll() ) ); } /** @@ -243,7 +243,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult drop( Optional count ) throws LuaException { - return this.trackCommand( new TurtleDropCommand( InteractDirection.FORWARD, checkCount( count ) ) ); + return trackCommand( new TurtleDropCommand( InteractDirection.FORWARD, checkCount( count ) ) ); } private static int checkCount( Optional countArg ) throws LuaException @@ -269,7 +269,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult dropUp( Optional count ) throws LuaException { - return this.trackCommand( new TurtleDropCommand( InteractDirection.UP, checkCount( count ) ) ); + return trackCommand( new TurtleDropCommand( InteractDirection.UP, checkCount( count ) ) ); } /** @@ -285,7 +285,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult dropDown( Optional count ) throws LuaException { - return this.trackCommand( new TurtleDropCommand( InteractDirection.DOWN, checkCount( count ) ) ); + return trackCommand( new TurtleDropCommand( InteractDirection.DOWN, checkCount( count ) ) ); } /** @@ -304,7 +304,7 @@ public class TurtleAPI implements ILuaAPI public final MethodResult select( int slot ) throws LuaException { int actualSlot = checkSlot( slot ); - return this.turtle.executeCommand( turtle -> { + return turtle.executeCommand( turtle -> { turtle.setSelectedSlot( actualSlot ); return TurtleCommandResult.success(); } ); @@ -329,8 +329,8 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final int getItemCount( Optional slot ) throws LuaException { - int actualSlot = checkSlot( slot ).orElse( this.turtle.getSelectedSlot() ); - return this.turtle.getInventory() + int actualSlot = checkSlot( slot ).orElse( turtle.getSelectedSlot() ); + return turtle.getInventory() .getStack( actualSlot ) .getCount(); } @@ -352,8 +352,8 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final int getItemSpace( Optional slot ) throws LuaException { - int actualSlot = checkSlot( slot ).orElse( this.turtle.getSelectedSlot() ); - ItemStack stack = this.turtle.getInventory() + int actualSlot = checkSlot( slot ).orElse( turtle.getSelectedSlot() ); + ItemStack stack = turtle.getInventory() .getStack( actualSlot ); return stack.isEmpty() ? 64 : Math.min( stack.getMaxCount(), 64 ) - stack.getCount(); } @@ -367,7 +367,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult detect() { - return this.trackCommand( new TurtleDetectCommand( InteractDirection.FORWARD ) ); + return trackCommand( new TurtleDetectCommand( InteractDirection.FORWARD ) ); } /** @@ -379,7 +379,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult detectUp() { - return this.trackCommand( new TurtleDetectCommand( InteractDirection.UP ) ); + return trackCommand( new TurtleDetectCommand( InteractDirection.UP ) ); } /** @@ -391,7 +391,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult detectDown() { - return this.trackCommand( new TurtleDetectCommand( InteractDirection.DOWN ) ); + return trackCommand( new TurtleDetectCommand( InteractDirection.DOWN ) ); } /** @@ -403,7 +403,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult compare() { - return this.trackCommand( new TurtleCompareCommand( InteractDirection.FORWARD ) ); + return trackCommand( new TurtleCompareCommand( InteractDirection.FORWARD ) ); } /** @@ -415,7 +415,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult compareUp() { - return this.trackCommand( new TurtleCompareCommand( InteractDirection.UP ) ); + return trackCommand( new TurtleCompareCommand( InteractDirection.UP ) ); } /** @@ -427,7 +427,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult compareDown() { - return this.trackCommand( new TurtleCompareCommand( InteractDirection.DOWN ) ); + return trackCommand( new TurtleCompareCommand( InteractDirection.DOWN ) ); } /** @@ -441,7 +441,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult attack( Optional side ) { - return this.trackCommand( TurtleToolCommand.attack( InteractDirection.FORWARD, side.orElse( null ) ) ); + return trackCommand( TurtleToolCommand.attack( InteractDirection.FORWARD, side.orElse( null ) ) ); } /** @@ -455,7 +455,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult attackUp( Optional side ) { - return this.trackCommand( TurtleToolCommand.attack( InteractDirection.UP, side.orElse( null ) ) ); + return trackCommand( TurtleToolCommand.attack( InteractDirection.UP, side.orElse( null ) ) ); } /** @@ -469,7 +469,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult attackDown( Optional side ) { - return this.trackCommand( TurtleToolCommand.attack( InteractDirection.DOWN, side.orElse( null ) ) ); + return trackCommand( TurtleToolCommand.attack( InteractDirection.DOWN, side.orElse( null ) ) ); } /** @@ -486,7 +486,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult suck( Optional count ) throws LuaException { - return this.trackCommand( new TurtleSuckCommand( InteractDirection.FORWARD, checkCount( count ) ) ); + return trackCommand( new TurtleSuckCommand( InteractDirection.FORWARD, checkCount( count ) ) ); } /** @@ -501,7 +501,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult suckUp( Optional count ) throws LuaException { - return this.trackCommand( new TurtleSuckCommand( InteractDirection.UP, checkCount( count ) ) ); + return trackCommand( new TurtleSuckCommand( InteractDirection.UP, checkCount( count ) ) ); } /** @@ -516,7 +516,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult suckDown( Optional count ) throws LuaException { - return this.trackCommand( new TurtleSuckCommand( InteractDirection.DOWN, checkCount( count ) ) ); + return trackCommand( new TurtleSuckCommand( InteractDirection.DOWN, checkCount( count ) ) ); } /** @@ -531,7 +531,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final Object getFuelLevel() { - return this.turtle.isFuelNeeded() ? this.turtle.getFuelLevel() : "unlimited"; + return turtle.isFuelNeeded() ? turtle.getFuelLevel() : "unlimited"; } /** @@ -578,7 +578,7 @@ public class TurtleAPI implements ILuaAPI { throw new LuaException( "Refuel count " + count + " out of range" ); } - return this.trackCommand( new TurtleRefuelCommand( count ) ); + return trackCommand( new TurtleRefuelCommand( count ) ); } /** @@ -592,7 +592,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult compareTo( int slot ) throws LuaException { - return this.trackCommand( new TurtleCompareToCommand( checkSlot( slot ) ) ); + return trackCommand( new TurtleCompareToCommand( checkSlot( slot ) ) ); } /** @@ -610,7 +610,7 @@ public class TurtleAPI implements ILuaAPI { int slot = checkSlot( slotArg ); int count = checkCount( countArg ); - return this.trackCommand( new TurtleTransferToCommand( slot, count ) ); + return trackCommand( new TurtleTransferToCommand( slot, count ) ); } /** @@ -622,7 +622,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final int getSelectedSlot() { - return this.turtle.getSelectedSlot() + 1; + return turtle.getSelectedSlot() + 1; } /** @@ -639,7 +639,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final Object getFuelLimit() { - return this.turtle.isFuelNeeded() ? this.turtle.getFuelLimit() : "unlimited"; + return turtle.isFuelNeeded() ? turtle.getFuelLimit() : "unlimited"; } /** @@ -658,7 +658,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult equipLeft() { - return this.trackCommand( new TurtleEquipCommand( TurtleSide.LEFT ) ); + return trackCommand( new TurtleEquipCommand( TurtleSide.LEFT ) ); } /** @@ -677,7 +677,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult equipRight() { - return this.trackCommand( new TurtleEquipCommand( TurtleSide.RIGHT ) ); + return trackCommand( new TurtleEquipCommand( TurtleSide.RIGHT ) ); } /** @@ -702,7 +702,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult inspect() { - return this.trackCommand( new TurtleInspectCommand( InteractDirection.FORWARD ) ); + return trackCommand( new TurtleInspectCommand( InteractDirection.FORWARD ) ); } /** @@ -715,7 +715,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult inspectUp() { - return this.trackCommand( new TurtleInspectCommand( InteractDirection.UP ) ); + return trackCommand( new TurtleInspectCommand( InteractDirection.UP ) ); } /** @@ -728,7 +728,7 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult inspectDown() { - return this.trackCommand( new TurtleInspectCommand( InteractDirection.DOWN ) ); + return trackCommand( new TurtleInspectCommand( InteractDirection.DOWN ) ); } /** @@ -755,14 +755,14 @@ public class TurtleAPI implements ILuaAPI @LuaFunction public final MethodResult getItemDetail( ILuaContext context, Optional slot, Optional detailed ) throws LuaException { - int actualSlot = checkSlot( slot ).orElse( this.turtle.getSelectedSlot() ); - return detailed.orElse( false ) ? TaskCallback.make( context, () -> this.getItemDetail( actualSlot, true ) ) : MethodResult.of( this.getItemDetail( actualSlot, + int actualSlot = checkSlot( slot ).orElse( turtle.getSelectedSlot() ); + return detailed.orElse( false ) ? TaskCallback.make( context, () -> getItemDetail( actualSlot, true ) ) : MethodResult.of( getItemDetail( actualSlot, false ) ); } private Object[] getItemDetail( int slot, boolean detailed ) { - ItemStack stack = this.turtle.getInventory() + ItemStack stack = turtle.getInventory() .getStack( slot ); if( stack.isEmpty() ) { @@ -773,7 +773,7 @@ public class TurtleAPI implements ILuaAPI ? ItemData.fill( new HashMap<>(), stack ) : ItemData.fillBasicSafe( new HashMap<>(), stack ); - TurtleActionEvent event = new TurtleInspectItemEvent( this.turtle, stack, table, detailed ); + TurtleActionEvent event = new TurtleInspectItemEvent( turtle, stack, table, detailed ); if( TurtleEvent.post( event ) ) { return new Object[] { false, event.getFailureMessage() }; diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java index cdecd21fd..bff000580 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java @@ -49,7 +49,7 @@ public class BlockTurtle extends BlockComputerBase implements Waterl public BlockTurtle( Settings settings, ComputerFamily family, BlockEntityType type ) { super( settings, family, type ); - this.setDefaultState( this.getStateManager().getDefaultState() + setDefaultState( getStateManager().getDefaultState() .with( FACING, Direction.NORTH ) .with( WATERLOGGED, false ) ); } @@ -101,7 +101,7 @@ public class BlockTurtle extends BlockComputerBase implements Waterl @Override public BlockState getPlacementState( ItemPlacementContext placement ) { - return this.getDefaultState().with( FACING, placement.getPlayerFacing() ) + return getDefaultState().with( FACING, placement.getPlayerFacing() ) .with( WATERLOGGED, getWaterloggedStateForPlacement( placement ) ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java index 07c64678f..60a09b941 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java @@ -65,7 +65,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override protected void unload() { - if( !this.hasMoved() ) + if( !hasMoved() ) { super.unload(); } @@ -74,21 +74,21 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public void destroy() { - if( !this.hasMoved() ) + if( !hasMoved() ) { // Stop computer super.destroy(); // Drop contents - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - int size = this.size(); + int size = size(); for( int i = 0; i < size; i++ ) { - ItemStack stack = this.getStack( i ); + ItemStack stack = getStack( i ); if( !stack.isEmpty() ) { - WorldUtil.dropItemStack( stack, this.getWorld(), this.getPos() ); + WorldUtil.dropItemStack( stack, getWorld(), getPos() ); } } } @@ -98,14 +98,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default // Just turn off any redstone we had on for( Direction dir : DirectionUtil.FACINGS ) { - RedstoneUtil.propagateRedstoneOutput( this.getWorld(), this.getPos(), dir ); + RedstoneUtil.propagateRedstoneOutput( getWorld(), getPos(), dir ); } } } private boolean hasMoved() { - return this.moveState == MoveState.MOVED; + return moveState == MoveState.MOVED; } @Override @@ -117,7 +117,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public boolean isEmpty() { - for( ItemStack stack : this.inventory ) + for( ItemStack stack : inventory ) { if( !stack.isEmpty() ) { @@ -131,7 +131,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public ItemStack getStack( int slot ) { - return slot >= 0 && slot < INVENTORY_SIZE ? this.inventory.get( slot ) : ItemStack.EMPTY; + return slot >= 0 && slot < INVENTORY_SIZE ? inventory.get( slot ) : ItemStack.EMPTY; } @Nonnull @@ -143,7 +143,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default return ItemStack.EMPTY; } - ItemStack stack = this.getStack( slot ); + ItemStack stack = getStack( slot ); if( stack.isEmpty() ) { return ItemStack.EMPTY; @@ -151,12 +151,12 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default if( stack.getCount() <= count ) { - this.setStack( slot, ItemStack.EMPTY ); + setStack( slot, ItemStack.EMPTY ); return stack; } ItemStack part = stack.split( count ); - this.onInventoryDefinitelyChanged(); + onInventoryDefinitelyChanged(); return part; } @@ -164,31 +164,31 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public ItemStack removeStack( int slot ) { - ItemStack result = this.getStack( slot ); - this.setStack( slot, ItemStack.EMPTY ); + ItemStack result = getStack( slot ); + setStack( slot, ItemStack.EMPTY ); return result; } @Override public void setStack( int i, @Nonnull ItemStack stack ) { - if( i >= 0 && i < INVENTORY_SIZE && !InventoryUtil.areItemsEqual( stack, this.inventory.get( i ) ) ) + if( i >= 0 && i < INVENTORY_SIZE && !InventoryUtil.areItemsEqual( stack, inventory.get( i ) ) ) { - this.inventory.set( i, stack ); - this.onInventoryDefinitelyChanged(); + inventory.set( i, stack ); + onInventoryDefinitelyChanged(); } } @Override public boolean canPlayerUse( @Nonnull PlayerEntity player ) { - return this.isUsable( player, false ); + return isUsable( player, false ); } private void onInventoryDefinitelyChanged() { super.markDirty(); - this.inventoryChanged = true; + inventoryChanged = true; } @Override @@ -208,12 +208,12 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default if( currentItem.getItem() instanceof DyeItem ) { // Dye to change turtle colour - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { DyeColor dye = ((DyeItem) currentItem.getItem()).getColor(); - if( this.brain.getDyeColour() != dye ) + if( brain.getDyeColour() != dye ) { - this.brain.setDyeColour( dye ); + brain.setDyeColour( dye ); if( !player.isCreative() ) { currentItem.decrement( 1 ); @@ -222,14 +222,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default } return ActionResult.SUCCESS; } - else if( currentItem.getItem() == Items.WATER_BUCKET && this.brain.getColour() != -1 ) + else if( currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1 ) { // Water to remove turtle colour - if( !this.getWorld().isClient ) + if( !getWorld().isClient ) { - if( this.brain.getColour() != -1 ) + if( brain.getColour() != -1 ) { - this.brain.setColour( -1 ); + brain.setColour( -1 ); if( !player.isCreative() ) { player.setStackInHand( hand, new ItemStack( Items.BUCKET ) ); @@ -248,7 +248,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public void onNeighbourChange( @Nonnull BlockPos neighbour ) { - if( this.moveState == MoveState.NOT_MOVED ) + if( moveState == MoveState.NOT_MOVED ) { super.onNeighbourChange( neighbour ); } @@ -257,7 +257,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) { - if( this.moveState == MoveState.NOT_MOVED ) + if( moveState == MoveState.NOT_MOVED ) { super.onNeighbourTileEntityChange( neighbour ); } @@ -267,20 +267,20 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default public void tick() { super.tick(); - this.brain.update(); - if( !this.getWorld().isClient && this.inventoryChanged ) + brain.update(); + if( !getWorld().isClient && inventoryChanged ) { - ServerComputer computer = this.getServerComputer(); + ServerComputer computer = getServerComputer(); if( computer != null ) { computer.queueEvent( "turtle_inventory" ); } - this.inventoryChanged = false; - for( int n = 0; n < this.size(); n++ ) + inventoryChanged = false; + for( int n = 0; n < size(); n++ ) { - this.previousInventory.set( n, - this.getStack( n ).copy() ); + previousInventory.set( n, + getStack( n ).copy() ); } } } @@ -298,12 +298,12 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default ListTag nbttaglist = new ListTag(); for( int i = 0; i < INVENTORY_SIZE; i++ ) { - if( !this.inventory.get( i ) + if( !inventory.get( i ) .isEmpty() ) { CompoundTag tag = new CompoundTag(); tag.putByte( "Slot", (byte) i ); - this.inventory.get( i ) + inventory.get( i ) .toTag( tag ); nbttaglist.add( tag ); } @@ -311,7 +311,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default nbt.put( "Items", nbttaglist ); // Write brain - nbt = this.brain.writeToNBT( nbt ); + nbt = brain.writeToNBT( nbt ); return super.toTag( nbt ); } @@ -325,28 +325,28 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default // Read inventory ListTag nbttaglist = nbt.getList( "Items", NBTUtil.TAG_COMPOUND ); - this.inventory.clear(); - this.previousInventory.clear(); + inventory.clear(); + previousInventory.clear(); for( int i = 0; i < nbttaglist.size(); i++ ) { CompoundTag tag = nbttaglist.getCompound( i ); int slot = tag.getByte( "Slot" ) & 0xff; - if( slot < this.size() ) + if( slot < size() ) { - this.inventory.set( slot, ItemStack.fromTag( tag ) ); - this.previousInventory.set( slot, this.inventory.get( slot ) + inventory.set( slot, ItemStack.fromTag( tag ) ); + previousInventory.set( slot, inventory.get( slot ) .copy() ); } } // Read state - this.brain.readFromNBT( nbt ); + brain.readFromNBT( nbt ); } @Override protected boolean isPeripheralBlockedOnSide( ComputerSide localSide ) { - return this.hasPeripheralUpgradeOnSide( localSide ); + return hasPeripheralUpgradeOnSide( localSide ); } // ITurtleTile @@ -354,20 +354,20 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public Direction getDirection() { - return this.getCachedState().get( BlockTurtle.FACING ); + return getCachedState().get( BlockTurtle.FACING ); } @Override protected ServerComputer createComputer( int instanceID, int id ) { - ServerComputer computer = new ServerComputer( this.getWorld(), - id, this.label, - instanceID, this.getFamily(), + ServerComputer computer = new ServerComputer( getWorld(), + id, label, + instanceID, getFamily(), ComputerCraft.turtleTermWidth, ComputerCraft.turtleTermHeight ); - computer.setPosition( this.getPos() ); - computer.addAPI( new TurtleAPI( computer.getAPIEnvironment(), this.getAccess() ) ); - this.brain.setupComputer( computer ); + computer.setPosition( getPos() ); + computer.addAPI( new TurtleAPI( computer.getAPIEnvironment(), getAccess() ) ); + brain.setupComputer( computer ); return computer; } @@ -375,20 +375,20 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default protected void writeDescription( @Nonnull CompoundTag nbt ) { super.writeDescription( nbt ); - this.brain.writeDescription( nbt ); + brain.writeDescription( nbt ); } @Override protected void readDescription( @Nonnull CompoundTag nbt ) { super.readDescription( nbt ); - this.brain.readDescription( nbt ); + brain.readDescription( nbt ); } @Override public ComputerProxy createProxy() { - return this.brain.getProxy(); + return brain.getProxy(); } public void setDirection( Direction dir ) @@ -397,11 +397,11 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default { dir = Direction.NORTH; } - this.world.setBlockState( this.pos, - this.getCachedState().with( BlockTurtle.FACING, dir ) ); - this.updateOutput(); - this.updateInput(); - this.onTileEntityChange(); + world.setBlockState( pos, + getCachedState().with( BlockTurtle.FACING, dir ) ); + updateOutput(); + updateInput(); + onTileEntityChange(); } public void onTileEntityChange() @@ -415,10 +415,10 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default switch( side ) { case RIGHT: - upgrade = this.getUpgrade( TurtleSide.RIGHT ); + upgrade = getUpgrade( TurtleSide.RIGHT ); break; case LEFT: - upgrade = this.getUpgrade( TurtleSide.LEFT ); + upgrade = getUpgrade( TurtleSide.LEFT ); break; default: return false; @@ -437,67 +437,67 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default public void notifyMoveStart() { - if( this.moveState == MoveState.NOT_MOVED ) + if( moveState == MoveState.NOT_MOVED ) { - this.moveState = MoveState.IN_PROGRESS; + moveState = MoveState.IN_PROGRESS; } } public void notifyMoveEnd() { // MoveState.MOVED is final - if( this.moveState == MoveState.IN_PROGRESS ) + if( moveState == MoveState.IN_PROGRESS ) { - this.moveState = MoveState.NOT_MOVED; + moveState = MoveState.NOT_MOVED; } } @Override public int getColour() { - return this.brain.getColour(); + return brain.getColour(); } @Override public Identifier getOverlay() { - return this.brain.getOverlay(); + return brain.getOverlay(); } @Override public ITurtleUpgrade getUpgrade( TurtleSide side ) { - return this.brain.getUpgrade( side ); + return brain.getUpgrade( side ); } @Override public ITurtleAccess getAccess() { - return this.brain; + return brain; } @Override public Vec3d getRenderOffset( float f ) { - return this.brain.getRenderOffset( f ); + return brain.getRenderOffset( f ); } @Override public float getRenderYaw( float f ) { - return this.brain.getVisualYaw( f ); + return brain.getVisualYaw( f ); } @Override public float getToolRenderAngle( TurtleSide side, float f ) { - return this.brain.getToolRenderAngle( side, f ); + return brain.getToolRenderAngle( side, f ); } void setOwningPlayer( GameProfile player ) { - this.brain.setOwningPlayer( player ); - this.markDirty(); + brain.setOwningPlayer( player ); + markDirty(); } // Networking stuff @@ -506,13 +506,13 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default public void markDirty() { super.markDirty(); - if( !this.inventoryChanged ) + if( !inventoryChanged ) { - for( int n = 0; n < this.size(); n++ ) + for( int n = 0; n < size(); n++ ) { - if( !ItemStack.areEqual( this.getStack( n ), this.previousInventory.get( n ) ) ) + if( !ItemStack.areEqual( getStack( n ), previousInventory.get( n ) ) ) { - this.inventoryChanged = true; + inventoryChanged = true; break; } } @@ -525,17 +525,17 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default boolean changed = false; for( int i = 0; i < INVENTORY_SIZE; i++ ) { - if( !this.inventory.get( i ) + if( !inventory.get( i ) .isEmpty() ) { - this.inventory.set( i, ItemStack.EMPTY ); + inventory.set( i, ItemStack.EMPTY ); changed = true; } } if( changed ) { - this.onInventoryDefinitelyChanged(); + onInventoryDefinitelyChanged(); } } @@ -544,11 +544,11 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default public void transferStateFrom( TileTurtle copy ) { super.transferStateFrom( copy ); - Collections.copy( this.inventory, copy.inventory ); - Collections.copy( this.previousInventory, copy.previousInventory ); - this.inventoryChanged = copy.inventoryChanged; - this.brain = copy.brain; - this.brain.setOwner( this ); + Collections.copy( inventory, copy.inventory ); + Collections.copy( previousInventory, copy.previousInventory ); + inventoryChanged = copy.inventoryChanged; + brain = copy.brain; + brain.setOwner( this ); // Mark the other turtle as having moved, and so its peripheral is dead. copy.moveState = MoveState.MOVED; @@ -558,7 +558,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default @Override public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player ) { - return new ContainerTurtle( id, inventory, this.brain ); + return new ContainerTurtle( id, inventory, brain ); } enum MoveState diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java index 3cfd4ee4b..ff4c01a1d 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java @@ -65,7 +65,7 @@ public class TurtleBrain implements ITurtleAccess private final Map upgradeNBTData = new EnumMap<>( TurtleSide.class ); TurtlePlayer cachedPlayer; private TileTurtle owner; - private final Inventory inventory = (InventoryDelegate) () -> this.owner; + private final Inventory inventory = (InventoryDelegate) () -> owner; private ComputerProxy proxy; private GameProfile owningPlayer; private int commandsIssued = 0; @@ -79,12 +79,12 @@ public class TurtleBrain implements ITurtleAccess public TurtleBrain( TileTurtle turtle ) { - this.owner = turtle; + owner = turtle; } public TileTurtle getOwner() { - return this.owner; + return owner; } public void setOwner( TileTurtle owner ) @@ -94,21 +94,21 @@ public class TurtleBrain implements ITurtleAccess public ComputerProxy getProxy() { - if( this.proxy == null ) + if( proxy == null ) { - this.proxy = new ComputerProxy( () -> this.owner ); + proxy = new ComputerProxy( () -> owner ); } - return this.proxy; + return proxy; } public ComputerFamily getFamily() { - return this.owner.getFamily(); + return owner.getFamily(); } public void setupComputer( ServerComputer computer ) { - this.updatePeripherals( computer ); + updatePeripherals( computer ); } private void updatePeripherals( ServerComputer serverComputer ) @@ -121,7 +121,7 @@ public class TurtleBrain implements ITurtleAccess // Update peripherals for( TurtleSide side : TurtleSide.values() ) { - ITurtleUpgrade upgrade = this.getUpgrade( side ); + ITurtleUpgrade upgrade = getUpgrade( side ); IPeripheral peripheral = null; if( upgrade != null && upgrade.getType() .isPeripheral() ) @@ -129,7 +129,7 @@ public class TurtleBrain implements ITurtleAccess peripheral = upgrade.createPeripheral( this, side ); } - IPeripheral existing = this.peripherals.get( side ); + IPeripheral existing = peripherals.get( side ); if( existing == peripheral || (existing != null && peripheral != null && existing.equals( peripheral )) ) { // If the peripheral is the same, just use that. @@ -138,7 +138,7 @@ public class TurtleBrain implements ITurtleAccess else { // Otherwise update our map - this.peripherals.put( side, peripheral ); + peripherals.put( side, peripheral ); } // Always update the computer: it may not be the same computer as before! @@ -160,11 +160,11 @@ public class TurtleBrain implements ITurtleAccess public void update() { - World world = this.getWorld(); + World world = getWorld(); if( !world.isClient ) { // Advance movement - this.updateCommands(); + updateCommands(); // The block may have been broken while the command was executing (for instance, if a block explodes // when being mined). If so, abort. @@ -172,12 +172,12 @@ public class TurtleBrain implements ITurtleAccess } // Advance animation - this.updateAnimation(); + updateAnimation(); // Advance upgrades - if( !this.upgrades.isEmpty() ) + if( !upgrades.isEmpty() ) { - for( Map.Entry entry : this.upgrades.entrySet() ) + for( Map.Entry entry : upgrades.entrySet() ) { entry.getValue() .update( this, entry.getKey() ); @@ -189,29 +189,29 @@ public class TurtleBrain implements ITurtleAccess @Override public World getWorld() { - return this.owner.getWorld(); + return owner.getWorld(); } @Nonnull @Override public BlockPos getPosition() { - return this.owner.getPos(); + return owner.getPos(); } @Override public boolean teleportTo( @Nonnull World world, @Nonnull BlockPos pos ) { - if( world.isClient || this.getWorld().isClient ) + if( world.isClient || getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot teleport on the client" ); } // Cache info about the old turtle (so we don't access this after we delete ourselves) - World oldWorld = this.getWorld(); - TileTurtle oldOwner = this.owner; - BlockPos oldPos = this.owner.getPos(); - BlockState oldBlock = this.owner.getCachedState(); + World oldWorld = getWorld(); + TileTurtle oldOwner = owner; + BlockPos oldPos = owner.getPos(); + BlockState oldBlock = owner.getCachedState(); if( oldWorld == world && oldPos.equals( pos ) ) { @@ -291,35 +291,31 @@ public class TurtleBrain implements ITurtleAccess @Override public Vec3d getVisualPosition( float f ) { - Vec3d offset = this.getRenderOffset( f ); - BlockPos pos = this.owner.getPos(); + Vec3d offset = getRenderOffset( f ); + BlockPos pos = owner.getPos(); return new Vec3d( pos.getX() + 0.5 + offset.x, pos.getY() + 0.5 + offset.y, pos.getZ() + 0.5 + offset.z ); } @Override public float getVisualYaw( float f ) { - float yaw = this.getDirection().asRotation(); - switch( this.animation ) + float yaw = getDirection().asRotation(); + switch( animation ) { case TURN_LEFT: - { - yaw += 90.0f * (1.0f - this.getAnimationFraction( f )); + yaw += 90.0f * (1.0f - getAnimationFraction( f )); if( yaw >= 360.0f ) { yaw -= 360.0f; } break; - } case TURN_RIGHT: - { - yaw += -90.0f * (1.0f - this.getAnimationFraction( f )); + yaw += -90.0f * (1.0f - getAnimationFraction( f )); if( yaw < 0.0f ) { yaw += 360.0f; } break; - } } return yaw; } @@ -328,40 +324,40 @@ public class TurtleBrain implements ITurtleAccess @Override public Direction getDirection() { - return this.owner.getDirection(); + return owner.getDirection(); } @Override public void setDirection( @Nonnull Direction dir ) { - this.owner.setDirection( dir ); + owner.setDirection( dir ); } @Override public int getSelectedSlot() { - return this.selectedSlot; + return selectedSlot; } @Override public void setSelectedSlot( int slot ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot set the slot on the client" ); } - if( slot >= 0 && slot < this.owner.size() ) + if( slot >= 0 && slot < owner.size() ) { - this.selectedSlot = slot; - this.owner.onTileEntityChange(); + selectedSlot = slot; + owner.onTileEntityChange(); } } @Override public int getColour() { - return this.colourHex; + return colourHex; } @Override @@ -369,16 +365,16 @@ public class TurtleBrain implements ITurtleAccess { if( colour >= 0 && colour <= 0xFFFFFF ) { - if( this.colourHex != colour ) + if( colourHex != colour ) { - this.colourHex = colour; - this.owner.updateBlock(); + colourHex = colour; + owner.updateBlock(); } } - else if( this.colourHex != -1 ) + else if( colourHex != -1 ) { - this.colourHex = -1; - this.owner.updateBlock(); + colourHex = -1; + owner.updateBlock(); } } @@ -386,7 +382,7 @@ public class TurtleBrain implements ITurtleAccess @Override public GameProfile getOwningPlayer() { - return this.owningPlayer; + return owningPlayer; } @Override @@ -398,20 +394,20 @@ public class TurtleBrain implements ITurtleAccess @Override public int getFuelLevel() { - return Math.min( this.fuelLevel, this.getFuelLimit() ); + return Math.min( fuelLevel, getFuelLimit() ); } @Override public void setFuelLevel( int level ) { - this.fuelLevel = Math.min( level, this.getFuelLimit() ); - this.owner.onTileEntityChange(); + fuelLevel = Math.min( level, getFuelLimit() ); + owner.onTileEntityChange(); } @Override public int getFuelLimit() { - if( this.owner.getFamily() == ComputerFamily.ADVANCED ) + if( owner.getFamily() == ComputerFamily.ADVANCED ) { return ComputerCraft.advancedTurtleFuelLimit; } @@ -424,20 +420,20 @@ public class TurtleBrain implements ITurtleAccess @Override public boolean consumeFuel( int fuel ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot consume fuel on the client" ); } - if( !this.isFuelNeeded() ) + if( !isFuelNeeded() ) { return true; } int consumption = Math.max( fuel, 0 ); - if( this.getFuelLevel() >= consumption ) + if( getFuelLevel() >= consumption ) { - this.setFuelLevel( this.getFuelLevel() - consumption ); + setFuelLevel( getFuelLevel() - consumption ); return true; } return false; @@ -446,39 +442,39 @@ public class TurtleBrain implements ITurtleAccess @Override public void addFuel( int fuel ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot add fuel on the client" ); } int addition = Math.max( fuel, 0 ); - this.setFuelLevel( this.getFuelLevel() + addition ); + setFuelLevel( getFuelLevel() + addition ); } @Nonnull @Override public MethodResult executeCommand( @Nonnull ITurtleCommand command ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot run commands on the client" ); } // Issue command - int commandID = this.issueCommand( command ); + int commandID = issueCommand( command ); return new CommandCallback( commandID ).pull; } private int issueCommand( ITurtleCommand command ) { - this.commandQueue.offer( new TurtleCommandQueueEntry( ++this.commandsIssued, command ) ); - return this.commandsIssued; + commandQueue.offer( new TurtleCommandQueueEntry( ++commandsIssued, command ) ); + return commandsIssued; } @Override public void playAnimation( @Nonnull TurtleAnimation animation ) { - if( this.getWorld().isClient ) + if( getWorld().isClient ) { throw new UnsupportedOperationException( "Cannot play animations on the client" ); } @@ -486,34 +482,34 @@ public class TurtleBrain implements ITurtleAccess this.animation = animation; if( this.animation == TurtleAnimation.SHORT_WAIT ) { - this.animationProgress = ANIM_DURATION / 2; - this.lastAnimationProgress = ANIM_DURATION / 2; + animationProgress = ANIM_DURATION / 2; + lastAnimationProgress = ANIM_DURATION / 2; } else { - this.animationProgress = 0; - this.lastAnimationProgress = 0; + animationProgress = 0; + lastAnimationProgress = 0; } - this.owner.updateBlock(); + owner.updateBlock(); } @Override public ITurtleUpgrade getUpgrade( @Nonnull TurtleSide side ) { - return this.upgrades.get( side ); + return upgrades.get( side ); } @Override public void setUpgrade( @Nonnull TurtleSide side, ITurtleUpgrade upgrade ) { // Remove old upgrade - if( this.upgrades.containsKey( side ) ) + if( upgrades.containsKey( side ) ) { - if( this.upgrades.get( side ) == upgrade ) + if( upgrades.get( side ) == upgrade ) { return; } - this.upgrades.remove( side ); + upgrades.remove( side ); } else { @@ -523,36 +519,36 @@ public class TurtleBrain implements ITurtleAccess } } - this.upgradeNBTData.remove( side ); + upgradeNBTData.remove( side ); // Set new upgrade if( upgrade != null ) { - this.upgrades.put( side, upgrade ); + upgrades.put( side, upgrade ); } // Notify clients and create peripherals - if( this.owner.getWorld() != null ) + if( owner.getWorld() != null ) { - this.updatePeripherals( this.owner.createServerComputer() ); - this.owner.updateBlock(); + updatePeripherals( owner.createServerComputer() ); + owner.updateBlock(); } } @Override public IPeripheral getPeripheral( @Nonnull TurtleSide side ) { - return this.peripherals.get( side ); + return peripherals.get( side ); } @Nonnull @Override public CompoundTag getUpgradeNBTData( TurtleSide side ) { - CompoundTag nbt = this.upgradeNBTData.get( side ); + CompoundTag nbt = upgradeNBTData.get( side ); if( nbt == null ) { - this.upgradeNBTData.put( side, nbt = new CompoundTag() ); + upgradeNBTData.put( side, nbt = new CompoundTag() ); } return nbt; } @@ -560,30 +556,30 @@ public class TurtleBrain implements ITurtleAccess @Override public void updateUpgradeNBTData( @Nonnull TurtleSide side ) { - this.owner.updateBlock(); + owner.updateBlock(); } @Nonnull @Override public Inventory getInventory() { - return this.inventory; + return inventory; } public void setOwningPlayer( GameProfile profile ) { - this.owningPlayer = profile; + owningPlayer = profile; } private void updateCommands() { - if( this.animation != TurtleAnimation.NONE || this.commandQueue.isEmpty() ) + if( animation != TurtleAnimation.NONE || commandQueue.isEmpty() ) { return; } // If we've got a computer, ensure that we're allowed to perform work. - ServerComputer computer = this.owner.getServerComputer(); + ServerComputer computer = owner.getServerComputer(); if( computer != null && !computer.getComputer() .getMainThreadMonitor() .canWork() ) @@ -592,7 +588,7 @@ public class TurtleBrain implements ITurtleAccess } // Pull a new command - TurtleCommandQueueEntry nextCommand = this.commandQueue.poll(); + TurtleCommandQueueEntry nextCommand = commandQueue.poll(); if( nextCommand == null ) { return; @@ -648,25 +644,25 @@ public class TurtleBrain implements ITurtleAccess private void updateAnimation() { - if( this.animation != TurtleAnimation.NONE ) + if( animation != TurtleAnimation.NONE ) { - World world = this.getWorld(); + World world = getWorld(); if( ComputerCraft.turtlesCanPush ) { // Advance entity pushing - if( this.animation == TurtleAnimation.MOVE_FORWARD || this.animation == TurtleAnimation.MOVE_BACK || this.animation == TurtleAnimation.MOVE_UP || this.animation == TurtleAnimation.MOVE_DOWN ) + if( animation == TurtleAnimation.MOVE_FORWARD || animation == TurtleAnimation.MOVE_BACK || animation == TurtleAnimation.MOVE_UP || animation == TurtleAnimation.MOVE_DOWN ) { - BlockPos pos = this.getPosition(); + BlockPos pos = getPosition(); Direction moveDir; - switch( this.animation ) + switch( animation ) { case MOVE_FORWARD: default: - moveDir = this.getDirection(); + moveDir = getDirection(); break; case MOVE_BACK: - moveDir = this.getDirection().getOpposite(); + moveDir = getDirection().getOpposite(); break; case MOVE_UP: moveDir = Direction.UP; @@ -683,7 +679,7 @@ public class TurtleBrain implements ITurtleAccess double maxY = minY + 1.0; double maxZ = minZ + 1.0; - float pushFrac = 1.0f - (float) (this.animationProgress + 1) / ANIM_DURATION; + float pushFrac = 1.0f - (float) (animationProgress + 1) / ANIM_DURATION; float push = Math.max( pushFrac + 0.0125f, 0.0f ); if( moveDir.getOffsetX() < 0 ) { @@ -729,13 +725,13 @@ public class TurtleBrain implements ITurtleAccess } // Advance valentines day easter egg - if( world.isClient && this.animation == TurtleAnimation.MOVE_FORWARD && this.animationProgress == 4 ) + if( world.isClient && animation == TurtleAnimation.MOVE_FORWARD && animationProgress == 4 ) { // Spawn love pfx if valentines day Holiday currentHoliday = HolidayUtil.getCurrentHoliday(); if( currentHoliday == Holiday.VALENTINES ) { - Vec3d position = this.getVisualPosition( 1.0f ); + Vec3d position = getVisualPosition( 1.0f ); if( position != null ) { double x = position.x + world.random.nextGaussian() * 0.1; @@ -753,35 +749,34 @@ public class TurtleBrain implements ITurtleAccess } // Wait for anim completion - this.lastAnimationProgress = this.animationProgress; - if( ++this.animationProgress >= ANIM_DURATION ) + lastAnimationProgress = animationProgress; + if( ++animationProgress >= ANIM_DURATION ) { - this.animation = TurtleAnimation.NONE; - this.animationProgress = 0; - this.lastAnimationProgress = 0; + animation = TurtleAnimation.NONE; + animationProgress = 0; + lastAnimationProgress = 0; } } } public Vec3d getRenderOffset( float f ) { - switch( this.animation ) + switch( animation ) { case MOVE_FORWARD: case MOVE_BACK: case MOVE_UP: case MOVE_DOWN: - { // Get direction Direction dir; - switch( this.animation ) + switch( animation ) { case MOVE_FORWARD: default: - dir = this.getDirection(); + dir = getDirection(); break; case MOVE_BACK: - dir = this.getDirection().getOpposite(); + dir = getDirection().getOpposite(); break; case MOVE_UP: dir = Direction.UP; @@ -791,39 +786,36 @@ public class TurtleBrain implements ITurtleAccess break; } - double distance = -1.0 + this.getAnimationFraction( f ); + double distance = -1.0 + getAnimationFraction( f ); return new Vec3d( distance * dir.getOffsetX(), distance * dir.getOffsetY(), distance * dir.getOffsetZ() ); - } default: - { return Vec3d.ZERO; - } } } private float getAnimationFraction( float f ) { - float next = (float) this.animationProgress / ANIM_DURATION; - float previous = (float) this.lastAnimationProgress / ANIM_DURATION; + float next = (float) animationProgress / ANIM_DURATION; + float previous = (float) lastAnimationProgress / ANIM_DURATION; return previous + (next - previous) * f; } public void readFromNBT( CompoundTag nbt ) { - this.readCommon( nbt ); + readCommon( nbt ); // Read state - this.selectedSlot = nbt.getInt( NBT_SLOT ); + selectedSlot = nbt.getInt( NBT_SLOT ); // Read owner if( nbt.contains( "Owner", NBTUtil.TAG_COMPOUND ) ) { CompoundTag owner = nbt.getCompound( "Owner" ); - this.owningPlayer = new GameProfile( new UUID( owner.getLong( "UpperId" ), owner.getLong( "LowerId" ) ), owner.getString( "Name" ) ); + owningPlayer = new GameProfile( new UUID( owner.getLong( "UpperId" ), owner.getLong( "LowerId" ) ), owner.getString( "Name" ) ); } else { - this.owningPlayer = null; + owningPlayer = null; } } @@ -835,25 +827,25 @@ public class TurtleBrain implements ITurtleAccess private void readCommon( CompoundTag nbt ) { // Read fields - this.colourHex = nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : -1; - this.fuelLevel = nbt.contains( NBT_FUEL ) ? nbt.getInt( NBT_FUEL ) : 0; - this.overlay = nbt.contains( NBT_OVERLAY ) ? new Identifier( nbt.getString( NBT_OVERLAY ) ) : null; + colourHex = nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : -1; + fuelLevel = nbt.contains( NBT_FUEL ) ? nbt.getInt( NBT_FUEL ) : 0; + overlay = nbt.contains( NBT_OVERLAY ) ? new Identifier( nbt.getString( NBT_OVERLAY ) ) : null; // Read upgrades - this.setUpgrade( TurtleSide.LEFT, nbt.contains( NBT_LEFT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_LEFT_UPGRADE ) ) : null ); - this.setUpgrade( TurtleSide.RIGHT, nbt.contains( NBT_RIGHT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_RIGHT_UPGRADE ) ) : null ); + setUpgrade( TurtleSide.LEFT, nbt.contains( NBT_LEFT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_LEFT_UPGRADE ) ) : null ); + setUpgrade( TurtleSide.RIGHT, nbt.contains( NBT_RIGHT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_RIGHT_UPGRADE ) ) : null ); // NBT - this.upgradeNBTData.clear(); + upgradeNBTData.clear(); if( nbt.contains( NBT_LEFT_UPGRADE_DATA ) ) { - this.upgradeNBTData.put( TurtleSide.LEFT, + upgradeNBTData.put( TurtleSide.LEFT, nbt.getCompound( NBT_LEFT_UPGRADE_DATA ) .copy() ); } if( nbt.contains( NBT_RIGHT_UPGRADE_DATA ) ) { - this.upgradeNBTData.put( TurtleSide.RIGHT, + upgradeNBTData.put( TurtleSide.RIGHT, nbt.getCompound( NBT_RIGHT_UPGRADE_DATA ) .copy() ); } @@ -861,22 +853,22 @@ public class TurtleBrain implements ITurtleAccess public CompoundTag writeToNBT( CompoundTag nbt ) { - this.writeCommon( nbt ); + writeCommon( nbt ); // Write state - nbt.putInt( NBT_SLOT, this.selectedSlot ); + nbt.putInt( NBT_SLOT, selectedSlot ); // Write owner - if( this.owningPlayer != null ) + if( owningPlayer != null ) { CompoundTag owner = new CompoundTag(); nbt.put( "Owner", owner ); - owner.putLong( "UpperId", this.owningPlayer.getId() + owner.putLong( "UpperId", owningPlayer.getId() .getMostSignificantBits() ); - owner.putLong( "LowerId", this.owningPlayer.getId() + owner.putLong( "LowerId", owningPlayer.getId() .getLeastSignificantBits() ); - owner.putString( "Name", this.owningPlayer.getName() ); + owner.putString( "Name", owningPlayer.getName() ); } return nbt; @@ -884,38 +876,38 @@ public class TurtleBrain implements ITurtleAccess private void writeCommon( CompoundTag nbt ) { - nbt.putInt( NBT_FUEL, this.fuelLevel ); - if( this.colourHex != -1 ) + nbt.putInt( NBT_FUEL, fuelLevel ); + if( colourHex != -1 ) { - nbt.putInt( NBT_COLOUR, this.colourHex ); + nbt.putInt( NBT_COLOUR, colourHex ); } - if( this.overlay != null ) + if( overlay != null ) { - nbt.putString( NBT_OVERLAY, this.overlay.toString() ); + nbt.putString( NBT_OVERLAY, overlay.toString() ); } // Write upgrades - String leftUpgradeId = getUpgradeId( this.getUpgrade( TurtleSide.LEFT ) ); + String leftUpgradeId = getUpgradeId( getUpgrade( TurtleSide.LEFT ) ); if( leftUpgradeId != null ) { nbt.putString( NBT_LEFT_UPGRADE, leftUpgradeId ); } - String rightUpgradeId = getUpgradeId( this.getUpgrade( TurtleSide.RIGHT ) ); + String rightUpgradeId = getUpgradeId( getUpgrade( TurtleSide.RIGHT ) ); if( rightUpgradeId != null ) { nbt.putString( NBT_RIGHT_UPGRADE, rightUpgradeId ); } // Write upgrade NBT - if( this.upgradeNBTData.containsKey( TurtleSide.LEFT ) ) + if( upgradeNBTData.containsKey( TurtleSide.LEFT ) ) { nbt.put( NBT_LEFT_UPGRADE_DATA, - this.getUpgradeNBTData( TurtleSide.LEFT ).copy() ); + getUpgradeNBTData( TurtleSide.LEFT ).copy() ); } - if( this.upgradeNBTData.containsKey( TurtleSide.RIGHT ) ) + if( upgradeNBTData.containsKey( TurtleSide.RIGHT ) ) { nbt.put( NBT_RIGHT_UPGRADE_DATA, - this.getUpgradeNBTData( TurtleSide.RIGHT ).copy() ); + getUpgradeNBTData( TurtleSide.RIGHT ).copy() ); } } @@ -927,27 +919,27 @@ public class TurtleBrain implements ITurtleAccess public void readDescription( CompoundTag nbt ) { - this.readCommon( nbt ); + readCommon( nbt ); // Animation TurtleAnimation anim = TurtleAnimation.values()[nbt.getInt( "Animation" )]; - if( anim != this.animation && anim != TurtleAnimation.WAIT && anim != TurtleAnimation.SHORT_WAIT && anim != TurtleAnimation.NONE ) + if( anim != animation && anim != TurtleAnimation.WAIT && anim != TurtleAnimation.SHORT_WAIT && anim != TurtleAnimation.NONE ) { - this.animation = anim; - this.animationProgress = 0; - this.lastAnimationProgress = 0; + animation = anim; + animationProgress = 0; + lastAnimationProgress = 0; } } public void writeDescription( CompoundTag nbt ) { - this.writeCommon( nbt ); - nbt.putInt( "Animation", this.animation.ordinal() ); + writeCommon( nbt ); + nbt.putInt( "Animation", animation.ordinal() ); } public Identifier getOverlay() { - return this.overlay; + return overlay; } public void setOverlay( Identifier overlay ) @@ -955,17 +947,17 @@ public class TurtleBrain implements ITurtleAccess if( !Objects.equal( this.overlay, overlay ) ) { this.overlay = overlay; - this.owner.updateBlock(); + owner.updateBlock(); } } public DyeColor getDyeColour() { - if( this.colourHex == -1 ) + if( colourHex == -1 ) { return null; } - Colour colour = Colour.fromHex( this.colourHex ); + Colour colour = Colour.fromHex( colourHex ); return colour == null ? null : DyeColor.byId( 15 - colour.ordinal() ); } @@ -976,17 +968,17 @@ public class TurtleBrain implements ITurtleAccess { newColour = Colour.values()[15 - dyeColour.getId()].getHex(); } - if( this.colourHex != newColour ) + if( colourHex != newColour ) { - this.colourHex = newColour; - this.owner.updateBlock(); + colourHex = newColour; + owner.updateBlock(); } } public float getToolRenderAngle( TurtleSide side, float f ) { - return (side == TurtleSide.LEFT && this.animation == TurtleAnimation.SWING_LEFT_TOOL) || (side == TurtleSide.RIGHT && this.animation == TurtleAnimation.SWING_RIGHT_TOOL) ? 45.0f * (float) Math.sin( - this.getAnimationFraction( f ) * Math.PI ) : 0.0f; + return (side == TurtleSide.LEFT && animation == TurtleAnimation.SWING_LEFT_TOOL) || (side == TurtleSide.RIGHT && animation == TurtleAnimation.SWING_RIGHT_TOOL) ? 45.0f * (float) Math.sin( + getAnimationFraction( f ) * Math.PI ) : 0.0f; } private static final class CommandCallback implements ILuaCallback @@ -1005,12 +997,12 @@ public class TurtleBrain implements ITurtleAccess { if( response.length < 3 || !(response[1] instanceof Number) || !(response[2] instanceof Boolean) ) { - return this.pull; + return pull; } - if( ((Number) response[1]).intValue() != this.command ) + if( ((Number) response[1]).intValue() != command ) { - return this.pull; + return pull; } return MethodResult.of( Arrays.copyOfRange( response, 2, response.length ) ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java index 10297aea9..e5a638828 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java @@ -30,7 +30,7 @@ public class TurtleCompareToCommand implements ITurtleCommand ItemStack selectedStack = turtle.getInventory() .getStack( turtle.getSelectedSlot() ); ItemStack stack = turtle.getInventory() - .getStack( this.slot ); + .getStack( slot ); if( InventoryUtil.areItemsStackable( selectedStack, stack ) ) { return TurtleCommandResult.success(); diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java index 2cbfbedf4..8b6d63e17 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java @@ -33,7 +33,7 @@ public class TurtleCraftCommand implements ITurtleCommand { // Craft the item TurtleInventoryCrafting crafting = new TurtleInventoryCrafting( turtle ); - List results = crafting.doCrafting( turtle.getWorld(), this.limit ); + List results = crafting.doCrafting( turtle.getWorld(), limit ); if( results == null ) { return TurtleCommandResult.failure( "No matching recipes" ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java index 94b4a52bf..bd53b9c66 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java @@ -39,7 +39,7 @@ public class TurtleDropCommand implements ITurtleCommand public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle ) { // Dropping nothing is easy - if( this.quantity == 0 ) + if( quantity == 0 ) { turtle.playAnimation( TurtleAnimation.WAIT ); return TurtleCommandResult.success(); @@ -49,7 +49,7 @@ public class TurtleDropCommand implements ITurtleCommand Direction direction = this.direction.toWorldDir( turtle ); // Get things to drop - ItemStack stack = InventoryUtil.takeItems( this.quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() ); + ItemStack stack = InventoryUtil.takeItems( quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() ); if( stack.isEmpty() ) { return TurtleCommandResult.failure( "No items to drop" ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java index 58fb06c8b..d289efc40 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java @@ -55,7 +55,7 @@ public class TurtleEquipCommand implements ITurtleCommand // Determine the upgrade to replace ItemStack oldUpgradeStack; - ITurtleUpgrade oldUpgrade = turtle.getUpgrade( this.side ); + ITurtleUpgrade oldUpgrade = turtle.getUpgrade( side ); if( oldUpgrade != null ) { ItemStack craftingItem = oldUpgrade.getCraftingItem(); @@ -89,7 +89,7 @@ public class TurtleEquipCommand implements ITurtleCommand WorldUtil.dropItemStack( remainder, turtle.getWorld(), position, turtle.getDirection() ); } } - turtle.setUpgrade( this.side, newUpgrade ); + turtle.setUpgrade( side, newUpgrade ); // Animate if( newUpgrade != null || oldUpgrade != null ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index 93a406a86..bc909ea91 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -46,7 +46,7 @@ public class TurtlePlaceCommand implements ITurtleCommand public TurtlePlaceCommand( InteractDirection direction, Object[] arguments ) { this.direction = direction; - this.extraArguments = arguments; + extraArguments = arguments; } public static ItemStack deploy( @Nonnull ItemStack stack, ITurtleAccess turtle, Direction direction, Object[] extraArguments, String[] outErrorMessage ) @@ -89,7 +89,7 @@ public class TurtlePlaceCommand implements ITurtleCommand // Do the deploying String[] errorMessage = new String[1]; - ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, this.extraArguments, errorMessage ); + ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, extraArguments, errorMessage ); if( remainder != stack ) { // Put the remaining items back diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java index fff1e67bd..1d8d05718 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlayer.java @@ -75,20 +75,20 @@ public final class TurtlePlayer extends FakePlayer private void setState( ITurtleAccess turtle ) { - if( this.currentScreenHandler != playerScreenHandler ) + if( currentScreenHandler != playerScreenHandler ) { - ComputerCraft.log.warn( "Turtle has open container ({})", this.currentScreenHandler ); + ComputerCraft.log.warn( "Turtle has open container ({})", currentScreenHandler ); closeHandledScreen(); } BlockPos position = turtle.getPosition(); - this.setPos( position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5 ); + setPos( position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5 ); - this.yaw = turtle.getDirection() + yaw = turtle.getDirection() .asRotation(); - this.pitch = 0.0f; + pitch = 0.0f; - this.inventory.clear(); + inventory.clear(); } public static TurtlePlayer get( ITurtleAccess access ) @@ -112,23 +112,23 @@ public final class TurtlePlayer extends FakePlayer public void loadInventory( @Nonnull ItemStack currentStack ) { // Load up the fake inventory - this.inventory.selectedSlot = 0; - this.inventory.setStack( 0, currentStack ); + inventory.selectedSlot = 0; + inventory.setStack( 0, currentStack ); } public ItemStack unloadInventory( ITurtleAccess turtle ) { // Get the item we placed with - ItemStack results = this.inventory.getStack( 0 ); - this.inventory.setStack( 0, ItemStack.EMPTY ); + ItemStack results = inventory.getStack( 0 ); + inventory.setStack( 0, ItemStack.EMPTY ); // Store (or drop) anything else we found BlockPos dropPosition = turtle.getPosition(); Direction dropDirection = turtle.getDirection() .getOpposite(); - for( int i = 0; i < this.inventory.size(); i++ ) + for( int i = 0; i < inventory.size(); i++ ) { - ItemStack stack = this.inventory.getStack( i ); + ItemStack stack = inventory.getStack( i ); if( !stack.isEmpty() ) { ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getItemHandler(), turtle.getSelectedSlot() ); @@ -136,10 +136,10 @@ public final class TurtlePlayer extends FakePlayer { WorldUtil.dropItemStack( remainder, turtle.getWorld(), dropPosition, dropDirection ); } - this.inventory.setStack( i, ItemStack.EMPTY ); + inventory.setStack( i, ItemStack.EMPTY ); } } - this.inventory.markDirty(); + inventory.markDirty(); return results; } @@ -159,7 +159,7 @@ public final class TurtlePlayer extends FakePlayer @Override public Vec3d getPos() { - return new Vec3d( this.getX(), this.getY(), this.getZ() ); + return new Vec3d( getX(), getY(), getZ() ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java index 37d998c3c..d97e28ad8 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java @@ -47,10 +47,10 @@ public class TurtleRefuelCommand implements ITurtleCommand return TurtleCommandResult.failure( "Items not combustible" ); } - if( this.limit != 0 ) + if( limit != 0 ) { turtle.addFuel( event.getHandler() - .refuel( turtle, stack, slot, this.limit ) ); + .refuel( turtle, stack, slot, limit ) ); turtle.playAnimation( TurtleAnimation.WAIT ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java index 5a106dca4..cd807af15 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java @@ -42,7 +42,7 @@ public class TurtleSuckCommand implements ITurtleCommand public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle ) { // Sucking nothing is easy - if( this.quantity == 0 ) + if( quantity == 0 ) { turtle.playAnimation( TurtleAnimation.WAIT ); return TurtleCommandResult.success(); @@ -70,7 +70,7 @@ public class TurtleSuckCommand implements ITurtleCommand if( inventory != null ) { // Take from inventory of thing in front - ItemStack stack = InventoryUtil.takeItems( this.quantity, ItemStorage.wrap( inventory ) ); + ItemStack stack = InventoryUtil.takeItems( quantity, ItemStorage.wrap( inventory ) ); if( stack.isEmpty() ) { return TurtleCommandResult.failure( "No items to take" ); @@ -118,9 +118,9 @@ public class TurtleSuckCommand implements ITurtleCommand ItemStack storeStack; ItemStack leaveStack; - if( stack.getCount() > this.quantity ) + if( stack.getCount() > quantity ) { - storeStack = stack.split( this.quantity ); + storeStack = stack.split( quantity ); leaveStack = stack; } else diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java index e875f7e8b..77c679098 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java @@ -54,7 +54,7 @@ public class TurtleToolCommand implements ITurtleCommand continue; } - TurtleCommandResult result = upgrade.useTool( turtle, side, this.verb, this.direction.toWorldDir( turtle ) ); + TurtleCommandResult result = upgrade.useTool( turtle, side, verb, direction.toWorldDir( turtle ) ); if( result.isSuccess() ) { switch( side ) @@ -76,7 +76,7 @@ public class TurtleToolCommand implements ITurtleCommand firstFailure = result; } } - return firstFailure != null ? firstFailure : TurtleCommandResult.failure( "No tool to " + this.verb.name() + return firstFailure != null ? firstFailure : TurtleCommandResult.failure( "No tool to " + verb.name() .toLowerCase( Locale.ROOT ) + " with" ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java index 930969754..608d3196e 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java @@ -23,7 +23,7 @@ public class TurtleTransferToCommand implements ITurtleCommand public TurtleTransferToCommand( int slot, int limit ) { this.slot = slot; - this.quantity = limit; + quantity = limit; } @Nonnull @@ -31,7 +31,7 @@ public class TurtleTransferToCommand implements ITurtleCommand public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle ) { // Take stack - ItemStack stack = InventoryUtil.takeItems( this.quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() ); + ItemStack stack = InventoryUtil.takeItems( quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() ); if( stack.isEmpty() ) { turtle.playAnimation( TurtleAnimation.WAIT ); @@ -39,7 +39,7 @@ public class TurtleTransferToCommand implements ITurtleCommand } // Store stack - ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getItemHandler(), this.slot, 1, this.slot ); + ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getItemHandler(), slot, 1, slot ); if( !remainder.isEmpty() ) { // Put the remainder back diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java index 5f3f9ee5e..fd669ac8d 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java @@ -35,26 +35,20 @@ public class TurtleTurnCommand implements ITurtleCommand return TurtleCommandResult.failure( event.getFailureMessage() ); } - switch( this.direction ) + switch( direction ) { case LEFT: - { turtle.setDirection( turtle.getDirection() .rotateYCounterclockwise() ); turtle.playAnimation( TurtleAnimation.TURN_LEFT ); return TurtleCommandResult.success(); - } case RIGHT: - { turtle.setDirection( turtle.getDirection() .rotateYClockwise() ); turtle.playAnimation( TurtleAnimation.TURN_RIGHT ); return TurtleCommandResult.success(); - } default: - { return TurtleCommandResult.failure( "Unknown direction" ); - } } } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java index 487d11434..f090722b8 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/inventory/ContainerTurtle.java @@ -53,14 +53,14 @@ public class ContainerTurtle extends ContainerComputerBase super( ComputerCraftRegistry.ModContainers.TURTLE, id, canUse, computer, family ); this.properties = properties; - this.addProperties( properties ); + addProperties( properties ); // Turtle inventory for( int y = 0; y < 4; y++ ) { for( int x = 0; x < 4; x++ ) { - this.addSlot( new Slot( inventory, x + y * 4, TURTLE_START_X + 1 + x * 18, PLAYER_START_Y + 1 + y * 18 ) ); + addSlot( new Slot( inventory, x + y * 4, TURTLE_START_X + 1 + x * 18, PLAYER_START_Y + 1 + y * 18 ) ); } } @@ -69,14 +69,14 @@ public class ContainerTurtle extends ContainerComputerBase { for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( playerInventory, x + y * 9 + 9, 8 + x * 18, PLAYER_START_Y + 1 + y * 18 ) ); + addSlot( new Slot( playerInventory, x + y * 9 + 9, 8 + x * 18, PLAYER_START_Y + 1 + y * 18 ) ); } } // Player hotbar for( int x = 0; x < 9; x++ ) { - this.addSlot( new Slot( playerInventory, x, 8 + x * 18, PLAYER_START_Y + 3 * 18 + 5 ) ); + addSlot( new Slot( playerInventory, x, 8 + x * 18, PLAYER_START_Y + 3 * 18 + 5 ) ); } } @@ -98,7 +98,7 @@ public class ContainerTurtle extends ContainerComputerBase public int getSelectedSlot() { - return this.properties.get( 0 ); + return properties.get( 0 ); } @Nonnull @@ -107,11 +107,11 @@ public class ContainerTurtle extends ContainerComputerBase { if( slotNum >= 0 && slotNum < 16 ) { - return this.tryItemMerge( player, slotNum, 16, 52, true ); + return tryItemMerge( player, slotNum, 16, 52, true ); } else if( slotNum >= 16 ) { - return this.tryItemMerge( player, slotNum, 0, 16, false ); + return tryItemMerge( player, slotNum, 0, 16, false ); } return ItemStack.EMPTY; } @@ -119,13 +119,13 @@ public class ContainerTurtle extends ContainerComputerBase @Nonnull private ItemStack tryItemMerge( PlayerEntity player, int slotNum, int firstSlot, int lastSlot, boolean reverse ) { - Slot slot = this.slots.get( slotNum ); + Slot slot = slots.get( slotNum ); ItemStack originalStack = ItemStack.EMPTY; if( slot != null && slot.hasStack() ) { ItemStack clickedStack = slot.getStack(); originalStack = clickedStack.copy(); - if( !this.insertItem( clickedStack, firstSlot, lastSlot, reverse ) ) + if( !insertItem( clickedStack, firstSlot, lastSlot, reverse ) ) { return ItemStack.EMPTY; } diff --git a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java index 2e9046127..248c2a719 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtle.java @@ -36,17 +36,17 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem @Override public void appendStacks( @Nonnull ItemGroup group, @Nonnull DefaultedList list ) { - if( !this.isIn( group ) ) + if( !isIn( group ) ) { return; } - ComputerFamily family = this.getFamily(); + ComputerFamily family = getFamily(); - list.add( this.create( -1, null, -1, null, null, 0, null ) ); + list.add( create( -1, null, -1, null, null, 0, null ) ); TurtleUpgrades.getVanillaUpgrades() .filter( x -> TurtleUpgrades.suitableForFamily( family, x ) ) - .map( x -> this.create( -1, null, -1, null, x, 0, null ) ) + .map( x -> create( -1, null, -1, null, x, 0, null ) ) .forEach( list::add ); } @@ -98,9 +98,9 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem @Override public Text getName( @Nonnull ItemStack stack ) { - String baseString = this.getTranslationKey( stack ); - ITurtleUpgrade left = this.getUpgrade( stack, TurtleSide.LEFT ); - ITurtleUpgrade right = this.getUpgrade( stack, TurtleSide.RIGHT ); + String baseString = getTranslationKey( stack ); + ITurtleUpgrade left = getUpgrade( stack, TurtleSide.LEFT ); + ITurtleUpgrade right = getUpgrade( stack, TurtleSide.RIGHT ); if( left != null && right != null ) { return new TranslatableText( baseString + ".upgraded_twice", @@ -175,8 +175,8 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem @Override public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family ) { - return TurtleItemFactory.create( this.getComputerID( stack ), this.getLabel( stack ), this.getColour( stack ), - family, this.getUpgrade( stack, TurtleSide.LEFT ), - this.getUpgrade( stack, TurtleSide.RIGHT ), this.getFuelLevel( stack ), this.getOverlay( stack ) ); + return TurtleItemFactory.create( getComputerID( stack ), getLabel( stack ), getColour( stack ), + family, getUpgrade( stack, TurtleSide.LEFT ), + getUpgrade( stack, TurtleSide.RIGHT ), getFuelLevel( stack ), getOverlay( stack ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java index 75e97d9df..3fda22471 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java +++ b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java @@ -21,7 +21,7 @@ import javax.annotation.Nonnull; public final class TurtleRecipe extends ComputerFamilyRecipe { public static final RecipeSerializer SERIALIZER = - new dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe.Serializer() + new ComputerFamilyRecipe.Serializer() { @Override protected TurtleRecipe create( Identifier identifier, String group, int width, int height, DefaultedList ingredients, ItemStack result, ComputerFamily family ) @@ -50,6 +50,6 @@ public final class TurtleRecipe extends ComputerFamilyRecipe int computerID = item.getComputerID( stack ); String label = item.getLabel( stack ); - return TurtleItemFactory.create( computerID, label, -1, this.getFamily(), null, null, 0, null ); + return TurtleItemFactory.create( computerID, label, -1, getFamily(), null, null, 0, null ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java index cbaace61e..fc297291a 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java @@ -41,7 +41,7 @@ public final class TurtleUpgradeRecipe extends SpecialCraftingRecipe @Override public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world ) { - return !this.craft( inventory ).isEmpty(); + return !craft( inventory ).isEmpty(); } @Nonnull diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/CraftingTablePeripheral.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/CraftingTablePeripheral.java index 959ed2b7b..a01195ab2 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/CraftingTablePeripheral.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/CraftingTablePeripheral.java @@ -43,7 +43,7 @@ public class CraftingTablePeripheral implements IPeripheral @Override public Object getTarget() { - return this.turtle; + return turtle; } @Override @@ -60,6 +60,6 @@ public class CraftingTablePeripheral implements IPeripheral { throw new LuaException( "Crafting count " + limit + " out of range" ); } - return this.turtle.executeCommand( new TurtleCraftCommand( limit ) ); + return turtle.executeCommand( new TurtleCraftCommand( limit ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java index d7ebb5576..88d668a87 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleCraftingTable.java @@ -44,17 +44,17 @@ public class TurtleCraftingTable extends AbstractTurtleUpgrade @Environment( EnvType.CLIENT ) public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side ) { - this.loadModelLocations(); - return TransformedModel.of( side == TurtleSide.LEFT ? this.leftModel : this.rightModel ); + loadModelLocations(); + return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel ); } @Environment( EnvType.CLIENT ) private void loadModelLocations() { - if( this.leftModel == null ) + if( leftModel == null ) { - this.leftModel = new ModelIdentifier( "computercraft:turtle_crafting_table_left", "inventory" ); - this.rightModel = new ModelIdentifier( "computercraft:turtle_crafting_table_right", "inventory" ); + leftModel = new ModelIdentifier( "computercraft:turtle_crafting_table_left", "inventory" ); + rightModel = new ModelIdentifier( "computercraft:turtle_crafting_table_right", "inventory" ); } } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleHoe.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleHoe.java index 97d92eaa5..1676455c6 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleHoe.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleHoe.java @@ -46,7 +46,7 @@ public class TurtleHoe extends TurtleTool { if( verb == TurtleVerb.DIG ) { - ItemStack hoe = this.item.copy(); + ItemStack hoe = item.copy(); ItemStack remainder = TurtlePlaceCommand.deploy( hoe, turtle, direction, null, null ); if( remainder != hoe ) { diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java index f6e19fde5..9bd725bfe 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java @@ -37,8 +37,8 @@ public class TurtleInventoryCrafting extends CraftingInventory // avoid throwing any NPEs. super( null, 0, 0 ); this.turtle = turtle; - this.xStart = 0; - this.yStart = 0; + xStart = 0; + yStart = 0; } @Nullable @@ -54,7 +54,7 @@ public class TurtleInventoryCrafting extends CraftingInventory { if( x < this.xStart || x >= this.xStart + 3 || y < this.yStart || y >= this.yStart + 3 ) { - if( !this.turtle.getInventory() + if( !turtle.getInventory() .getStack( x + y * TileTurtle.INVENTORY_WIDTH ) .isEmpty() ) { @@ -65,9 +65,9 @@ public class TurtleInventoryCrafting extends CraftingInventory } // Check the actual crafting - return this.turtle.getWorld() + return turtle.getWorld() .getRecipeManager() - .getFirstMatch( RecipeType.CRAFTING, this, this.turtle.getWorld() ) + .getFirstMatch( RecipeType.CRAFTING, this, turtle.getWorld() ) .orElse( null ); } @@ -80,18 +80,18 @@ public class TurtleInventoryCrafting extends CraftingInventory } // Find out what we can craft - Recipe recipe = this.tryCrafting( 0, 0 ); + Recipe recipe = tryCrafting( 0, 0 ); if( recipe == null ) { - recipe = this.tryCrafting( 0, 1 ); + recipe = tryCrafting( 0, 1 ); } if( recipe == null ) { - recipe = this.tryCrafting( 1, 0 ); + recipe = tryCrafting( 1, 0 ); } if( recipe == null ) { - recipe = this.tryCrafting( 1, 1 ); + recipe = tryCrafting( 1, 1 ); } if( recipe == null ) { @@ -104,7 +104,7 @@ public class TurtleInventoryCrafting extends CraftingInventory return Collections.emptyList(); } - TurtlePlayer player = TurtlePlayer.get( this.turtle ); + TurtlePlayer player = TurtlePlayer.get( turtle ); ArrayList results = new ArrayList<>(); for( int i = 0; i < maxCount && recipe.matches( this, world ); i++ ) @@ -121,13 +121,13 @@ public class TurtleInventoryCrafting extends CraftingInventory for( int slot = 0; slot < remainders.size(); slot++ ) { - ItemStack existing = this.getStack( slot ); + ItemStack existing = getStack( slot ); ItemStack remainder = remainders.get( slot ); if( !existing.isEmpty() ) { - this.removeStack( slot, 1 ); - existing = this.getStack( slot ); + removeStack( slot, 1 ); + existing = getStack( slot ); } if( remainder.isEmpty() ) @@ -139,12 +139,12 @@ public class TurtleInventoryCrafting extends CraftingInventory // afterwards). if( existing.isEmpty() ) { - this.setStack( slot, remainder ); + setStack( slot, remainder ); } else if( ItemStack.areItemsEqualIgnoreDamage( existing, remainder ) && ItemStack.areTagsEqual( existing, remainder ) ) { remainder.increment( existing.getCount() ); - this.setStack( slot, remainder ); + setStack( slot, remainder ); } else { @@ -159,7 +159,7 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public int getMaxCountPerStack() { - return this.turtle.getInventory() + return turtle.getInventory() .getMaxCountPerStack(); } @@ -172,8 +172,8 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public boolean isValid( int i, @Nonnull ItemStack stack ) { - i = this.modifyIndex( i ); - return this.turtle.getInventory() + i = modifyIndex( i ); + return turtle.getInventory() .isValid( i, stack ); } @@ -185,8 +185,8 @@ public class TurtleInventoryCrafting extends CraftingInventory private int modifyIndex( int index ) { - int x = this.xStart + index % this.getWidth(); - int y = this.yStart + index / this.getHeight(); + int x = xStart + index % getWidth(); + int y = yStart + index / getHeight(); return x >= 0 && x < TileTurtle.INVENTORY_WIDTH && y >= 0 && y < TileTurtle.INVENTORY_HEIGHT ? x + y * TileTurtle.INVENTORY_WIDTH : -1; } @@ -195,15 +195,15 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public int size() { - return this.getWidth() * this.getHeight(); + return getWidth() * getHeight(); } @Nonnull @Override public ItemStack getStack( int i ) { - i = this.modifyIndex( i ); - return this.turtle.getInventory() + i = modifyIndex( i ); + return turtle.getInventory() .getStack( i ); } @@ -211,8 +211,8 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public ItemStack removeStack( int i ) { - i = this.modifyIndex( i ); - return this.turtle.getInventory() + i = modifyIndex( i ); + return turtle.getInventory() .removeStack( i ); } @@ -220,16 +220,16 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public ItemStack removeStack( int i, int size ) { - i = this.modifyIndex( i ); - return this.turtle.getInventory() + i = modifyIndex( i ); + return turtle.getInventory() .removeStack( i, size ); } @Override public void setStack( int i, @Nonnull ItemStack stack ) { - i = this.modifyIndex( i ); - this.turtle.getInventory() + i = modifyIndex( i ); + turtle.getInventory() .setStack( i, stack ); } @@ -237,7 +237,7 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public void markDirty() { - this.turtle.getInventory() + turtle.getInventory() .markDirty(); } @@ -251,10 +251,10 @@ public class TurtleInventoryCrafting extends CraftingInventory @Override public void clear() { - for( int i = 0; i < this.size(); i++ ) + for( int i = 0; i < size(); i++ ) { - int j = this.modifyIndex( i ); - this.turtle.getInventory() + int j = modifyIndex( i ); + turtle.getInventory() .setStack( j, ItemStack.EMPTY ); } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java index ed94e0153..1933ee25e 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleModem.java @@ -47,7 +47,7 @@ public class TurtleModem extends AbstractTurtleUpgrade @Override public IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side ) { - return new Peripheral( turtle, this.advanced ); + return new Peripheral( turtle, advanced ); } @Nonnull @@ -62,7 +62,7 @@ public class TurtleModem extends AbstractTurtleUpgrade @Environment( EnvType.CLIENT ) public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side ) { - this.loadModelLocations(); + loadModelLocations(); boolean active = false; if( turtle != null ) @@ -71,27 +71,27 @@ public class TurtleModem extends AbstractTurtleUpgrade active = turtleNBT.contains( "active" ) && turtleNBT.getBoolean( "active" ); } - return side == TurtleSide.LEFT ? TransformedModel.of( active ? this.leftOnModel : this.leftOffModel ) : TransformedModel.of( active ? this.rightOnModel : this.rightOffModel ); + return side == TurtleSide.LEFT ? TransformedModel.of( active ? leftOnModel : leftOffModel ) : TransformedModel.of( active ? rightOnModel : rightOffModel ); } @Environment( EnvType.CLIENT ) private void loadModelLocations() { - if( this.leftOffModel == null ) + if( leftOffModel == null ) { - if( this.advanced ) + if( advanced ) { - this.leftOffModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_off_left", "inventory" ); - this.rightOffModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_off_right", "inventory" ); - this.leftOnModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_on_left", "inventory" ); - this.rightOnModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_on_right", "inventory" ); + leftOffModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_off_left", "inventory" ); + rightOffModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_off_right", "inventory" ); + leftOnModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_on_left", "inventory" ); + rightOnModel = new ModelIdentifier( "computercraft:turtle_modem_advanced_on_right", "inventory" ); } else { - this.leftOffModel = new ModelIdentifier( "computercraft:turtle_modem_normal_off_left", "inventory" ); - this.rightOffModel = new ModelIdentifier( "computercraft:turtle_modem_normal_off_right", "inventory" ); - this.leftOnModel = new ModelIdentifier( "computercraft:turtle_modem_normal_on_left", "inventory" ); - this.rightOnModel = new ModelIdentifier( "computercraft:turtle_modem_normal_on_right", "inventory" ); + leftOffModel = new ModelIdentifier( "computercraft:turtle_modem_normal_off_left", "inventory" ); + rightOffModel = new ModelIdentifier( "computercraft:turtle_modem_normal_off_right", "inventory" ); + leftOnModel = new ModelIdentifier( "computercraft:turtle_modem_normal_on_left", "inventory" ); + rightOnModel = new ModelIdentifier( "computercraft:turtle_modem_normal_on_right", "inventory" ); } } } @@ -130,21 +130,21 @@ public class TurtleModem extends AbstractTurtleUpgrade @Override public World getWorld() { - return this.turtle.getWorld(); + return turtle.getWorld(); } @Nonnull @Override public Vec3d getPosition() { - BlockPos turtlePos = this.turtle.getPosition(); + BlockPos turtlePos = turtle.getPosition(); return new Vec3d( turtlePos.getX(), turtlePos.getY(), turtlePos.getZ() ); } @Override public boolean equals( IPeripheral other ) { - return this == other || (other instanceof Peripheral && ((Peripheral) other).turtle == this.turtle); + return this == other || (other instanceof Peripheral && ((Peripheral) other).turtle == turtle); } } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleShovel.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleShovel.java index 79ce86663..f08164bb2 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleShovel.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleShovel.java @@ -46,7 +46,7 @@ public class TurtleShovel extends TurtleTool { if( verb == TurtleVerb.DIG ) { - ItemStack shovel = this.item.copy(); + ItemStack shovel = item.copy(); ItemStack remainder = TurtlePlaceCommand.deploy( shovel, turtle, direction, null, null ); if( remainder != shovel ) { diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java index 0980e0928..3fbc845ca 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java @@ -46,17 +46,17 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade @Environment( EnvType.CLIENT ) public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side ) { - this.loadModelLocations(); - return TransformedModel.of( side == TurtleSide.LEFT ? this.leftModel : this.rightModel ); + loadModelLocations(); + return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel ); } @Environment( EnvType.CLIENT ) private void loadModelLocations() { - if( this.leftModel == null ) + if( leftModel == null ) { - this.leftModel = new ModelIdentifier( "computercraft:turtle_speaker_upgrade_left", "inventory" ); - this.rightModel = new ModelIdentifier( "computercraft:turtle_speaker_upgrade_right", "inventory" ); + leftModel = new ModelIdentifier( "computercraft:turtle_speaker_upgrade_left", "inventory" ); + rightModel = new ModelIdentifier( "computercraft:turtle_speaker_upgrade_right", "inventory" ); } } @@ -83,20 +83,20 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade @Override public World getWorld() { - return this.turtle.getWorld(); + return turtle.getWorld(); } @Override public Vec3d getPosition() { - BlockPos pos = this.turtle.getPosition(); + BlockPos pos = turtle.getPosition(); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } @Override public boolean equals( IPeripheral other ) { - return this == other || (other instanceof Peripheral && this.turtle == ((Peripheral) other).turtle); + return this == other || (other instanceof Peripheral && turtle == ((Peripheral) other).turtle); } } } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index 45d63752b..777c3b880 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -70,7 +70,7 @@ public class TurtleTool extends AbstractTurtleUpgrade public TurtleTool( Identifier id, ItemStack craftItem, ItemStack toolItem ) { super( id, TurtleUpgradeType.TOOL, craftItem ); - this.item = toolItem; + item = toolItem; } @Override @@ -82,13 +82,8 @@ public class TurtleTool extends AbstractTurtleUpgrade // Check we've not got anything vaguely interesting on the item. We allow other mods to add their // own NBT, with the understanding such details will be lost to the mist of time. if( stack.isDamaged() || stack.hasEnchantments() || stack.hasCustomName() ) return false; - if( tag.contains( "AttributeModifiers", TAG_LIST ) && - !tag.getList( "AttributeModifiers", TAG_COMPOUND ).isEmpty() ) - { - return false; - } - - return true; + return !tag.contains( "AttributeModifiers", TAG_LIST ) || + tag.getList( "AttributeModifiers", TAG_COMPOUND ).isEmpty(); } @Nonnull @@ -98,9 +93,9 @@ public class TurtleTool extends AbstractTurtleUpgrade switch( verb ) { case ATTACK: - return this.attack( turtle, direction, side ); + return attack( turtle, direction, side ); case DIG: - return this.dig( turtle, direction, side ); + return dig( turtle, direction, side ); default: return TurtleCommandResult.failure( "Unsupported action" ); } @@ -112,7 +107,7 @@ public class TurtleTool extends AbstractTurtleUpgrade public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side ) { float xOffset = side == TurtleSide.LEFT ? -0.40625f : 0.40625f; - return TransformedModel.of( this.getCraftingItem(), new AffineTransformation( new Vector3f( xOffset + 1, 0, 1 ), Vector3f.POSITIVE_Y.getDegreesQuaternion( 270 ), new Vector3f( 1, 1, 1 ), Vector3f.POSITIVE_Z.getDegreesQuaternion( 90 ) ) ); + return TransformedModel.of( getCraftingItem(), new AffineTransformation( new Vector3f( xOffset + 1, 0, 1 ), Vector3f.POSITIVE_Y.getDegreesQuaternion( 270 ), new Vector3f( 1, 1, 1 ), Vector3f.POSITIVE_Z.getDegreesQuaternion( 90 ) ) ); } private TurtleCommandResult attack( ITurtleAccess turtle, Direction direction, TurtleSide side ) @@ -132,7 +127,7 @@ public class TurtleTool extends AbstractTurtleUpgrade if( hit != null ) { // Load up the turtle's inventoryf - ItemStack stackCopy = this.item.copy(); + ItemStack stackCopy = item.copy(); turtlePlayer.loadInventory( stackCopy ); Entity hitEntity = hit.getKey(); @@ -162,7 +157,7 @@ public class TurtleTool extends AbstractTurtleUpgrade if( !hitEntity.handleAttack( turtlePlayer ) ) { float damage = (float) turtlePlayer.getAttributeValue( EntityAttributes.GENERIC_ATTACK_DAMAGE ); - damage *= this.getDamageMultiplier(); + damage *= getDamageMultiplier(); if( damage > 0.0f ) { DamageSource source = DamageSource.player( turtlePlayer ); @@ -219,7 +214,7 @@ public class TurtleTool extends AbstractTurtleUpgrade BlockState state = world.getBlockState( blockPosition ); TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction ); - turtlePlayer.loadInventory( this.item.copy() ); + turtlePlayer.loadInventory( item.copy() ); if( ComputerCraft.turtlesObeyBlockProtection ) { @@ -230,7 +225,7 @@ public class TurtleTool extends AbstractTurtleUpgrade } // Check if we can break the block - if( !this.canBreakBlock( state, world, blockPosition, turtlePlayer ) ) + if( !canBreakBlock( state, world, blockPosition, turtlePlayer ) ) { return TurtleCommandResult.failure( "Unbreakable block detected" ); } diff --git a/src/main/java/dan200/computercraft/shared/util/Colour.java b/src/main/java/dan200/computercraft/shared/util/Colour.java index 0f7c2840f..73589ee0f 100644 --- a/src/main/java/dan200/computercraft/shared/util/Colour.java +++ b/src/main/java/dan200/computercraft/shared/util/Colour.java @@ -32,7 +32,7 @@ public enum Colour Colour( int hex ) { this.hex = hex; - this.rgb = new float[] { + rgb = new float[] { ((hex >> 16) & 0xFF) / 255.0f, ((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f, @@ -59,36 +59,36 @@ public enum Colour public int getHex() { - return this.hex; + return hex; } public Colour getNext() { - return VALUES[(this.ordinal() + 1) % 16]; + return VALUES[(ordinal() + 1) % 16]; } public Colour getPrevious() { - return VALUES[(this.ordinal() + 15) % 16]; + return VALUES[(ordinal() + 15) % 16]; } public float[] getRGB() { - return this.rgb; + return rgb; } public float getR() { - return this.rgb[0]; + return rgb[0]; } public float getG() { - return this.rgb[1]; + return rgb[1]; } public float getB() { - return this.rgb[2]; + return rgb[2]; } } diff --git a/src/main/java/dan200/computercraft/shared/util/ColourTracker.java b/src/main/java/dan200/computercraft/shared/util/ColourTracker.java index 3bfe9d062..da0e00bb1 100644 --- a/src/main/java/dan200/computercraft/shared/util/ColourTracker.java +++ b/src/main/java/dan200/computercraft/shared/util/ColourTracker.java @@ -21,16 +21,16 @@ public class ColourTracker public void addColour( float r, float g, float b ) { - this.addColour( (int) (r * 255), (int) (g * 255), (int) (b * 255) ); + addColour( (int) (r * 255), (int) (g * 255), (int) (b * 255) ); } public void addColour( int r, int g, int b ) { - this.total += Math.max( r, Math.max( g, b ) ); - this.totalR += r; - this.totalG += g; - this.totalB += b; - this.count++; + total += Math.max( r, Math.max( g, b ) ); + totalR += r; + totalG += g; + totalB += b; + count++; } public void addColour( DyeColor dye ) @@ -46,11 +46,11 @@ public class ColourTracker public int getColour() { - int avgR = this.totalR / this.count; - int avgG = this.totalG / this.count; - int avgB = this.totalB / this.count; + int avgR = totalR / count; + int avgG = totalG / count; + int avgB = totalB / count; - float avgTotal = (float) this.total / this.count; + float avgTotal = (float) total / count; float avgMax = Math.max( avgR, Math.max( avgG, avgB ) ); avgR = (int) (avgR * avgTotal / avgMax); avgG = (int) (avgG * avgTotal / avgMax); diff --git a/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java b/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java index 6401f7f39..830eb4a5a 100644 --- a/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java +++ b/src/main/java/dan200/computercraft/shared/util/CommentedConfigSpec.java @@ -29,12 +29,13 @@ public class CommentedConfigSpec extends ConfigSpec comment( split( path, '.' ), comment ); } + @Override public int correct( Config config ) { - return correct( config, ( action, path, incorrectValue, correctedValue ) -> { - } ); + return correct( config, ( action, path, incorrectValue, correctedValue ) -> { } ); } + @Override public int correct( Config config, ConfigSpec.CorrectionListener listener ) { int corrections = super.correct( config, listener ); diff --git a/src/main/java/dan200/computercraft/shared/util/Config.java b/src/main/java/dan200/computercraft/shared/util/Config.java index 06dd19fac..241f0282d 100644 --- a/src/main/java/dan200/computercraft/shared/util/Config.java +++ b/src/main/java/dan200/computercraft/shared/util/Config.java @@ -214,7 +214,7 @@ public final class Config serverSpec.defineList( "turtle.disabled_actions", Collections.emptyList(), x -> x instanceof String && getAction( (String) x ) != null ); } - { + { // Terminal sizes serverSpec.comment( "term_sizes", "Configure the size of various computer's terminals.\n" + "Larger terminals require more bandwidth, so use with care." ); diff --git a/src/main/java/dan200/computercraft/shared/util/DefaultSidedInventory.java b/src/main/java/dan200/computercraft/shared/util/DefaultSidedInventory.java index f2b234516..706a0047b 100644 --- a/src/main/java/dan200/computercraft/shared/util/DefaultSidedInventory.java +++ b/src/main/java/dan200/computercraft/shared/util/DefaultSidedInventory.java @@ -18,7 +18,7 @@ public interface DefaultSidedInventory extends DefaultInventory, SidedInventory @Override default boolean canInsert( int slot, @Nonnull ItemStack stack, @Nullable Direction side ) { - return this.isValid( slot, stack ); + return isValid( slot, stack ); } @Override diff --git a/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java b/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java index 3be2298bd..ff41f1f0c 100644 --- a/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java +++ b/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java @@ -341,7 +341,7 @@ public class FakeNetHandler extends ServerPlayNetworkHandler @Override public void disconnect( @Nonnull Text message ) { - this.closeReason = message; + closeReason = message; } @Override @@ -353,14 +353,14 @@ public class FakeNetHandler extends ServerPlayNetworkHandler @Override public PacketListener getPacketListener() { - return this.handler; + return handler; } @Nullable @Override public Text getDisconnectReason() { - return this.closeReason; + return closeReason; } @Override diff --git a/src/main/java/dan200/computercraft/shared/util/FixedPointTileEntityType.java b/src/main/java/dan200/computercraft/shared/util/FixedPointTileEntityType.java index 62bb4ceb0..2890f3540 100644 --- a/src/main/java/dan200/computercraft/shared/util/FixedPointTileEntityType.java +++ b/src/main/java/dan200/computercraft/shared/util/FixedPointTileEntityType.java @@ -48,14 +48,14 @@ public final class FixedPointTileEntityType extends Block private FixedPointSupplier( Supplier block, Function, T> builder ) { - this.factory = new FixedPointTileEntityType<>( block, this ); + factory = new FixedPointTileEntityType<>( block, this ); this.builder = builder; } @Override public T get() { - return this.builder.apply( this.factory ); + return builder.apply( factory ); } } } diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java index 2958e421f..ed2fa79d8 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java @@ -81,7 +81,7 @@ public final class ImpostorRecipe extends ShapedRecipe @Override public String getGroup() { - return this.group; + return group; } @Override diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java index b84e4bfe4..ad54b8c50 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java @@ -31,7 +31,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe public ImpostorShapelessRecipe read( @Nonnull Identifier id, @Nonnull JsonObject json ) { String s = JsonHelper.getString( json, "group", "" ); - DefaultedList ingredients = this.readIngredients( JsonHelper.getArray( json, "ingredients" ) ); + DefaultedList ingredients = readIngredients( JsonHelper.getArray( json, "ingredients" ) ); if( ingredients.isEmpty() ) { @@ -110,7 +110,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe @Override public String getGroup() { - return this.group; + return group; } @Override diff --git a/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java b/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java index f66bb98d4..41af4a582 100644 --- a/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java +++ b/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java @@ -26,7 +26,7 @@ public interface InventoryDelegate extends Inventory @Override default int size() { - return this.getInventory().size(); + return getInventory().size(); } Inventory getInventory(); @@ -34,87 +34,87 @@ public interface InventoryDelegate extends Inventory @Override default boolean isEmpty() { - return this.getInventory().isEmpty(); + return getInventory().isEmpty(); } @Nonnull @Override default ItemStack getStack( int slot ) { - return this.getInventory().getStack( slot ); + return getInventory().getStack( slot ); } @Nonnull @Override default ItemStack removeStack( int slot, int count ) { - return this.getInventory().removeStack( slot, count ); + return getInventory().removeStack( slot, count ); } @Nonnull @Override default ItemStack removeStack( int slot ) { - return this.getInventory().removeStack( slot ); + return getInventory().removeStack( slot ); } @Override default void setStack( int slot, @Nonnull ItemStack stack ) { - this.getInventory().setStack( slot, stack ); + getInventory().setStack( slot, stack ); } @Override default int getMaxCountPerStack() { - return this.getInventory().getMaxCountPerStack(); + return getInventory().getMaxCountPerStack(); } @Override default void markDirty() { - this.getInventory().markDirty(); + getInventory().markDirty(); } @Override default boolean canPlayerUse( @Nonnull PlayerEntity player ) { - return this.getInventory().canPlayerUse( player ); + return getInventory().canPlayerUse( player ); } @Override default void onOpen( @Nonnull PlayerEntity player ) { - this.getInventory().onOpen( player ); + getInventory().onOpen( player ); } @Override default void onClose( @Nonnull PlayerEntity player ) { - this.getInventory().onClose( player ); + getInventory().onClose( player ); } @Override default boolean isValid( int slot, @Nonnull ItemStack stack ) { - return this.getInventory().isValid( slot, stack ); + return getInventory().isValid( slot, stack ); } @Override default int count( @Nonnull Item stack ) { - return this.getInventory().count( stack ); + return getInventory().count( stack ); } @Override default boolean containsAny( @Nonnull Set set ) { - return this.getInventory().containsAny( set ); + return getInventory().containsAny( set ); } @Override default void clear() { - this.getInventory().clear(); + getInventory().clear(); } } diff --git a/src/main/java/dan200/computercraft/shared/util/ItemStorage.java b/src/main/java/dan200/computercraft/shared/util/ItemStorage.java index f0787f61d..0bbd878ca 100644 --- a/src/main/java/dan200/computercraft/shared/util/ItemStorage.java +++ b/src/main/java/dan200/computercraft/shared/util/ItemStorage.java @@ -65,22 +65,22 @@ public interface ItemStorage @Override public int size() { - return this.inventory.size(); + return inventory.size(); } @Override @Nonnull public ItemStack getStack( int slot ) { - return this.inventory.getStack( slot ); + return inventory.getStack( slot ); } @Override @Nonnull public ItemStack take( int slot, int limit, @Nonnull ItemStack filter, boolean simulate ) { - ItemStack existing = this.inventory.getStack( slot ); - if( existing.isEmpty() || !this.canExtract( slot, existing ) || (!filter.isEmpty() && !areStackable( existing, filter )) ) + ItemStack existing = inventory.getStack( slot ); + if( existing.isEmpty() || !canExtract( slot, existing ) || (!filter.isEmpty() && !areStackable( existing, filter )) ) { return ItemStack.EMPTY; } @@ -96,13 +96,13 @@ public interface ItemStorage } else if( existing.getCount() < limit ) { - this.setAndDirty( slot, ItemStack.EMPTY ); + setAndDirty( slot, ItemStack.EMPTY ); return existing; } else { ItemStack result = existing.split( limit ); - this.setAndDirty( slot, existing ); + setAndDirty( slot, existing ); return result; } } @@ -114,23 +114,23 @@ public interface ItemStorage private void setAndDirty( int slot, @Nonnull ItemStack stack ) { - this.inventory.setStack( slot, stack ); - this.inventory.markDirty(); + inventory.setStack( slot, stack ); + inventory.markDirty(); } @Override @Nonnull public ItemStack store( int slot, @Nonnull ItemStack stack, boolean simulate ) { - if( stack.isEmpty() || !this.inventory.isValid( slot, stack ) ) + if( stack.isEmpty() || !inventory.isValid( slot, stack ) ) { return stack; } - ItemStack existing = this.inventory.getStack( slot ); + ItemStack existing = inventory.getStack( slot ); if( existing.isEmpty() ) { - int limit = Math.min( stack.getMaxCount(), this.inventory.getMaxCountPerStack() ); + int limit = Math.min( stack.getMaxCount(), inventory.getMaxCountPerStack() ); if( limit <= 0 ) { return stack; @@ -140,7 +140,7 @@ public interface ItemStorage { if( !simulate ) { - this.setAndDirty( slot, stack ); + setAndDirty( slot, stack ); } return ItemStack.EMPTY; } @@ -150,14 +150,14 @@ public interface ItemStorage ItemStack insert = stack.split( limit ); if( !simulate ) { - this.setAndDirty( slot, insert ); + setAndDirty( slot, insert ); } return stack; } } else if( areStackable( stack, existing ) ) { - int limit = Math.min( existing.getMaxCount(), this.inventory.getMaxCountPerStack() ) - existing.getCount(); + int limit = Math.min( existing.getMaxCount(), inventory.getMaxCountPerStack() ) - existing.getCount(); if( limit <= 0 ) { return stack; @@ -168,7 +168,7 @@ public interface ItemStorage if( !simulate ) { existing.increment( stack.getCount() ); - this.setAndDirty( slot, existing ); + setAndDirty( slot, existing ); } return ItemStack.EMPTY; } @@ -179,7 +179,7 @@ public interface ItemStorage if( !simulate ) { existing.increment( limit ); - this.setAndDirty( slot, existing ); + setAndDirty( slot, existing ); } return stack; } @@ -206,20 +206,20 @@ public interface ItemStorage @Override protected boolean canExtract( int slot, ItemStack stack ) { - return super.canExtract( slot, stack ) && this.inventory.canExtract( slot, stack, this.facing ); + return super.canExtract( slot, stack ) && inventory.canExtract( slot, stack, facing ); } @Override public int size() { - return this.inventory.getAvailableSlots( this.facing ).length; + return inventory.getAvailableSlots( facing ).length; } @Nonnull @Override public ItemStack take( int slot, int limit, @Nonnull ItemStack filter, boolean simulate ) { - int[] slots = this.inventory.getAvailableSlots( this.facing ); + int[] slots = inventory.getAvailableSlots( facing ); return slot >= 0 && slot < slots.length ? super.take( slots[slot], limit, filter, simulate ) : ItemStack.EMPTY; } @@ -227,14 +227,14 @@ public interface ItemStorage @Override public ItemStack store( int slot, @Nonnull ItemStack stack, boolean simulate ) { - int[] slots = this.inventory.getAvailableSlots( this.facing ); + int[] slots = inventory.getAvailableSlots( facing ); if( slot < 0 || slot >= slots.length ) { return stack; } int mappedSlot = slots[slot]; - if( !this.inventory.canInsert( slot, stack, this.facing ) ) + if( !inventory.canInsert( slot, stack, facing ) ) { return stack; } @@ -258,46 +258,46 @@ public interface ItemStorage @Override public int size() { - return this.size; + return size; } @Override @Nonnull public ItemStack getStack( int slot ) { - if( slot < this.start || slot >= this.start + this.size ) + if( slot < start || slot >= start + size ) { return ItemStack.EMPTY; } - return this.parent.getStack( slot - this.start ); + return parent.getStack( slot - start ); } @Nonnull @Override public ItemStack take( int slot, int limit, @Nonnull ItemStack filter, boolean simulate ) { - if( slot < this.start || slot >= this.start + this.size ) + if( slot < start || slot >= start + size ) { return ItemStack.EMPTY; } - return this.parent.take( slot - this.start, limit, filter, simulate ); + return parent.take( slot - start, limit, filter, simulate ); } @Nonnull @Override public ItemStack store( int slot, @Nonnull ItemStack stack, boolean simulate ) { - if( slot < this.start || slot >= this.start + this.size ) + if( slot < start || slot >= start + size ) { return stack; } - return this.parent.store( slot - this.start, stack, simulate ); + return parent.store( slot - start, stack, simulate ); } @Override public ItemStorage view( int start, int size ) { - return new View( this.parent, this.start + start, size ); + return new View( parent, this.start + start, size ); } } } diff --git a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java index 99f39d71c..19dac3a14 100644 --- a/src/main/java/dan200/computercraft/shared/util/NBTUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/NBTUtil.java @@ -117,7 +117,6 @@ public final class NBTUtil case TAG_STRING: return tag.asString(); case TAG_COMPOUND: - { CompoundTag c = (CompoundTag) tag; int len = c.getInt( "len" ); Map map = new HashMap<>( len ); @@ -131,7 +130,6 @@ public final class NBTUtil } } return map; - } } } @@ -190,7 +188,6 @@ public final class NBTUtil return map; } case TAG_INT_ARRAY: - { int[] array = ((IntArrayTag) tag).getIntArray(); Map map = new HashMap<>( array.length ); for( int i = 0; i < array.length; i++ ) @@ -198,7 +195,6 @@ public final class NBTUtil map.put( i + 1, array[i] ); } return map; - } default: return null; @@ -260,13 +256,13 @@ public final class NBTUtil @Override public void write( int b ) { - this.digest.update( (byte) b ); + digest.update( (byte) b ); } @Override public void write( @Nonnull byte[] b, int off, int len ) { - this.digest.update( b, off, len ); + digest.update( b, off, len ); } } } diff --git a/src/main/java/dan200/computercraft/shared/util/Palette.java b/src/main/java/dan200/computercraft/shared/util/Palette.java index 23f5654a0..a7939b8b2 100644 --- a/src/main/java/dan200/computercraft/shared/util/Palette.java +++ b/src/main/java/dan200/computercraft/shared/util/Palette.java @@ -18,52 +18,52 @@ public class Palette public Palette() { // Get the default palette - this.resetColours(); + resetColours(); } public void resetColours() { for( int i = 0; i < Colour.VALUES.length; i++ ) { - this.resetColour( i ); + resetColour( i ); } } public void resetColour( int i ) { - if( i >= 0 && i < this.colours.length ) + if( i >= 0 && i < colours.length ) { - this.setColour( i, Colour.VALUES[i] ); + setColour( i, Colour.VALUES[i] ); } } public void setColour( int i, Colour colour ) { - this.setColour( i, colour.getR(), colour.getG(), colour.getB() ); + setColour( i, colour.getR(), colour.getG(), colour.getB() ); } public void setColour( int i, double r, double g, double b ) { - if( i >= 0 && i < this.colours.length ) + if( i >= 0 && i < colours.length ) { - this.colours[i][0] = r; - this.colours[i][1] = g; - this.colours[i][2] = b; + colours[i][0] = r; + colours[i][1] = g; + colours[i][2] = b; } } public double[] getColour( int i ) { - if( i >= 0 && i < this.colours.length ) + if( i >= 0 && i < colours.length ) { - return this.colours[i]; + return colours[i]; } return null; } public void write( PacketByteBuf buffer ) { - for( double[] colour : this.colours ) + for( double[] colour : colours ) { for( double channel : colour ) { @@ -74,7 +74,7 @@ public class Palette public void read( PacketByteBuf buffer ) { - for( double[] colour : this.colours ) + for( double[] colour : colours ) { for( int i = 0; i < colour.length; i++ ) { @@ -85,11 +85,11 @@ public class Palette public CompoundTag writeToNBT( CompoundTag nbt ) { - int[] rgb8 = new int[this.colours.length]; + int[] rgb8 = new int[colours.length]; - for( int i = 0; i < this.colours.length; i++ ) + for( int i = 0; i < colours.length; i++ ) { - rgb8[i] = encodeRGB8( this.colours[i] ); + rgb8[i] = encodeRGB8( colours[i] ); } nbt.putIntArray( "term_palette", rgb8 ); @@ -113,14 +113,14 @@ public class Palette } int[] rgb8 = nbt.getIntArray( "term_palette" ); - if( rgb8.length != this.colours.length ) + if( rgb8.length != colours.length ) { return; } - for( int i = 0; i < this.colours.length; i++ ) + for( int i = 0; i < colours.length; i++ ) { - this.colours[i] = decodeRGB8( rgb8[i] ); + colours[i] = decodeRGB8( rgb8[i] ); } } diff --git a/src/main/java/dan200/computercraft/shared/util/SingleIntArray.java b/src/main/java/dan200/computercraft/shared/util/SingleIntArray.java index 7479b2e37..4e9141232 100644 --- a/src/main/java/dan200/computercraft/shared/util/SingleIntArray.java +++ b/src/main/java/dan200/computercraft/shared/util/SingleIntArray.java @@ -14,7 +14,7 @@ public interface SingleIntArray extends PropertyDelegate @Override default int get( int property ) { - return property == 0 ? this.get() : 0; + return property == 0 ? get() : 0; } int get(); diff --git a/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java b/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java index 9dd28fa52..ccbf63218 100644 --- a/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java +++ b/src/main/java/dan200/computercraft/shared/wired/WiredNetwork.java @@ -27,8 +27,8 @@ public final class WiredNetwork implements IWiredNetwork WiredNetwork( WiredNode node ) { - this.nodes = new HashSet<>( 1 ); - this.nodes.add( node ); + nodes = new HashSet<>( 1 ); + nodes.add( node ); } private WiredNetwork( HashSet nodes ) @@ -111,11 +111,11 @@ public final class WiredNetwork implements IWiredNetwork throw new IllegalArgumentException( "Cannot add a connection to oneself." ); } - this.lock.writeLock() + lock.writeLock() .lock(); try { - if( this.nodes == null ) + if( nodes == null ) { throw new IllegalStateException( "Cannot add a connection to an empty network." ); } @@ -137,13 +137,13 @@ public final class WiredNetwork implements IWiredNetwork { // Cache several properties for iterating over later Map otherPeripherals = other.peripherals; - Map thisPeripherals = otherPeripherals.isEmpty() ? this.peripherals : new HashMap<>( this.peripherals ); + Map thisPeripherals = otherPeripherals.isEmpty() ? peripherals : new HashMap<>( peripherals ); - Collection thisNodes = otherPeripherals.isEmpty() ? this.nodes : new ArrayList<>( this.nodes ); + Collection thisNodes = otherPeripherals.isEmpty() ? nodes : new ArrayList<>( nodes ); Collection otherNodes = other.nodes; // Move all nodes across into this network, destroying the original nodes. - this.nodes.addAll( otherNodes ); + nodes.addAll( otherNodes ); for( WiredNode node : otherNodes ) { node.network = this; @@ -152,7 +152,7 @@ public final class WiredNetwork implements IWiredNetwork // Move all peripherals across, other.peripherals = null; - this.peripherals.putAll( otherPeripherals ); + peripherals.putAll( otherPeripherals ); if( !thisPeripherals.isEmpty() ) { @@ -187,7 +187,7 @@ public final class WiredNetwork implements IWiredNetwork } finally { - this.lock.writeLock() + lock.writeLock() .unlock(); } } @@ -202,7 +202,7 @@ public final class WiredNetwork implements IWiredNetwork throw new IllegalArgumentException( "Cannot remove a connection to oneself." ); } - this.lock.writeLock() + lock.writeLock() .lock(); try { @@ -256,27 +256,27 @@ public final class WiredNetwork implements IWiredNetwork try { // Remove nodes from this network - this.nodes.removeAll( reachableU ); + nodes.removeAll( reachableU ); // Set network and transfer peripherals for( WiredNode node : reachableU ) { node.network = networkU; networkU.peripherals.putAll( node.peripherals ); - this.peripherals.keySet() + peripherals.keySet() .removeAll( node.peripherals.keySet() ); } // Broadcast changes - if( !this.peripherals.isEmpty() ) + if( !peripherals.isEmpty() ) { - WiredNetworkChange.removed( this.peripherals ) + WiredNetworkChange.removed( peripherals ) .broadcast( networkU.nodes ); } if( !networkU.peripherals.isEmpty() ) { WiredNetworkChange.removed( networkU.peripherals ) - .broadcast( this.nodes ); + .broadcast( nodes ); } InvariantChecker.checkNetwork( this ); @@ -294,7 +294,7 @@ public final class WiredNetwork implements IWiredNetwork } finally { - this.lock.writeLock() + lock.writeLock() .unlock(); } } @@ -304,16 +304,16 @@ public final class WiredNetwork implements IWiredNetwork { WiredNode wired = checkNode( node ); - this.lock.writeLock() + lock.writeLock() .lock(); try { // If we're the empty graph then just abort: nodes must have _some_ network. - if( this.nodes == null ) + if( nodes == null ) { return false; } - if( this.nodes.size() <= 1 ) + if( nodes.size() <= 1 ) { return false; } @@ -325,7 +325,7 @@ public final class WiredNetwork implements IWiredNetwork HashSet neighbours = wired.neighbours; // Remove this node and move into a separate network. - this.nodes.remove( wired ); + nodes.remove( wired ); for( WiredNode neighbour : neighbours ) { neighbour.neighbours.remove( wired ); @@ -338,7 +338,7 @@ public final class WiredNetwork implements IWiredNetwork if( neighbours.size() == 1 ) { // Broadcast our simple peripheral changes - this.removeSingleNode( wired, wiredNetwork ); + removeSingleNode( wired, wiredNetwork ); InvariantChecker.checkNode( wired ); InvariantChecker.checkNetwork( wiredNetwork ); return true; @@ -348,10 +348,10 @@ public final class WiredNetwork implements IWiredNetwork .next() ); // If all nodes are reachable then exit. - if( reachable.size() == this.nodes.size() ) + if( reachable.size() == nodes.size() ) { // Broadcast our simple peripheral changes - this.removeSingleNode( wired, wiredNetwork ); + removeSingleNode( wired, wiredNetwork ); InvariantChecker.checkNode( wired ); InvariantChecker.checkNetwork( wiredNetwork ); return true; @@ -403,7 +403,7 @@ public final class WiredNetwork implements IWiredNetwork // Then broadcast network changes once all nodes are finalised for( WiredNetwork network : maximals ) { - WiredNetworkChange.changeOf( this.peripherals, network.peripherals ) + WiredNetworkChange.changeOf( peripherals, network.peripherals ) .broadcast( network.nodes ); } } @@ -416,14 +416,14 @@ public final class WiredNetwork implements IWiredNetwork } } - this.nodes.clear(); - this.peripherals.clear(); + nodes.clear(); + peripherals.clear(); return true; } finally { - this.lock.writeLock() + lock.writeLock() .unlock(); } } @@ -432,9 +432,9 @@ public final class WiredNetwork implements IWiredNetwork public void updatePeripherals( @Nonnull IWiredNode node, @Nonnull Map newPeripherals ) { WiredNode wired = checkNode( node ); - Objects.requireNonNull( this.peripherals, "peripherals cannot be null" ); + Objects.requireNonNull( peripherals, "peripherals cannot be null" ); - this.lock.writeLock() + lock.writeLock() .lock(); try { @@ -453,18 +453,18 @@ public final class WiredNetwork implements IWiredNetwork wired.peripherals = ImmutableMap.copyOf( newPeripherals ); // Detach the old peripherals then remove them. - this.peripherals.keySet() + peripherals.keySet() .removeAll( change.peripheralsRemoved() .keySet() ); // Add the new peripherals and attach them - this.peripherals.putAll( change.peripheralsAdded() ); + peripherals.putAll( change.peripheralsAdded() ); - change.broadcast( this.nodes ); + change.broadcast( nodes ); } finally { - this.lock.writeLock() + lock.writeLock() .unlock(); } } @@ -485,19 +485,19 @@ public final class WiredNetwork implements IWiredNetwork wired.peripherals = Collections.emptyMap(); // Broadcast the change - if( !this.peripherals.isEmpty() ) + if( !peripherals.isEmpty() ) { - WiredNetworkChange.removed( this.peripherals ) + WiredNetworkChange.removed( peripherals ) .broadcast( wired ); } // Now remove all peripherals from this network and broadcast the change. - this.peripherals.keySet() + peripherals.keySet() .removeAll( wiredPeripherals.keySet() ); if( !wiredPeripherals.isEmpty() ) { WiredNetworkChange.removed( wiredPeripherals ) - .broadcast( this.nodes ); + .broadcast( nodes ); } } @@ -561,7 +561,7 @@ public final class WiredNetwork implements IWiredNetwork public int compareTo( @Nonnull TransmitPoint o ) { // Objects with the same distance are not the same object, so we must add an additional layer of ordering. - return this.distance == o.distance ? Integer.compare( this.node.hashCode(), o.node.hashCode() ) : Double.compare( this.distance, o.distance ); + return distance == o.distance ? Integer.compare( node.hashCode(), o.node.hashCode() ) : Double.compare( distance, o.distance ); } } } diff --git a/src/main/java/dan200/computercraft/shared/wired/WiredNetworkChange.java b/src/main/java/dan200/computercraft/shared/wired/WiredNetworkChange.java index cdaabfc32..fda849f10 100644 --- a/src/main/java/dan200/computercraft/shared/wired/WiredNetworkChange.java +++ b/src/main/java/dan200/computercraft/shared/wired/WiredNetworkChange.java @@ -90,19 +90,19 @@ public final class WiredNetworkChange implements IWiredNetworkChange @Override public Map peripheralsRemoved() { - return this.removed; + return removed; } @Nonnull @Override public Map peripheralsAdded() { - return this.added; + return added; } void broadcast( Iterable nodes ) { - if( !this.isEmpty() ) + if( !isEmpty() ) { for( WiredNode node : nodes ) { @@ -113,12 +113,12 @@ public final class WiredNetworkChange implements IWiredNetworkChange public boolean isEmpty() { - return this.added.isEmpty() && this.removed.isEmpty(); + return added.isEmpty() && removed.isEmpty(); } void broadcast( WiredNode node ) { - if( !this.isEmpty() ) + if( !isEmpty() ) { node.element.networkChanged( this ); } diff --git a/src/main/java/dan200/computercraft/shared/wired/WiredNode.java b/src/main/java/dan200/computercraft/shared/wired/WiredNode.java index fdb5048f0..03cd63820 100644 --- a/src/main/java/dan200/computercraft/shared/wired/WiredNode.java +++ b/src/main/java/dan200/computercraft/shared/wired/WiredNode.java @@ -29,25 +29,25 @@ public final class WiredNode implements IWiredNode public WiredNode( IWiredElement element ) { this.element = element; - this.network = new WiredNetwork( this ); + network = new WiredNetwork( this ); } @Override public synchronized void addReceiver( @Nonnull IPacketReceiver receiver ) { - if( this.receivers == null ) + if( receivers == null ) { - this.receivers = new HashSet<>(); + receivers = new HashSet<>(); } - this.receivers.add( receiver ); + receivers.add( receiver ); } @Override public synchronized void removeReceiver( @Nonnull IPacketReceiver receiver ) { - if( this.receivers != null ) + if( receivers != null ) { - this.receivers.remove( receiver ); + receivers.remove( receiver ); } } @@ -66,14 +66,14 @@ public final class WiredNode implements IWiredNode throw new IllegalArgumentException( "Sender is not in the network" ); } - this.acquireReadLock(); + acquireReadLock(); try { WiredNetwork.transmitPacket( this, packet, range, false ); } finally { - this.network.lock.readLock() + network.lock.readLock() .unlock(); } } @@ -87,26 +87,26 @@ public final class WiredNode implements IWiredNode throw new IllegalArgumentException( "Sender is not in the network" ); } - this.acquireReadLock(); + acquireReadLock(); try { WiredNetwork.transmitPacket( this, packet, 0, true ); } finally { - this.network.lock.readLock() + network.lock.readLock() .unlock(); } } private void acquireReadLock() { - WiredNetwork currentNetwork = this.network; + WiredNetwork currentNetwork = network; while( true ) { Lock lock = currentNetwork.lock.readLock(); lock.lock(); - if( currentNetwork == this.network ) + if( currentNetwork == network ) { return; } @@ -118,12 +118,12 @@ public final class WiredNode implements IWiredNode synchronized void tryTransmit( Packet packet, double packetDistance, boolean packetInterdimensional, double range, boolean interdimensional ) { - if( this.receivers == null ) + if( receivers == null ) { return; } - for( IPacketReceiver receiver : this.receivers ) + for( IPacketReceiver receiver : receivers ) { if( !packetInterdimensional ) { @@ -131,7 +131,7 @@ public final class WiredNode implements IWiredNode if( interdimensional || receiver.isInterdimensional() || packetDistance < receiveRange ) { receiver.receiveSameDimension( packet, - packetDistance + this.element.getPosition() + packetDistance + element.getPosition() .distanceTo( receiver.getPosition() ) ); } } @@ -149,20 +149,20 @@ public final class WiredNode implements IWiredNode @Override public IWiredElement getElement() { - return this.element; + return element; } @Nonnull @Override public IWiredNetwork getNetwork() { - return this.network; + return network; } @Override public String toString() { - return "WiredNode{@" + this.element.getPosition() + " (" + this.element.getClass() + return "WiredNode{@" + element.getPosition() + " (" + element.getClass() .getSimpleName() + ")}"; } }