1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-31 01:27:55 +00:00

Merge pull request #60 from Toad-Dev/linter-fix

Linter fix and removing unnecessary this's
This commit is contained in:
ToadDev
2021-06-12 16:11:04 -07:00
committed by GitHub
200 changed files with 2377 additions and 2416 deletions

View File

@@ -80,11 +80,11 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Override @Override
public String getInstalledVersion() 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 ) .getModContainer( ComputerCraft.MOD_ID )
.map( x -> x.getMetadata() .map( x -> x.getMetadata()
.getVersion() .getVersion()

View File

@@ -38,7 +38,7 @@ public final class TransformedModel
public TransformedModel( @Nonnull BakedModel model ) public TransformedModel( @Nonnull BakedModel model )
{ {
this.model = Objects.requireNonNull( model ); this.model = Objects.requireNonNull( model );
this.matrix = AffineTransformation.identity(); matrix = AffineTransformation.identity();
} }
public static TransformedModel of( @Nonnull ModelIdentifier location ) public static TransformedModel of( @Nonnull ModelIdentifier location )
@@ -60,26 +60,26 @@ public final class TransformedModel
@Nonnull @Nonnull
public BakedModel getModel() public BakedModel getModel()
{ {
return this.model; return model;
} }
@Nonnull @Nonnull
public AffineTransformation getMatrix() public AffineTransformation getMatrix()
{ {
return this.matrix; return matrix;
} }
public void push( MatrixStack matrixStack ) public void push( MatrixStack matrixStack )
{ {
matrixStack.push(); matrixStack.push();
AffineTransformationAccess access = (AffineTransformationAccess) (Object) this.matrix; AffineTransformationAccess access = (AffineTransformationAccess) (Object) matrix;
if( access.getTranslation() != null ) if( access.getTranslation() != null )
{ {
matrixStack.translate( access.getTranslation().getX(), access.getTranslation().getY(), access.getTranslation().getZ() ); matrixStack.translate( access.getTranslation().getX(), access.getTranslation().getY(), access.getTranslation().getZ() );
} }
matrixStack.multiply( this.matrix.getRotation2() ); matrixStack.multiply( matrix.getRotation2() );
if( access.getScale() != null ) if( access.getScale() != null )
{ {

View File

@@ -47,13 +47,13 @@ final class FileAttributes implements BasicFileAttributes
@Override @Override
public boolean isRegularFile() public boolean isRegularFile()
{ {
return !this.isDirectory; return !isDirectory;
} }
@Override @Override
public boolean isDirectory() public boolean isDirectory()
{ {
return this.isDirectory; return isDirectory;
} }
@Override @Override
@@ -71,7 +71,7 @@ final class FileAttributes implements BasicFileAttributes
@Override @Override
public long size() public long size()
{ {
return this.size; return size;
} }
@Override @Override

View File

@@ -31,12 +31,12 @@ public class FileOperationException extends IOException
public FileOperationException( @Nonnull String message ) public FileOperationException( @Nonnull String message )
{ {
super( Objects.requireNonNull( message, "message cannot be null" ) ); super( Objects.requireNonNull( message, "message cannot be null" ) );
this.filename = null; filename = null;
} }
@Nullable @Nullable
public String getFilename() public String getFilename()
{ {
return this.filename; return filename;
} }
} }

View File

@@ -59,11 +59,11 @@ public interface IMount
@Nonnull @Nonnull
default BasicFileAttributes getAttributes( @Nonnull String path ) throws IOException default BasicFileAttributes getAttributes( @Nonnull String path ) throws IOException
{ {
if( !this.exists( path ) ) if( !exists( path ) )
{ {
throw new FileOperationException( path, "No such file" ); throw new FileOperationException( path, "No such file" );
} }
return new FileAttributes( this.isDirectory( path ), this.getSize( path ) ); return new FileAttributes( isDirectory( path ), getSize( path ) );
} }
/** /**

View File

@@ -30,10 +30,10 @@ public interface IArguments
default Object[] getAll() default Object[] getAll()
{ {
Object[] result = new Object[this.count()]; Object[] result = new Object[count()];
for( int i = 0; i < result.length; i++ ) for( int i = 0; i < result.length; i++ )
{ {
result[i] = this.get( i ); result[i] = get( i );
} }
return result; return result;
} }
@@ -71,7 +71,7 @@ public interface IArguments
*/ */
default int getInt( int index ) throws LuaException 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 default long getLong( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( !(value instanceof Number) ) if( !(value instanceof Number) )
{ {
throw LuaValues.badArgumentOf( index, "number", value ); throw LuaValues.badArgumentOf( index, "number", value );
@@ -101,7 +101,7 @@ public interface IArguments
*/ */
default double getFiniteDouble( int index ) throws LuaException 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 default double getDouble( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( !(value instanceof Number) ) if( !(value instanceof Number) )
{ {
throw LuaValues.badArgumentOf( index, "number", value ); throw LuaValues.badArgumentOf( index, "number", value );
@@ -131,7 +131,7 @@ public interface IArguments
*/ */
default boolean getBoolean( int index ) throws LuaException default boolean getBoolean( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( !(value instanceof Boolean) ) if( !(value instanceof Boolean) )
{ {
throw LuaValues.badArgumentOf( index, "boolean", value ); throw LuaValues.badArgumentOf( index, "boolean", value );
@@ -149,7 +149,7 @@ public interface IArguments
@Nonnull @Nonnull
default ByteBuffer getBytes( int index ) throws LuaException 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 @Nonnull
default String getString( int index ) throws LuaException default String getString( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( !(value instanceof String) ) if( !(value instanceof String) )
{ {
throw LuaValues.badArgumentOf( index, "string", value ); throw LuaValues.badArgumentOf( index, "string", value );
@@ -182,7 +182,7 @@ public interface IArguments
@Nonnull @Nonnull
default <T extends Enum<T>> T getEnum( int index, Class<T> klass ) throws LuaException default <T extends Enum<T>> T getEnum( int index, Class<T> 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 @Nonnull
default Map<?, ?> getTable( int index ) throws LuaException default Map<?, ?> getTable( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( !(value instanceof Map) ) if( !(value instanceof Map) )
{ {
throw LuaValues.badArgumentOf( index, "table", value ); throw LuaValues.badArgumentOf( index, "table", value );
@@ -212,7 +212,7 @@ public interface IArguments
*/ */
default Optional<ByteBuffer> optBytes( int index ) throws LuaException default Optional<ByteBuffer> 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<String> optString( int index ) throws LuaException default Optional<String> optString( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( value == null ) if( value == null )
{ {
return Optional.empty(); return Optional.empty();
@@ -248,7 +248,7 @@ public interface IArguments
@Nonnull @Nonnull
default <T extends Enum<T>> Optional<T> optEnum( int index, Class<T> klass ) throws LuaException default <T extends Enum<T>> Optional<T> optEnum( int index, Class<T> klass ) throws LuaException
{ {
Optional<String> str = this.optString( index ); Optional<String> str = optString( index );
return str.isPresent() ? Optional.of( LuaValues.checkEnum( index, klass, str.get() ) ) : Optional.empty(); 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 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 @Nonnull
default Optional<Double> optDouble( int index ) throws LuaException default Optional<Double> optDouble( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( value == null ) if( value == null )
{ {
return Optional.empty(); return Optional.empty();
@@ -297,7 +297,7 @@ public interface IArguments
*/ */
default int optInt( int index, int def ) throws LuaException 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 @Nonnull
default Optional<Integer> optInt( int index ) throws LuaException default Optional<Integer> 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<Long> optLong( int index ) throws LuaException default Optional<Long> optLong( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( value == null ) if( value == null )
{ {
return Optional.empty(); return Optional.empty();
@@ -345,7 +345,7 @@ public interface IArguments
*/ */
default long optLong( int index, long def ) throws LuaException 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 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<Double> optFiniteDouble( int index ) throws LuaException default Optional<Double> optFiniteDouble( int index ) throws LuaException
{ {
Optional<Double> value = this.optDouble( index ); Optional<Double> value = optDouble( index );
if( value.isPresent() ) if( value.isPresent() )
{ {
LuaValues.checkFiniteNum( index, value.get() ); LuaValues.checkFiniteNum( index, value.get() );
@@ -388,7 +388,7 @@ public interface IArguments
*/ */
default boolean optBoolean( int index, boolean def ) throws LuaException 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<Boolean> optBoolean( int index ) throws LuaException default Optional<Boolean> optBoolean( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( value == null ) if( value == null )
{ {
return Optional.empty(); return Optional.empty();
@@ -422,7 +422,7 @@ public interface IArguments
*/ */
default String optString( int index, String def ) throws LuaException 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<Object, Object> def ) throws LuaException default Map<?, ?> optTable( int index, Map<Object, Object> def ) throws LuaException
{ {
return this.optTable( index ).orElse( def ); return optTable( index ).orElse( def );
} }
/** /**
@@ -447,7 +447,7 @@ public interface IArguments
*/ */
default Optional<Map<?, ?>> optTable( int index ) throws LuaException default Optional<Map<?, ?>> optTable( int index ) throws LuaException
{ {
Object value = this.get( index ); Object value = get( index );
if( value == null ) if( value == null )
{ {
return Optional.empty(); return Optional.empty();

View File

@@ -20,14 +20,14 @@ public class LuaException extends Exception
public LuaException( @Nullable String message ) public LuaException( @Nullable String message )
{ {
super( message ); super( message );
this.hasLevel = false; hasLevel = false;
this.level = 1; level = 1;
} }
public LuaException( @Nullable String message, int level ) public LuaException( @Nullable String message, int level )
{ {
super( message ); super( message );
this.hasLevel = true; hasLevel = true;
this.level = level; this.level = level;
} }
@@ -38,7 +38,7 @@ public class LuaException extends Exception
*/ */
public boolean hasLevel() public boolean hasLevel()
{ {
return this.hasLevel; return hasLevel;
} }
/** /**
@@ -48,6 +48,6 @@ public class LuaException extends Exception
*/ */
public int getLevel() public int getLevel()
{ {
return this.level; return level;
} }
} }

View File

@@ -31,14 +31,14 @@ public final class MethodResult
private MethodResult( Object[] arguments, ILuaCallback callback ) private MethodResult( Object[] arguments, ILuaCallback callback )
{ {
this.result = arguments; result = arguments;
this.callback = callback; this.callback = callback;
this.adjust = 0; adjust = 0;
} }
private MethodResult( Object[] arguments, ILuaCallback callback, int adjust ) private MethodResult( Object[] arguments, ILuaCallback callback, int adjust )
{ {
this.result = arguments; result = arguments;
this.callback = callback; this.callback = callback;
this.adjust = adjust; this.adjust = adjust;
} }
@@ -141,18 +141,18 @@ public final class MethodResult
@Nullable @Nullable
public Object[] getResult() public Object[] getResult()
{ {
return this.result; return result;
} }
@Nullable @Nullable
public ILuaCallback getCallback() public ILuaCallback getCallback()
{ {
return this.callback; return callback;
} }
public int getErrorAdjust() 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" ); throw new IllegalArgumentException( "cannot adjust by a negative amount" );
} }
if( adjust == 0 || this.callback == null ) if( adjust == 0 || callback == null )
{ {
return this; return this;
} }
return new MethodResult( this.result, this.callback, this.adjust + adjust ); return new MethodResult( result, callback, this.adjust + adjust );
} }
} }

View File

@@ -47,30 +47,30 @@ public final class ObjectArguments implements IArguments
{ {
return this; return this;
} }
if( count >= this.args.size() ) if( count >= args.size() )
{ {
return EMPTY; return EMPTY;
} }
return new ObjectArguments( this.args.subList( count, this.args.size() ) ); return new ObjectArguments( args.subList( count, args.size() ) );
} }
@Override @Override
public Object[] getAll() public Object[] getAll()
{ {
return this.args.toArray(); return args.toArray();
} }
@Override @Override
public int count() public int count()
{ {
return this.args.size(); return args.size();
} }
@Nullable @Nullable
@Override @Override
public Object get( int index ) public Object get( int index )
{ {
return index >= this.args.size() ? null : this.args.get( index ); return index >= args.size() ? null : args.get( index );
} }
} }

View File

@@ -53,7 +53,7 @@ public class Packet
*/ */
public int getChannel() public int getChannel()
{ {
return this.channel; return channel;
} }
/** /**
@@ -63,7 +63,7 @@ public class Packet
*/ */
public int getReplyChannel() public int getReplyChannel()
{ {
return this.replyChannel; return replyChannel;
} }
/** /**
@@ -74,7 +74,7 @@ public class Packet
@Nullable @Nullable
public Object getPayload() public Object getPayload()
{ {
return this.payload; return payload;
} }
/** /**
@@ -85,17 +85,17 @@ public class Packet
@Nonnull @Nonnull
public IPacketSender getSender() public IPacketSender getSender()
{ {
return this.sender; return sender;
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
int result; int result;
result = this.channel; result = channel;
result = 31 * result + this.replyChannel; result = 31 * result + replyChannel;
result = 31 * result + (this.payload != null ? this.payload.hashCode() : 0); result = 31 * result + (payload != null ? payload.hashCode() : 0);
result = 31 * result + this.sender.hashCode(); result = 31 * result + sender.hashCode();
return result; return result;
} }
@@ -106,25 +106,25 @@ public class Packet
{ {
return true; return true;
} }
if( o == null || this.getClass() != o.getClass() ) if( o == null || getClass() != o.getClass() )
{ {
return false; return false;
} }
Packet packet = (Packet) o; Packet packet = (Packet) o;
if( this.channel != packet.channel ) if( channel != packet.channel )
{ {
return false; return false;
} }
if( this.replyChannel != packet.replyChannel ) if( replyChannel != packet.replyChannel )
{ {
return false; return false;
} }
if( !Objects.equals( this.payload, packet.payload ) ) if( !Objects.equals( payload, packet.payload ) )
{ {
return false; return false;
} }
return this.sender.equals( packet.sender ); return sender.equals( packet.sender );
} }
} }

View File

@@ -46,7 +46,7 @@ public interface IWiredNode extends IPacketNetwork
*/ */
default boolean connectTo( @Nonnull IWiredNode node ) 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 ) 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() 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<String, IPeripheral> peripherals ) default void updatePeripherals( @Nonnull Map<String, IPeripheral> peripherals )
{ {
this.getNetwork().updatePeripherals( this, peripherals ); getNetwork().updatePeripherals( this, peripherals );
} }
} }

View File

@@ -43,7 +43,7 @@ public interface IComputerAccess
@Nullable @Nullable
default String mount( @Nonnull String desiredLocation, @Nonnull IMount mount ) 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 @Nullable
default String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount ) default String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount )
{ {
return this.mountWritable( desiredLocation, mount, this.getAttachmentName() ); return mountWritable( desiredLocation, mount, getAttachmentName() );
} }
/** /**

View File

@@ -45,7 +45,7 @@ public interface IWorkMonitor
default boolean runWork( @Nonnull Runnable runnable ) default boolean runWork( @Nonnull Runnable runnable )
{ {
Objects.requireNonNull( runnable, "runnable should not be null" ); Objects.requireNonNull( runnable, "runnable should not be null" );
if( !this.canWork() ) if( !canWork() )
{ {
return false; return false;
} }
@@ -57,7 +57,7 @@ public interface IWorkMonitor
} }
finally finally
{ {
this.trackWork( System.nanoTime() - start, TimeUnit.NANOSECONDS ); trackWork( System.nanoTime() - start, TimeUnit.NANOSECONDS );
} }
return true; return true;

View File

@@ -33,7 +33,7 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
{ {
this.id = id; this.id = id;
this.adjective = adjective; this.adjective = adjective;
this.stack = new ItemStack( item ); stack = new ItemStack( item );
} }
protected AbstractPocketUpgrade( Identifier id, String adjective, ItemStack stack ) protected AbstractPocketUpgrade( Identifier id, String adjective, ItemStack stack )
@@ -48,20 +48,20 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
@Override @Override
public final Identifier getUpgradeID() public final Identifier getUpgradeID()
{ {
return this.id; return id;
} }
@Nonnull @Nonnull
@Override @Override
public final String getUnlocalisedAdjective() public final String getUnlocalisedAdjective()
{ {
return this.adjective; return adjective;
} }
@Nonnull @Nonnull
@Override @Override
public final ItemStack getCraftingItem() public final ItemStack getCraftingItem()
{ {
return this.stack; return stack;
} }
} }

View File

@@ -53,27 +53,27 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
@Override @Override
public final Identifier getUpgradeID() public final Identifier getUpgradeID()
{ {
return this.id; return id;
} }
@Nonnull @Nonnull
@Override @Override
public final String getUnlocalisedAdjective() public final String getUnlocalisedAdjective()
{ {
return this.adjective; return adjective;
} }
@Nonnull @Nonnull
@Override @Override
public final TurtleUpgradeType getType() public final TurtleUpgradeType getType()
{ {
return this.type; return type;
} }
@Nonnull @Nonnull
@Override @Override
public final ItemStack getCraftingItem() public final ItemStack getCraftingItem()
{ {
return this.stack; return stack;
} }
} }

View File

@@ -54,7 +54,7 @@ public class FakePlayer extends ServerPlayerEntity
public FakePlayer( ServerWorld world, GameProfile gameProfile ) public FakePlayer( ServerWorld world, GameProfile gameProfile )
{ {
super( world.getServer(), world, gameProfile, new ServerPlayerInteractionManager( world ) ); super( world.getServer(), world, gameProfile, new ServerPlayerInteractionManager( world ) );
this.networkHandler = new FakeNetHandler( this ); networkHandler = new FakeNetHandler( this );
} }
// region Direct networkHandler access // region Direct networkHandler access

View File

@@ -267,7 +267,7 @@ public interface ITurtleAccess
default ItemStorage getItemHandler() default ItemStorage getItemHandler()
{ {
return ItemStorage.wrap( this.getInventory() ); return ItemStorage.wrap( getInventory() );
} }
/** /**

View File

@@ -91,7 +91,7 @@ public final class TurtleCommandResult
*/ */
public boolean isSuccess() public boolean isSuccess()
{ {
return this.success; return success;
} }
/** /**
@@ -102,7 +102,7 @@ public final class TurtleCommandResult
@Nullable @Nullable
public String getErrorMessage() public String getErrorMessage()
{ {
return this.errorMessage; return errorMessage;
} }
/** /**
@@ -113,6 +113,6 @@ public final class TurtleCommandResult
@Nullable @Nullable
public Object[] getResults() public Object[] getResults()
{ {
return this.results; return results;
} }
} }

View File

@@ -32,7 +32,7 @@ public class TurtleActionEvent extends TurtleEvent
public TurtleAction getAction() public TurtleAction getAction()
{ {
return this.action; return action;
} }
/** /**
@@ -47,7 +47,7 @@ public class TurtleActionEvent extends TurtleEvent
@Deprecated @Deprecated
public void setCanceled( boolean cancel ) 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 ) public void setCanceled( boolean cancel, @Nullable String failureMessage )
{ {
this.cancelled = true; cancelled = true;
this.failureMessage = cancel ? failureMessage : null; this.failureMessage = cancel ? failureMessage : null;
} }
@@ -75,11 +75,11 @@ public class TurtleActionEvent extends TurtleEvent
@Nullable @Nullable
public String getFailureMessage() public String getFailureMessage()
{ {
return this.failureMessage; return failureMessage;
} }
public boolean isCancelled() public boolean isCancelled()
{ {
return this.cancelled; return cancelled;
} }
} }

View File

@@ -46,7 +46,7 @@ public class TurtleAttackEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public Entity getTarget() public Entity getTarget()
{ {
return this.target; return target;
} }
/** /**
@@ -57,7 +57,7 @@ public class TurtleAttackEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public ITurtleUpgrade getUpgrade() public ITurtleUpgrade getUpgrade()
{ {
return this.upgrade; return upgrade;
} }
/** /**
@@ -68,6 +68,6 @@ public class TurtleAttackEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public TurtleSide getSide() public TurtleSide getSide()
{ {
return this.side; return side;
} }
} }

View File

@@ -52,7 +52,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
*/ */
public World getWorld() public World getWorld()
{ {
return this.world; return world;
} }
/** /**
@@ -62,7 +62,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
*/ */
public BlockPos getPos() public BlockPos getPos()
{ {
return this.pos; return pos;
} }
/** /**
@@ -97,7 +97,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public BlockState getBlock() public BlockState getBlock()
{ {
return this.block; return block;
} }
/** /**
@@ -108,7 +108,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public ITurtleUpgrade getUpgrade() public ITurtleUpgrade getUpgrade()
{ {
return this.upgrade; return upgrade;
} }
/** /**
@@ -119,7 +119,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public TurtleSide getSide() public TurtleSide getSide()
{ {
return this.side; return side;
} }
} }
@@ -161,7 +161,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public ItemStack getStack() public ItemStack getStack()
{ {
return this.stack; return stack;
} }
} }
@@ -196,7 +196,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public BlockState getState() public BlockState getState()
{ {
return this.state; return state;
} }
/** /**
@@ -207,7 +207,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull @Nonnull
public Map<String, Object> getData() public Map<String, Object> getData()
{ {
return this.data; return data;
} }
/** /**
@@ -218,7 +218,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
public void addData( @Nonnull Map<String, ?> newData ) public void addData( @Nonnull Map<String, ?> newData )
{ {
Objects.requireNonNull( newData, "newData cannot be null" ); Objects.requireNonNull( newData, "newData cannot be null" );
this.data.putAll( newData ); data.putAll( newData );
} }
} }
} }

View File

@@ -46,7 +46,7 @@ public abstract class TurtleEvent
@Nonnull @Nonnull
public ITurtleAccess getTurtle() public ITurtleAccess getTurtle()
{ {
return this.turtle; return turtle;
} }
} }

View File

@@ -53,7 +53,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
@Nonnull @Nonnull
public ItemStack getStack() public ItemStack getStack()
{ {
return this.stack; return stack;
} }
/** /**
@@ -64,7 +64,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
@Nonnull @Nonnull
public Map<String, Object> getData() public Map<String, Object> getData()
{ {
return this.data; return data;
} }
/** /**
@@ -74,7 +74,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
*/ */
public boolean onMainThread() public boolean onMainThread()
{ {
return this.mainThread; return mainThread;
} }
/** /**
@@ -85,6 +85,6 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
public void addData( @Nonnull Map<String, ?> newData ) public void addData( @Nonnull Map<String, ?> newData )
{ {
Objects.requireNonNull( newData, "newData cannot be null" ); Objects.requireNonNull( newData, "newData cannot be null" );
this.data.putAll( newData ); data.putAll( newData );
} }
} }

View File

@@ -39,7 +39,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
@Nullable @Nullable
public Inventory getItemHandler() public Inventory getItemHandler()
{ {
return this.handler; return handler;
} }
/** /**
@@ -81,7 +81,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
@Nonnull @Nonnull
public ItemStack getStack() public ItemStack getStack()
{ {
return this.stack; return stack;
} }
} }
} }

View File

@@ -39,6 +39,6 @@ public abstract class TurtlePlayerEvent extends TurtleActionEvent
@Nonnull @Nonnull
public FakePlayer getPlayer() public FakePlayer getPlayer()
{ {
return this.player; return player;
} }
} }

View File

@@ -41,7 +41,7 @@ public class TurtleRefuelEvent extends TurtleActionEvent
*/ */
public ItemStack getStack() public ItemStack getStack()
{ {
return this.stack; return stack;
} }
/** /**
@@ -53,7 +53,7 @@ public class TurtleRefuelEvent extends TurtleActionEvent
@Nullable @Nullable
public Handler getHandler() public Handler getHandler()
{ {
return this.handler; return handler;
} }
/** /**

View File

@@ -103,11 +103,9 @@ public final class ClientRegistry
case 1: // Frame colour case 1: // Frame colour
return IColouredItem.getColourBasic( stack ); return IColouredItem.getColourBasic( stack );
case 2: // Light colour case 2: // Light colour
{
int light = ItemPocketComputer.getLightState( stack ); int light = ItemPocketComputer.getLightState( stack );
return light == -1 ? Colour.BLACK.getHex() : light; return light == -1 ? Colour.BLACK.getHex() : light;
} }
}
}, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_NORMAL, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_ADVANCED ); }, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_NORMAL, ComputerCraftRegistry.ModItems.POCKET_COMPUTER_ADVANCED );
// Setup turtle colours // Setup turtle colours

View File

@@ -35,7 +35,7 @@ public class ClientTableFormatter implements TableFormatter
@Nullable @Nullable
public Text getPadding( Text component, int width ) public Text getPadding( Text component, int width )
{ {
int extraWidth = width - this.getWidth( component ); int extraWidth = width - getWidth( component );
if( extraWidth <= 0 ) if( extraWidth <= 0 )
{ {
return null; return null;

View File

@@ -65,27 +65,27 @@ public class GuiComputer<T extends ContainerComputerBase> extends HandledScreen<
protected void initTerminal( int border, int widthExtra, int heightExtra ) 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 termPxWidth = termWidth * FixedWidthFontRenderer.FONT_WIDTH;
int termPxHeight = this.termHeight * FixedWidthFontRenderer.FONT_HEIGHT; int termPxHeight = termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
this.backgroundWidth = termPxWidth + MARGIN * 2 + border * 2 + widthExtra; backgroundWidth = termPxWidth + MARGIN * 2 + border * 2 + widthExtra;
this.backgroundHeight = termPxHeight + MARGIN * 2 + border * 2 + heightExtra; backgroundHeight = termPxHeight + MARGIN * 2 + border * 2 + heightExtra;
super.init(); super.init();
this.terminal = new WidgetTerminal( this.client, () -> this.computer, this.termWidth, this.termHeight, MARGIN, MARGIN, MARGIN, MARGIN ); terminal = new WidgetTerminal( client, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN );
this.terminalWrapper = new WidgetWrapper( this.terminal, MARGIN + border + this.x, MARGIN + border + this.y, termPxWidth, termPxHeight ); terminalWrapper = new WidgetWrapper( terminal, MARGIN + border + x, MARGIN + border + y, termPxWidth, termPxHeight );
this.children.add( this.terminalWrapper ); children.add( terminalWrapper );
this.setFocused( this.terminalWrapper ); setFocused( terminalWrapper );
} }
@Override @Override
protected void init() protected void init()
{ {
this.initTerminal( BORDER, 0, 0 ); initTerminal( BORDER, 0, 0 );
} }
@Override @Override
@@ -93,7 +93,7 @@ public class GuiComputer<T extends ContainerComputerBase> extends HandledScreen<
{ {
this.renderBackground( stack ); this.renderBackground( stack );
super.render( stack, mouseX, mouseY, partialTicks ); super.render( stack, mouseX, mouseY, partialTicks );
this.drawMouseoverTooltip( stack, mouseX, mouseY ); drawMouseoverTooltip( stack, mouseX, mouseY );
} }
@Override @Override
@@ -106,35 +106,35 @@ public class GuiComputer<T extends ContainerComputerBase> extends HandledScreen<
public void drawBackground( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY ) public void drawBackground( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY )
{ {
// Draw terminal // Draw terminal
this.terminal.draw( this.terminalWrapper.getX(), this.terminalWrapper.getY() ); terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
// Draw a border around the terminal // Draw a border around the terminal
RenderSystem.color4f( 1, 1, 1, 1 ); RenderSystem.color4f( 1, 1, 1, 1 );
this.client.getTextureManager() client.getTextureManager()
.bindTexture( ComputerBorderRenderer.getTexture( this.family ) ); .bindTexture( ComputerBorderRenderer.getTexture( family ) );
ComputerBorderRenderer.render( this.terminalWrapper.getX() - MARGIN, this.terminalWrapper.getY() - MARGIN, ComputerBorderRenderer.render( terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN,
this.getZOffset(), this.terminalWrapper.getWidth() + MARGIN * 2, this.terminalWrapper.getHeight() + MARGIN * 2 ); getZOffset(), terminalWrapper.getWidth() + MARGIN * 2, terminalWrapper.getHeight() + MARGIN * 2 );
} }
@Override @Override
public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) 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 @Override
public boolean mouseReleased( double mouseX, double mouseY, int button ) 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 @Override
public boolean keyPressed( int key, int scancode, int modifiers ) public boolean keyPressed( int key, int scancode, int modifiers )
{ {
// Forward the tab key to the terminal, rather than moving between controls. // 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 ); return super.keyPressed( key, scancode, modifiers );
@@ -144,15 +144,15 @@ public class GuiComputer<T extends ContainerComputerBase> extends HandledScreen<
public void removed() public void removed()
{ {
super.removed(); super.removed();
this.children.remove( this.terminal ); children.remove( terminal );
this.terminal = null; terminal = null;
this.client.keyboard.setRepeatEvents( false ); client.keyboard.setRepeatEvents( false );
} }
@Override @Override
public void tick() public void tick()
{ {
super.tick(); super.tick();
this.terminal.update(); terminal.update();
} }
} }

View File

@@ -28,17 +28,17 @@ public class GuiDiskDrive extends HandledScreen<ContainerDiskDrive>
@Override @Override
public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks ) public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks )
{ {
this.renderBackground( transform ); renderBackground( transform );
super.render( transform, mouseX, mouseY, partialTicks ); super.render( transform, mouseX, mouseY, partialTicks );
this.drawMouseoverTooltip( transform, mouseX, mouseY ); drawMouseoverTooltip( transform, mouseX, mouseY );
} }
@Override @Override
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{ {
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.client.getTextureManager() client.getTextureManager()
.bindTexture( BACKGROUND ); .bindTexture( BACKGROUND );
this.drawTexture( transform, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight ); drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight );
} }
} }

View File

@@ -36,22 +36,22 @@ public class GuiPrinter extends HandledScreen<ContainerPrinter>
@Override @Override
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
{ {
this.renderBackground( stack ); renderBackground( stack );
super.render( stack, mouseX, mouseY, partialTicks ); super.render( stack, mouseX, mouseY, partialTicks );
this.drawMouseoverTooltip( stack, mouseX, mouseY ); drawMouseoverTooltip( stack, mouseX, mouseY );
} }
@Override @Override
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{ {
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.client.getTextureManager() client.getTextureManager()
.bindTexture( BACKGROUND ); .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 );
} }
} }
} }

View File

@@ -35,7 +35,7 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
{ {
super( container, player, title ); super( container, player, title );
this.backgroundHeight = Y_SIZE; backgroundHeight = Y_SIZE;
String[] text = ItemPrintout.getText( container.getStack() ); String[] text = ItemPrintout.getText( container.getStack() );
this.text = new TextBuffer[text.length]; this.text = new TextBuffer[text.length];
@@ -51,9 +51,9 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
this.colours[i] = new TextBuffer( colours[i] ); this.colours[i] = new TextBuffer( colours[i] );
} }
this.page = 0; page = 0;
this.pages = Math.max( this.text.length / ItemPrintout.LINES_PER_PAGE, 1 ); pages = Math.max( this.text.length / ItemPrintout.LINES_PER_PAGE, 1 );
this.book = ((ItemPrintout) container.getStack() book = ((ItemPrintout) container.getStack()
.getItem()).getType() == ItemPrintout.Type.BOOK; .getItem()).getType() == ItemPrintout.Type.BOOK;
} }
@@ -67,9 +67,9 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
if( delta < 0 ) if( delta < 0 )
{ {
// Scroll up goes to the next page // Scroll up goes to the next page
if( this.page < this.pages - 1 ) if( page < pages - 1 )
{ {
this.page++; page++;
} }
return true; return true;
} }
@@ -77,9 +77,9 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
if( delta > 0 ) if( delta > 0 )
{ {
// Scroll down goes to the previous page // Scroll down goes to the previous page
if( this.page > 0 ) if( page > 0 )
{ {
this.page--; page--;
} }
return true; return true;
} }
@@ -91,9 +91,9 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks ) 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. // We must take the background further back in order to not overlap with our printed pages.
this.setZOffset( this.getZOffset() - 1 ); setZOffset( getZOffset() - 1 );
this.renderBackground( stack ); renderBackground( stack );
this.setZOffset( this.getZOffset() + 1 ); setZOffset( getZOffset() + 1 );
super.render( stack, mouseX, mouseY, partialTicks ); super.render( stack, mouseX, mouseY, partialTicks );
} }
@@ -116,8 +116,8 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
.getEntityVertexConsumers(); .getEntityVertexConsumers();
Matrix4f matrix = transform.peek() Matrix4f matrix = transform.peek()
.getModel(); .getModel();
drawBorder( matrix, renderer, this.x, this.y, this.getZOffset(), this.page, this.pages, this.book ); drawBorder( matrix, renderer, x, y, getZOffset(), page, pages, book );
drawText( matrix, renderer, this.x + X_TEXT_MARGIN, this.y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * this.page, this.text, this.colours ); drawText( matrix, renderer, x + X_TEXT_MARGIN, y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, text, colours );
renderer.draw(); renderer.draw();
} }
@@ -131,18 +131,18 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem>
if( key == GLFW.GLFW_KEY_RIGHT ) if( key == GLFW.GLFW_KEY_RIGHT )
{ {
if( this.page < this.pages - 1 ) if( page < pages - 1 )
{ {
this.page++; page++;
} }
return true; return true;
} }
if( key == GLFW.GLFW_KEY_LEFT ) if( key == GLFW.GLFW_KEY_LEFT )
{ {
if( this.page > 0 ) if( page > 0 )
{ {
this.page--; page--;
} }
return true; return true;
} }

View File

@@ -33,29 +33,29 @@ public class GuiTurtle extends GuiComputer<ContainerTurtle>
@Override @Override
protected void init() protected void init()
{ {
this.initTerminal( 8, 0, 80 ); initTerminal( 8, 0, 80 );
} }
@Override @Override
public void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY ) public void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{ {
// Draw term // Draw term
Identifier texture = this.family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL; Identifier texture = family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL;
this.terminal.draw( this.terminalWrapper.getX(), this.terminalWrapper.getY() ); terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
// Draw border/inventory // Draw border/inventory
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.client.getTextureManager() client.getTextureManager()
.bindTexture( texture ); .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 // Draw selection slot
int slot = this.container.getSelectedSlot(); int slot = container.getSelectedSlot();
if( slot >= 0 ) if( slot >= 0 )
{ {
int slotX = slot % 4; int slotX = slot % 4;
int slotY = 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, 0,
217, 217,
24, 24,

View File

@@ -74,9 +74,9 @@ public class WidgetTerminal implements Element
computer.mouseClick( button + 1, charX + 1, charY + 1 ); computer.mouseClick( button + 1, charX + 1, charY + 1 );
this.lastMouseButton = button; lastMouseButton = button;
this.lastMouseX = charX; lastMouseX = charX;
this.lastMouseY = charY; lastMouseY = charY;
} }
return true; return true;
@@ -99,14 +99,14 @@ public class WidgetTerminal implements Element
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 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 ); computer.mouseUp( lastMouseButton + 1, charX + 1, charY + 1 );
this.lastMouseButton = -1; lastMouseButton = -1;
} }
this.lastMouseX = charX; lastMouseX = charX;
this.lastMouseY = charY; lastMouseY = charY;
} }
return false; return false;
@@ -129,11 +129,11 @@ public class WidgetTerminal implements Element
charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 );
charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 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 ); computer.mouseDrag( button + 1, charX + 1, charY + 1 );
this.lastMouseX = charX; lastMouseX = charX;
this.lastMouseY = charY; lastMouseY = charY;
} }
} }
@@ -159,8 +159,8 @@ public class WidgetTerminal implements Element
computer.mouseScroll( delta < 0 ? 1 : -1, charX + 1, charY + 1 ); computer.mouseScroll( delta < 0 ? 1 : -1, charX + 1, charY + 1 );
this.lastMouseX = charX; lastMouseX = charX;
this.lastMouseY = charY; lastMouseY = charY;
} }
return true; return true;
@@ -178,27 +178,27 @@ public class WidgetTerminal implements Element
switch( key ) switch( key )
{ {
case GLFW.GLFW_KEY_T: case GLFW.GLFW_KEY_T:
if( this.terminateTimer < 0 ) if( terminateTimer < 0 )
{ {
this.terminateTimer = 0; terminateTimer = 0;
} }
return true; return true;
case GLFW.GLFW_KEY_S: case GLFW.GLFW_KEY_S:
if( this.shutdownTimer < 0 ) if( shutdownTimer < 0 )
{ {
this.shutdownTimer = 0; shutdownTimer = 0;
} }
return true; return true;
case GLFW.GLFW_KEY_R: case GLFW.GLFW_KEY_R:
if( this.rebootTimer < 0 ) if( rebootTimer < 0 )
{ {
this.rebootTimer = 0; rebootTimer = 0;
} }
return true; return true;
case GLFW.GLFW_KEY_V: case GLFW.GLFW_KEY_V:
// Ctrl+V for paste // Ctrl+V for paste
String clipboard = this.client.keyboard.getClipboard(); String clipboard = client.keyboard.getClipboard();
if( clipboard != null ) if( clipboard != null )
{ {
// Clip to the first occurrence of \r or \n // Clip to the first occurrence of \r or \n
@@ -226,7 +226,7 @@ public class WidgetTerminal implements Element
{ {
clipboard = clipboard.substring( 0, 512 ); clipboard = clipboard.substring( 0, 512 );
} }
this.queueEvent( "paste", clipboard ); queueEvent( "paste", clipboard );
} }
return true; 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 // Queue the "key" event and add to the down set
boolean repeat = this.keysDown.get( key ); boolean repeat = keysDown.get( key );
this.keysDown.set( key ); keysDown.set( key );
IComputer computer = this.computer.get(); IComputer computer = this.computer.get();
if( computer != null ) if( computer != null )
{ {
@@ -253,9 +253,9 @@ public class WidgetTerminal implements Element
public boolean keyReleased( int key, int scancode, int modifiers ) public boolean keyReleased( int key, int scancode, int modifiers )
{ {
// Queue the "key_up" event and remove from the down set // 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(); IComputer computer = this.computer.get();
if( computer != null ) if( computer != null )
{ {
@@ -266,17 +266,17 @@ public class WidgetTerminal implements Element
switch( key ) switch( key )
{ {
case GLFW.GLFW_KEY_T: case GLFW.GLFW_KEY_T:
this.terminateTimer = -1; terminateTimer = -1;
break; break;
case GLFW.GLFW_KEY_R: case GLFW.GLFW_KEY_R:
this.rebootTimer = -1; rebootTimer = -1;
break; break;
case GLFW.GLFW_KEY_S: case GLFW.GLFW_KEY_S:
this.shutdownTimer = -1; shutdownTimer = -1;
break; break;
case GLFW.GLFW_KEY_LEFT_CONTROL: case GLFW.GLFW_KEY_LEFT_CONTROL:
case GLFW.GLFW_KEY_RIGHT_CONTROL: case GLFW.GLFW_KEY_RIGHT_CONTROL:
this.terminateTimer = this.rebootTimer = this.shutdownTimer = -1; terminateTimer = rebootTimer = shutdownTimer = -1;
break; break;
} }
@@ -289,7 +289,7 @@ public class WidgetTerminal implements Element
if( ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255 ) // printable chars in byte range if( ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255 ) // printable chars in byte range
{ {
// Queue the "char" event // Queue the "char" event
this.queueEvent( "char", Character.toString( ch ) ); queueEvent( "char", Character.toString( ch ) );
} }
return true; return true;
@@ -298,32 +298,32 @@ public class WidgetTerminal implements Element
@Override @Override
public boolean changeFocus( boolean reversed ) public boolean changeFocus( boolean reversed )
{ {
if( this.focused ) if( focused )
{ {
// When blurring, we should make all keys go up // 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 // When blurring, we should make the last mouse button go up
if( this.lastMouseButton > 0 ) if( lastMouseButton > 0 )
{ {
IComputer computer = this.computer.get(); IComputer computer = this.computer.get();
if( computer != null ) 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; return true;
} }
@@ -344,12 +344,12 @@ public class WidgetTerminal implements Element
public void update() 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(); ClientComputer computer = this.computer.get();
if( computer != null ) 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(); ClientComputer computer = this.computer.get();
if( computer != null ) if( computer != null )
@@ -379,21 +379,21 @@ public class WidgetTerminal implements Element
public void draw( int originX, int originY ) public void draw( int originX, int originY )
{ {
synchronized( this.computer ) synchronized( computer )
{ {
// Draw the screen contents // Draw the screen contents
ClientComputer computer = this.computer.get(); ClientComputer computer = this.computer.get();
Terminal terminal = computer != null ? computer.getTerminal() : null; Terminal terminal = computer != null ? computer.getTerminal() : null;
if( terminal != null ) if( terminal != null )
{ {
FixedWidthFontRenderer.drawTerminal( originX, originY, terminal, !computer.isColour(), this.topMargin, this.bottomMargin, this.leftMargin, FixedWidthFontRenderer.drawTerminal( originX, originY, terminal, !computer.isColour(), topMargin, bottomMargin, leftMargin,
this.rightMargin ); rightMargin );
} }
else else
{ {
FixedWidthFontRenderer.drawEmptyTerminal( originX - this.leftMargin, FixedWidthFontRenderer.drawEmptyTerminal( originX - leftMargin,
originY - this.rightMargin, this.termWidth * FONT_WIDTH + this.leftMargin + this.rightMargin, originY - rightMargin, termWidth * FONT_WIDTH + leftMargin + rightMargin,
this.termHeight * FONT_HEIGHT + this.topMargin + this.bottomMargin ); termHeight * FONT_HEIGHT + topMargin + bottomMargin );
} }
} }
} }

View File

@@ -29,78 +29,78 @@ public class WidgetWrapper implements Element
public boolean mouseClicked( double x, double y, int button ) public boolean mouseClicked( double x, double y, int button )
{ {
double dx = x - this.x, dy = y - this.y; 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 @Override
public boolean mouseReleased( double x, double y, int button ) public boolean mouseReleased( double x, double y, int button )
{ {
double dx = x - this.x, dy = y - this.y; 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 @Override
public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
{ {
double dx = x - this.x, dy = y - this.y; 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 @Override
public boolean mouseScrolled( double x, double y, double delta ) public boolean mouseScrolled( double x, double y, double delta )
{ {
double dx = x - this.x, dy = y - this.y; 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 @Override
public boolean keyPressed( int key, int scancode, int modifiers ) public boolean keyPressed( int key, int scancode, int modifiers )
{ {
return this.listener.keyPressed( key, scancode, modifiers ); return listener.keyPressed( key, scancode, modifiers );
} }
@Override @Override
public boolean keyReleased( int key, int scancode, int modifiers ) public boolean keyReleased( int key, int scancode, int modifiers )
{ {
return this.listener.keyReleased( key, scancode, modifiers ); return listener.keyReleased( key, scancode, modifiers );
} }
@Override @Override
public boolean charTyped( char character, int modifiers ) public boolean charTyped( char character, int modifiers )
{ {
return this.listener.charTyped( character, modifiers ); return listener.charTyped( character, modifiers );
} }
@Override @Override
public boolean changeFocus( boolean b ) public boolean changeFocus( boolean b )
{ {
return this.listener.changeFocus( b ); return listener.changeFocus( b );
} }
@Override @Override
public boolean isMouseOver( double x, double y ) public boolean isMouseOver( double x, double y )
{ {
double dx = x - this.x, dy = y - this.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() public int getX()
{ {
return this.x; return x;
} }
public int getY() public int getY()
{ {
return this.y; return y;
} }
public int getWidth() public int getWidth()
{ {
return this.width; return width;
} }
public int getHeight() public int getHeight()
{ {
return this.height; return height;
} }
} }

View File

@@ -113,13 +113,13 @@ public class ComputerBorderRenderer
int endY = y + height; int endY = y + height;
// Vertical bars // Vertical bars
this.renderLine( x - BORDER, y, 0, CORNER_TOP_Y, BORDER, endY - y ); 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( endX, y, BORDER_RIGHT_X, CORNER_TOP_Y, BORDER, endY - y );
// Top bar // Top bar
this.renderLine( x, y - BORDER, 0, 0, endX - x, BORDER ); renderLine( x, y - BORDER, 0, 0, endX - x, BORDER );
this.renderCorner( x - BORDER, y - BORDER, CORNER_LEFT_X, CORNER_TOP_Y ); renderCorner( x - BORDER, y - BORDER, CORNER_LEFT_X, CORNER_TOP_Y );
this.renderCorner( endX, y - BORDER, CORNER_RIGHT_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 // Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the
// pocket computer's lights). // pocket computer's lights).
@@ -131,43 +131,43 @@ public class ComputerBorderRenderer
} }
else else
{ {
this.renderLine( x, endY, 0, BORDER, endX - x, BORDER ); renderLine( x, endY, 0, BORDER, endX - x, BORDER );
this.renderCorner( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y ); renderCorner( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y );
this.renderCorner( endX, endY, CORNER_RIGHT_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 ) 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 ) 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 ) 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 ) 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 ) builder.vertex( transform, x, y + height, z )
.color( this.r, this.g, this.b, 1.0f ) .color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.next(); .next();
this.builder.vertex( this.transform, x + width, y + height, this.z ) builder.vertex( transform, x + width, y + height, z )
.color( this.r, this.g, this.b, 1.0f ) .color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.next(); .next();
this.builder.vertex( this.transform, x + width, y, this.z ) builder.vertex( transform, x + width, y, z )
.color( this.r, this.g, this.b, 1.0f ) .color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ) .texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE )
.next(); .next();
this.builder.vertex( this.transform, x, y, this.z ) builder.vertex( transform, x, y, z )
.color( this.r, this.g, this.b, 1.0f ) .color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, v * TEX_SCALE ) .texture( u * TEX_SCALE, v * TEX_SCALE )
.next(); .next();
} }

View File

@@ -33,11 +33,11 @@ public abstract class ItemMapLikeRenderer
transform.push(); transform.push();
if( hand == Hand.MAIN_HAND && player.getOffHandStack().isEmpty() ) 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 else
{ {
this.renderItemFirstPersonSide( transform, renderItemFirstPersonSide( transform,
render, render,
lightTexture, lightTexture,
hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(), 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.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) );
transform.scale( 2.0F, 2.0F, 2.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_X.getDegreesQuaternion( f2 * -45f ) );
transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) ); transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) );
this.renderItem( transform, render, stack ); renderItem( transform, render, stack );
transform.pop(); transform.pop();
} }

View File

@@ -229,7 +229,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer<TileMonitor>
} }
case VBO: case VBO:
{
VertexBuffer vbo = monitor.buffer; VertexBuffer vbo = monitor.buffer;
if( redraw ) if( redraw )
{ {
@@ -261,5 +260,4 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer<TileMonitor>
break; break;
} }
} }
}
} }

View File

@@ -116,7 +116,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer<TileTurtle>
// Render the label // Render the label
String label = turtle.createProxy() String label = turtle.createProxy()
.getLabel(); .getLabel();
HitResult hit = this.dispatcher.crosshairTarget; HitResult hit = dispatcher.crosshairTarget;
if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getPos() if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getPos()
.equals( ((BlockHitResult) hit).getBlockPos() ) ) .equals( ((BlockHitResult) hit).getBlockPos() ) )
{ {

View File

@@ -76,7 +76,7 @@ public final class TurtleModelLoader
public Collection<SpriteIdentifier> getTextureDependencies( Function<Identifier, UnbakedModel> modelGetter, public Collection<SpriteIdentifier> getTextureDependencies( Function<Identifier, UnbakedModel> modelGetter,
Set<Pair<String, String>> missingTextureErrors ) Set<Pair<String, String>> missingTextureErrors )
{ {
return this.getModelDependencies() return getModelDependencies()
.stream() .stream()
.flatMap( x -> modelGetter.apply( x ) .flatMap( x -> modelGetter.apply( x )
.getTextureDependencies( modelGetter, missingTextureErrors ) .getTextureDependencies( modelGetter, missingTextureErrors )
@@ -88,14 +88,14 @@ public final class TurtleModelLoader
@Override @Override
public Collection<Identifier> getModelDependencies() public Collection<Identifier> getModelDependencies()
{ {
return Arrays.asList( this.family, COLOUR_TURTLE_MODEL ); return Arrays.asList( family, COLOUR_TURTLE_MODEL );
} }
@Override @Override
public BakedModel bake( @Nonnull ModelLoader loader, @Nonnull Function<SpriteIdentifier, Sprite> spriteGetter, @Nonnull ModelBakeSettings state, public BakedModel bake( @Nonnull ModelLoader loader, @Nonnull Function<SpriteIdentifier, Sprite> spriteGetter, @Nonnull ModelBakeSettings state,
Identifier modelId ) Identifier modelId )
{ {
return new TurtleSmartItemModel( loader.getOrLoadModel( this.family ) return new TurtleSmartItemModel( loader.getOrLoadModel( family )
.bake( loader, spriteGetter, state, modelId ), .bake( loader, spriteGetter, state, modelId ),
loader.getOrLoadModel( COLOUR_TURTLE_MODEL ) loader.getOrLoadModel( COLOUR_TURTLE_MODEL )
.bake( loader, spriteGetter, state, modelId ) ); .bake( loader, spriteGetter, state, modelId ) );

View File

@@ -13,6 +13,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList; 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.texture.Sprite;
import net.minecraft.client.util.math.AffineTransformation; import net.minecraft.client.util.math.AffineTransformation;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -48,19 +49,19 @@ public class TurtleMultiModel implements BakedModel
{ {
if( side != null ) 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 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<BakedQuad> quads = new ArrayList<>(); ArrayList<BakedQuad> quads = new ArrayList<>();
ModelTransformer.transformQuadsTo( quads, this.baseModel.getQuads( state, side, rand ), this.generalTransform.getMatrix() ); ModelTransformer.transformQuadsTo( quads, baseModel.getQuads( state, side, rand ), generalTransform.getMatrix() );
if( this.overlayModel != null ) 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() ); AffineTransformation upgradeTransform = generalTransform.multiply( leftUpgradeModel.getMatrix() );
ModelTransformer.transformQuadsTo( quads, this.leftUpgradeModel.getModel() ModelTransformer.transformQuadsTo( quads, leftUpgradeModel.getModel()
.getQuads( state, side, rand ), .getQuads( state, side, rand ),
upgradeTransform.getMatrix() ); upgradeTransform.getMatrix() );
} }
if( this.rightUpgradeModel != null ) if( rightUpgradeModel != null )
{ {
AffineTransformation upgradeTransform = this.generalTransform.multiply( this.rightUpgradeModel.getMatrix() ); AffineTransformation upgradeTransform = generalTransform.multiply( rightUpgradeModel.getMatrix() );
ModelTransformer.transformQuadsTo( quads, this.rightUpgradeModel.getModel() ModelTransformer.transformQuadsTo( quads, rightUpgradeModel.getModel()
.getQuads( state, side, rand ), .getQuads( state, side, rand ),
upgradeTransform.getMatrix() ); upgradeTransform.getMatrix() );
} }
@@ -95,25 +96,25 @@ public class TurtleMultiModel implements BakedModel
@Override @Override
public boolean useAmbientOcclusion() public boolean useAmbientOcclusion()
{ {
return this.baseModel.useAmbientOcclusion(); return baseModel.useAmbientOcclusion();
} }
@Override @Override
public boolean hasDepth() public boolean hasDepth()
{ {
return this.baseModel.hasDepth(); return baseModel.hasDepth();
} }
@Override @Override
public boolean isSideLit() public boolean isSideLit()
{ {
return this.baseModel.isSideLit(); return baseModel.isSideLit();
} }
@Override @Override
public boolean isBuiltin() public boolean isBuiltin()
{ {
return this.baseModel.isBuiltin(); return baseModel.isBuiltin();
} }
@Nonnull @Nonnull
@@ -121,15 +122,15 @@ public class TurtleMultiModel implements BakedModel
@Deprecated @Deprecated
public Sprite getSprite() public Sprite getSprite()
{ {
return this.baseModel.getSprite(); return baseModel.getSprite();
} }
@Nonnull @Nonnull
@Override @Override
@Deprecated @Deprecated
public net.minecraft.client.render.model.json.ModelTransformation getTransformation() public ModelTransformation getTransformation()
{ {
return this.baseModel.getTransformation(); return baseModel.getTransformation();
} }
@Nonnull @Nonnull

View File

@@ -66,7 +66,7 @@ public class TurtleSmartItemModel implements BakedModel
this.colourModel = colourModel; this.colourModel = colourModel;
// this actually works I think, trust me // 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 @Nonnull
@Override @Override
@@ -85,10 +85,10 @@ public class TurtleSmartItemModel implements BakedModel
boolean flip = false; boolean flip = false;
TurtleModelCombination combo = new TurtleModelCombination( colour != -1, leftUpgrade, rightUpgrade, overlay, christmas, flip ); 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 ) if( model == null )
{ {
TurtleSmartItemModel.this.cachedModels.put( combo, model = TurtleSmartItemModel.this.buildModel( combo ) ); cachedModels.put( combo, model = buildModel( combo ) );
} }
return model; return model;
} }
@@ -103,7 +103,7 @@ public class TurtleSmartItemModel implements BakedModel
.getModelManager(); .getModelManager();
ModelIdentifier overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.overlay, combo.christmas ); 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; BakedModel overlayModel = overlayModelLocation != null ? modelManager.getModel( overlayModelLocation ) : null;
AffineTransformation transform = combo.flip ? flip : identity; AffineTransformation transform = combo.flip ? flip : identity;
TransformedModel leftModel = combo.leftUpgrade != null ? combo.leftUpgrade.getModel( null, TurtleSide.LEFT ) : null; TransformedModel leftModel = combo.leftUpgrade != null ? combo.leftUpgrade.getModel( null, TurtleSide.LEFT ) : null;
@@ -116,31 +116,31 @@ public class TurtleSmartItemModel implements BakedModel
@Deprecated @Deprecated
public List<BakedQuad> getQuads( BlockState state, Direction facing, @Nonnull Random rand ) public List<BakedQuad> getQuads( BlockState state, Direction facing, @Nonnull Random rand )
{ {
return this.familyModel.getQuads( state, facing, rand ); return familyModel.getQuads( state, facing, rand );
} }
@Override @Override
public boolean useAmbientOcclusion() public boolean useAmbientOcclusion()
{ {
return this.familyModel.useAmbientOcclusion(); return familyModel.useAmbientOcclusion();
} }
@Override @Override
public boolean hasDepth() public boolean hasDepth()
{ {
return this.familyModel.hasDepth(); return familyModel.hasDepth();
} }
@Override @Override
public boolean isSideLit() public boolean isSideLit()
{ {
return this.familyModel.isSideLit(); return familyModel.isSideLit();
} }
@Override @Override
public boolean isBuiltin() public boolean isBuiltin()
{ {
return this.familyModel.isBuiltin(); return familyModel.isBuiltin();
} }
@Nonnull @Nonnull
@@ -148,7 +148,7 @@ public class TurtleSmartItemModel implements BakedModel
@Deprecated @Deprecated
public Sprite getSprite() public Sprite getSprite()
{ {
return this.familyModel.getSprite(); return familyModel.getSprite();
} }
@Nonnull @Nonnull
@@ -156,14 +156,14 @@ public class TurtleSmartItemModel implements BakedModel
@Deprecated @Deprecated
public ModelTransformation getTransformation() public ModelTransformation getTransformation()
{ {
return this.familyModel.getTransformation(); return familyModel.getTransformation();
} }
@Nonnull @Nonnull
@Override @Override
public ModelOverrideList getOverrides() public ModelOverrideList getOverrides()
{ {
return this.overrides; return overrides;
} }
private static class TurtleModelCombination private static class TurtleModelCombination
@@ -191,12 +191,12 @@ public class TurtleSmartItemModel implements BakedModel
{ {
final int prime = 31; final int prime = 31;
int result = 0; int result = 0;
result = prime * result + (this.colour ? 1 : 0); result = prime * result + (colour ? 1 : 0);
result = prime * result + (this.leftUpgrade != null ? this.leftUpgrade.hashCode() : 0); result = prime * result + (leftUpgrade != null ? leftUpgrade.hashCode() : 0);
result = prime * result + (this.rightUpgrade != null ? this.rightUpgrade.hashCode() : 0); result = prime * result + (rightUpgrade != null ? rightUpgrade.hashCode() : 0);
result = prime * result + (this.overlay != null ? this.overlay.hashCode() : 0); result = prime * result + (overlay != null ? overlay.hashCode() : 0);
result = prime * result + (this.christmas ? 1 : 0); result = prime * result + (christmas ? 1 : 0);
result = prime * result + (this.flip ? 1 : 0); result = prime * result + (flip ? 1 : 0);
return result; return result;
} }
@@ -213,8 +213,8 @@ public class TurtleSmartItemModel implements BakedModel
} }
TurtleModelCombination otherCombo = (TurtleModelCombination) other; TurtleModelCombination otherCombo = (TurtleModelCombination) other;
return otherCombo.colour == this.colour && otherCombo.leftUpgrade == this.leftUpgrade && otherCombo.rightUpgrade == this.rightUpgrade && Objects.equal( return otherCombo.colour == colour && otherCombo.leftUpgrade == leftUpgrade && otherCombo.rightUpgrade == rightUpgrade && Objects.equal(
otherCombo.overlay, this.overlay ) && otherCombo.christmas == this.christmas && otherCombo.flip == this.flip; otherCombo.overlay, overlay ) && otherCombo.christmas == christmas && otherCombo.flip == flip;
} }
} }

View File

@@ -344,11 +344,9 @@ public class FSAPI implements ILuaAPI
return new Object[] { new EncodedWritableHandle( writer.get(), writer ) }; return new Object[] { new EncodedWritableHandle( writer.get(), writer ) };
} }
case "rb": case "rb":
{
// Open the file for binary reading, then create a wrapper around the reader // Open the file for binary reading, then create a wrapper around the reader
FileSystemWrapper<ReadableByteChannel> reader = fileSystem.openForRead( path, Function.identity() ); FileSystemWrapper<ReadableByteChannel> reader = fileSystem.openForRead( path, Function.identity() );
return new Object[] { BinaryReadableHandle.of( reader.get(), reader ) }; return new Object[] { BinaryReadableHandle.of( reader.get(), reader ) };
}
case "wb": case "wb":
{ {
// Open the file for binary writing, then create a wrapper around the writer // 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 ) }; return new Object[] { BinaryWritableHandle.of( writer.get(), writer ) };
} }
case "ab": case "ab":
{
// Open the file for binary appending, then create a wrapper around the reader // Open the file for binary appending, then create a wrapper around the reader
FileSystemWrapper<WritableByteChannel> writer = fileSystem.openForWrite( path, true, Function.identity() ); FileSystemWrapper<WritableByteChannel> writer = fileSystem.openForWrite( path, true, Function.identity() );
return new Object[] { BinaryWritableHandle.of( writer.get(), writer ) }; return new Object[] { BinaryWritableHandle.of( writer.get(), writer ) };
}
default: default:
throw new LuaException( "Unsupported mode" ); throw new LuaException( "Unsupported mode" );
} }

View File

@@ -403,11 +403,9 @@ public class OSAPI implements ILuaAPI
return getEpochForCalendar( c ); return getEpochForCalendar( c );
} }
case "local": case "local":
{
// Get local epoch // Get local epoch
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
return getEpochForCalendar( c ); return getEpochForCalendar( c );
}
case "ingame": case "ingame":
// Get in-game epoch // Get in-game epoch
synchronized( alarms ) synchronized( alarms )

View File

@@ -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. * Note, this may require a DNS lookup, and so should not be executed on the main CC thread.
* *

View File

@@ -66,7 +66,7 @@ public final class Generator<T>
{ {
this.base = base; this.base = base;
this.context = context; this.context = context;
this.interfaces = new String[] { Type.getInternalName( base ) }; interfaces = new String[] { Type.getInternalName( base ) };
this.wrap = wrap; this.wrap = wrap;
StringBuilder methodDesc = new StringBuilder().append( "(Ljava/lang/Object;" ); StringBuilder methodDesc = new StringBuilder().append( "(Ljava/lang/Object;" );

View File

@@ -18,7 +18,7 @@ import static org.objectweb.asm.Opcodes.ICONST_0;
final class Reflect 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() private Reflect()
{ {
@@ -57,7 +57,7 @@ final class Reflect
ParameterizedType type = (ParameterizedType) underlying; ParameterizedType type = (ParameterizedType) underlying;
if( !allowParameter ) if( !allowParameter )
{ {
for( java.lang.reflect.Type arg : type.getActualTypeArguments() ) for( Type arg : type.getActualTypeArguments() )
{ {
if( arg instanceof WildcardType ) continue; if( arg instanceof WildcardType ) continue;
if( arg instanceof TypeVariable && ((TypeVariable<?>) arg).getName().startsWith( "capture#" ) ) if( arg instanceof TypeVariable && ((TypeVariable<?>) arg).getName().startsWith( "capture#" ) )

View File

@@ -313,7 +313,7 @@ public final class ResourceMount implements IMount
prepareProfiler.push( "Mount reloading" ); prepareProfiler.push( "Mount reloading" );
try try
{ {
for( ResourceMount mount : this.mounts ) mount.load(); for( ResourceMount mount : mounts ) mount.load();
} }
finally finally
{ {

View File

@@ -64,7 +64,7 @@ public class CobaltLuaMachine implements ILuaMachine
{ {
this.computer = computer; this.computer = computer;
this.timeout = timeout; this.timeout = timeout;
this.context = new LuaContext( computer ); context = new LuaContext( computer );
debug = new TimeoutDebugHandler(); debug = new TimeoutDebugHandler();
// Create an environment to run in // Create an environment to run in
@@ -367,7 +367,6 @@ public class CobaltLuaMachine implements ILuaMachine
case Constants.TSTRING: case Constants.TSTRING:
return value.toString(); return value.toString();
case Constants.TTABLE: case Constants.TTABLE:
{
// Table: // Table:
// Start remembering stuff // Start remembering stuff
if( objects == null ) if( objects == null )
@@ -409,7 +408,6 @@ public class CobaltLuaMachine implements ILuaMachine
} }
} }
return table; return table;
}
default: default:
return null; return null;
} }

View File

@@ -44,9 +44,9 @@ public class Terminal
this.height = height; this.height = height;
onChanged = changedCallback; onChanged = changedCallback;
text = new TextBuffer[this.height]; text = new TextBuffer[height];
textColour = new TextBuffer[this.height]; textColour = new TextBuffer[height];
backgroundColour = new TextBuffer[this.height]; backgroundColour = new TextBuffer[height];
for( int i = 0; i < this.height; i++ ) for( int i = 0; i < this.height; i++ )
{ {
text[i] = new TextBuffer( ' ', this.width ); text[i] = new TextBuffer( ' ', this.width );
@@ -93,9 +93,9 @@ public class Terminal
this.width = width; this.width = width;
this.height = height; this.height = height;
text = new TextBuffer[this.height]; text = new TextBuffer[height];
textColour = new TextBuffer[this.height]; textColour = new TextBuffer[height];
backgroundColour = new TextBuffer[this.height]; backgroundColour = new TextBuffer[height];
for( int i = 0; i < this.height; i++ ) for( int i = 0; i < this.height; i++ )
{ {
if( i >= oldHeight ) if( i >= oldHeight )

View File

@@ -12,7 +12,7 @@ public class TextBuffer
public TextBuffer( char c, int length ) public TextBuffer( char c, int length )
{ {
text = new char[length]; text = new char[length];
this.fill( c ); fill( c );
} }
public TextBuffer( String text ) public TextBuffer( String text )

View File

@@ -32,7 +32,7 @@ public class MixinWorld
@Inject( method = "setBlockEntity", at = @At( "HEAD" ) ) @Inject( method = "setBlockEntity", at = @At( "HEAD" ) )
public void setBlockEntity( BlockPos pos, @Nullable BlockEntity entity, CallbackInfo info ) 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 ); setWorld( entity, this );
} }
@@ -49,7 +49,7 @@ public class MixinWorld
@Inject( method = "addBlockEntities", at = @At( "HEAD" ) ) @Inject( method = "addBlockEntities", at = @At( "HEAD" ) )
public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info ) public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info )
{ {
if( this.iteratingTickingBlockEntities ) if( iteratingTickingBlockEntities )
{ {
for( BlockEntity entity : entities ) for( BlockEntity entity : entities )
{ {

View File

@@ -27,11 +27,11 @@ public final class TurtleUpgrades
Wrapper( ITurtleUpgrade upgrade ) Wrapper( ITurtleUpgrade upgrade )
{ {
this.upgrade = upgrade; this.upgrade = upgrade;
this.id = upgrade.getUpgradeID() id = upgrade.getUpgradeID()
.toString(); .toString();
// TODO This should be the mod id of the mod the peripheral comes from // TODO This should be the mod id of the mod the peripheral comes from
this.modId = ComputerCraft.MOD_ID; modId = ComputerCraft.MOD_ID;
this.enabled = true; enabled = true;
} }
} }

View File

@@ -40,7 +40,7 @@ public abstract class ChoiceArgumentType<T> implements ArgumentType<T>
int start = reader.getCursor(); int start = reader.getCursor();
String name = reader.readUnquotedString(); String name = reader.readUnquotedString();
for( T choice : this.choices ) for( T choice : choices )
{ {
String choiceName = this.name.apply( choice ); String choiceName = this.name.apply( choice );
if( name.equals( choiceName ) ) if( name.equals( choiceName ) )
@@ -50,7 +50,7 @@ public abstract class ChoiceArgumentType<T> implements ArgumentType<T>
} }
reader.setCursor( start ); reader.setCursor( start );
throw this.exception.createWithContext( reader, name ); throw exception.createWithContext( reader, name );
} }
@Override @Override
@@ -58,7 +58,7 @@ public abstract class ChoiceArgumentType<T> implements ArgumentType<T>
{ {
String remaining = builder.getRemaining() String remaining = builder.getRemaining()
.toLowerCase( Locale.ROOT ); .toLowerCase( Locale.ROOT );
for( T choice : this.choices ) for( T choice : choices )
{ {
String name = this.name.apply( choice ); String name = this.name.apply( choice );
if( !name.toLowerCase( Locale.ROOT ) if( !name.toLowerCase( Locale.ROOT )
@@ -66,7 +66,7 @@ public abstract class ChoiceArgumentType<T> implements ArgumentType<T>
{ {
continue; continue;
} }
builder.suggest( name, this.tooltip.apply( choice ) ); builder.suggest( name, tooltip.apply( choice ) );
} }
return builder.buildFuture(); return builder.buildFuture();
@@ -75,10 +75,10 @@ public abstract class ChoiceArgumentType<T> implements ArgumentType<T>
@Override @Override
public Collection<String> getExamples() public Collection<String> getExamples()
{ {
List<String> items = this.choices instanceof Collection<?> ? new ArrayList<>( ((Collection<T>) this.choices).size() ) : new ArrayList<>(); List<String> items = choices instanceof Collection<?> ? new ArrayList<>( ((Collection<T>) choices).size() ) : new ArrayList<>();
for( T choice : this.choices ) for( T choice : choices )
{ {
items.add( this.name.apply( choice ) ); items.add( name.apply( choice ) );
} }
items.sort( Comparator.naturalOrder() ); items.sort( Comparator.naturalOrder() );
return items; return items;

View File

@@ -105,7 +105,7 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume
}; };
} }
if( this.requireSome ) if( requireSome )
{ {
String selector = reader.getString() String selector = reader.getString()
.substring( start, reader.getCursor() ); .substring( start, reader.getCursor() );

View File

@@ -79,12 +79,12 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
} }
int startParse = reader.getCursor(); int startParse = reader.getCursor();
this.appender.accept( out, this.child.parse( reader ) ); appender.accept( out, child.parse( reader ) );
hadSome = true; hadSome = true;
if( reader.getCursor() == startParse ) 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<T, U> implements ArgumentType<List<T>>
// We should probably review that this is sensible in the future. // We should probably review that this is sensible in the future.
if( !hadSome ) if( !hadSome )
{ {
throw this.some.createWithContext( reader ); throw some.createWithContext( reader );
} }
return Collections.unmodifiableList( out ); return Collections.unmodifiableList( out );
@@ -109,7 +109,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
{ {
try try
{ {
this.child.parse( reader ); child.parse( reader );
} }
catch( CommandSyntaxException e ) catch( CommandSyntaxException e )
{ {
@@ -126,13 +126,13 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
} }
reader.setCursor( previous ); reader.setCursor( previous );
return this.child.listSuggestions( context, builder.createOffset( previous ) ); return child.listSuggestions( context, builder.createOffset( previous ) );
} }
@Override @Override
public Collection<String> getExamples() public Collection<String> getExamples()
{ {
return this.child.getExamples(); return child.getExamples();
} }
public static class Serializer implements ArgumentSerializer<RepeatArgumentType<?, ?>> public static class Serializer implements ArgumentSerializer<RepeatArgumentType<?, ?>>

View File

@@ -48,58 +48,58 @@ public class CommandBuilder<S> implements CommandNodeBuilder<S, Command<S>>
public CommandBuilder<S> requires( Predicate<S> predicate ) public CommandBuilder<S> requires( Predicate<S> predicate )
{ {
this.requires = this.requires == null ? predicate : this.requires.and( predicate ); requires = requires == null ? predicate : requires.and( predicate );
return this; return this;
} }
public CommandBuilder<S> arg( String name, ArgumentType<?> type ) public CommandBuilder<S> arg( String name, ArgumentType<?> type )
{ {
this.args.add( RequiredArgumentBuilder.argument( name, type ) ); args.add( RequiredArgumentBuilder.argument( name, type ) );
return this; return this;
} }
public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyValue( String name, ArgumentType<T> type, T defaultValue ) public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyValue( String name, ArgumentType<T> type, T defaultValue )
{ {
return this.argManyValue( name, type, Collections.singletonList( defaultValue ) ); return argManyValue( name, type, Collections.singletonList( defaultValue ) );
} }
public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyValue( String name, ArgumentType<T> type, List<T> empty ) public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyValue( String name, ArgumentType<T> type, List<T> empty )
{ {
return this.argMany( name, type, () -> empty ); return argMany( name, type, () -> empty );
} }
public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argMany( String name, ArgumentType<T> type, Supplier<List<T>> empty ) public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argMany( String name, ArgumentType<T> type, Supplier<List<T>> empty )
{ {
return this.argMany( name, RepeatArgumentType.some( type, ARGUMENT_EXPECTED ), empty ); return argMany( name, RepeatArgumentType.some( type, ARGUMENT_EXPECTED ), empty );
} }
private <T, U> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argMany( String name, RepeatArgumentType<T, ?> type, Supplier<List<T>> empty ) private <T, U> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argMany( String name, RepeatArgumentType<T, ?> type, Supplier<List<T>> empty )
{ {
if( this.args.isEmpty() ) if( args.isEmpty() )
{ {
throw new IllegalStateException( "Cannot have empty arg chain builder" ); throw new IllegalStateException( "Cannot have empty arg chain builder" );
} }
return command -> { return command -> {
// The node for no arguments // The node for no arguments
ArgumentBuilder<S, ?> tail = this.tail( ctx -> command.run( ctx, empty.get() ) ); ArgumentBuilder<S, ?> tail = tail( ctx -> command.run( ctx, empty.get() ) );
// The node for one or more arguments // The node for one or more arguments
ArgumentBuilder<S, ?> moreArg = RequiredArgumentBuilder.<S, List<T>>argument( name, type ).executes( ctx -> command.run( ctx, getList( ctx, name ) ) ); ArgumentBuilder<S, ?> moreArg = RequiredArgumentBuilder.<S, List<T>>argument( name, type ).executes( ctx -> command.run( ctx, getList( ctx, name ) ) );
// Chain all of them together! // Chain all of them together!
tail.then( moreArg ); tail.then( moreArg );
return this.link( tail ); return link( tail );
}; };
} }
private ArgumentBuilder<S, ?> tail( Command<S> command ) private ArgumentBuilder<S, ?> tail( Command<S> command )
{ {
ArgumentBuilder<S, ?> defaultTail = this.args.get( this.args.size() - 1 ); ArgumentBuilder<S, ?> defaultTail = args.get( args.size() - 1 );
defaultTail.executes( command ); defaultTail.executes( command );
if( this.requires != null ) if( requires != null )
{ {
defaultTail.requires( this.requires ); defaultTail.requires( requires );
} }
return defaultTail; return defaultTail;
} }
@@ -112,9 +112,9 @@ public class CommandBuilder<S> implements CommandNodeBuilder<S, Command<S>>
private CommandNode<S> link( ArgumentBuilder<S, ?> tail ) private CommandNode<S> link( ArgumentBuilder<S, ?> 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 ); .then( tail );
} }
return tail.build(); return tail.build();
@@ -122,17 +122,17 @@ public class CommandBuilder<S> implements CommandNodeBuilder<S, Command<S>>
public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyFlatten( String name, ArgumentType<List<T>> type, Supplier<List<T>> empty ) public <T> CommandNodeBuilder<S, ArgCommand<S, List<T>>> argManyFlatten( String name, ArgumentType<List<T>> type, Supplier<List<T>> empty )
{ {
return this.argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty ); return argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty );
} }
@Override @Override
public CommandNode<S> executes( Command<S> command ) public CommandNode<S> executes( Command<S> command )
{ {
if( this.args.isEmpty() ) if( args.isEmpty() )
{ {
throw new IllegalStateException( "Cannot have empty arg chain builder" ); throw new IllegalStateException( "Cannot have empty arg chain builder" );
} }
return this.link( this.tail( command ) ); return link( tail( command ) );
} }
} }

View File

@@ -107,14 +107,14 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
@Override @Override
public LiteralArgumentBuilder<ServerCommandSource> then( final ArgumentBuilder<ServerCommandSource, ?> argument ) public LiteralArgumentBuilder<ServerCommandSource> then( final ArgumentBuilder<ServerCommandSource, ?> argument )
{ {
if( this.getRedirect() != null ) if( getRedirect() != null )
{ {
throw new IllegalStateException( "Cannot add children to a redirected node" ); throw new IllegalStateException( "Cannot add children to a redirected node" );
} }
if( argument instanceof HelpingArgumentBuilder ) if( argument instanceof HelpingArgumentBuilder )
{ {
this.children.add( (HelpingArgumentBuilder) argument ); children.add( (HelpingArgumentBuilder) argument );
} }
else if( argument instanceof LiteralArgumentBuilder ) else if( argument instanceof LiteralArgumentBuilder )
{ {
@@ -147,25 +147,25 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
@Override @Override
public LiteralCommandNode<ServerCommandSource> build() public LiteralCommandNode<ServerCommandSource> build()
{ {
return this.buildImpl( this.getLiteral().replace( '-', '_' ), this.getLiteral() ); return buildImpl( getLiteral().replace( '-', '_' ), getLiteral() );
} }
private LiteralCommandNode<ServerCommandSource> build( @Nonnull String id, @Nonnull String command ) private LiteralCommandNode<ServerCommandSource> 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<ServerCommandSource> buildImpl( String id, String command ) private LiteralCommandNode<ServerCommandSource> buildImpl( String id, String command )
{ {
HelpCommand helpCommand = new HelpCommand( id, command ); HelpCommand helpCommand = new HelpCommand( id, command );
LiteralCommandNode<ServerCommandSource> node = new LiteralCommandNode<>( this.getLiteral(), LiteralCommandNode<ServerCommandSource> node = new LiteralCommandNode<>( getLiteral(),
helpCommand, this.getRequirement(), helpCommand, getRequirement(),
this.getRedirect(), this.getRedirectModifier(), this.isFork() ); getRedirect(), getRedirectModifier(), isFork() );
helpCommand.node = node; helpCommand.node = node;
// Set up a /... help command // Set up a /... help command
LiteralArgumentBuilder<ServerCommandSource> helpNode = LiteralArgumentBuilder<ServerCommandSource> helpNode =
LiteralArgumentBuilder.<ServerCommandSource>literal( "help" ).requires( x -> this.getArguments().stream() LiteralArgumentBuilder.<ServerCommandSource>literal( "help" ).requires( x -> getArguments().stream()
.anyMatch( .anyMatch(
y -> y.getRequirement() y -> y.getRequirement()
.test( .test(
@@ -173,7 +173,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
.executes( helpCommand ); .executes( helpCommand );
// Add all normal command children to this and the help node // Add all normal command children to this and the help node
for( CommandNode<ServerCommandSource> child : this.getArguments() ) for( CommandNode<ServerCommandSource> child : getArguments() )
{ {
node.addChild( child ); node.addChild( child );
@@ -183,7 +183,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
} }
// And add alternative versions of which forward instead // And add alternative versions of which forward instead
for( HelpingArgumentBuilder childBuilder : this.children ) for( HelpingArgumentBuilder childBuilder : children )
{ {
LiteralCommandNode<ServerCommandSource> child = childBuilder.build( id, command ); LiteralCommandNode<ServerCommandSource> child = childBuilder.build( id, command );
node.addChild( child ); node.addChild( child );
@@ -214,7 +214,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
public int run( CommandContext<ServerCommandSource> context ) public int run( CommandContext<ServerCommandSource> context )
{ {
context.getSource() context.getSource()
.sendFeedback( getHelp( context, this.node, this.id, this.command ), false ); .sendFeedback( getHelp( context, node, id, command ), false );
return 0; return 0;
} }
} }

View File

@@ -26,7 +26,7 @@ public class ServerTableFormatter implements TableFormatter
@Nullable @Nullable
public Text getPadding( Text component, int width ) public Text getPadding( Text component, int width )
{ {
int extraWidth = width - this.getWidth( component ); int extraWidth = width - getWidth( component );
if( extraWidth <= 0 ) if( extraWidth <= 0 )
{ {
return null; return null;
@@ -50,6 +50,6 @@ public class ServerTableFormatter implements TableFormatter
@Override @Override
public void writeLine( int id, Text component ) public void writeLine( int id, Text component )
{ {
this.source.sendFeedback( component, false ); source.sendFeedback( component, false );
} }
} }

View File

@@ -34,7 +34,7 @@ public class TableBuilder
} }
this.id = id; this.id = id;
this.headers = headers; this.headers = headers;
this.columns = headers.length; columns = headers.length;
} }
public TableBuilder( int id ) public TableBuilder( int id )
@@ -44,7 +44,7 @@ public class TableBuilder
throw new IllegalArgumentException( "ID must be positive" ); throw new IllegalArgumentException( "ID must be positive" );
} }
this.id = id; this.id = id;
this.headers = null; headers = null;
} }
public TableBuilder( int id, @Nonnull String... headers ) public TableBuilder( int id, @Nonnull String... headers )
@@ -55,7 +55,7 @@ public class TableBuilder
} }
this.id = id; this.id = id;
this.headers = new Text[headers.length]; this.headers = new Text[headers.length];
this.columns = headers.length; columns = headers.length;
for( int i = 0; i < headers.length; i++ ) for( int i = 0; i < headers.length; i++ )
{ {
@@ -65,15 +65,15 @@ public class TableBuilder
public void row( @Nonnull Text... row ) 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" ); 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() public int getId()
{ {
return this.id; return id;
} }
/** /**
@@ -97,24 +97,24 @@ public class TableBuilder
*/ */
public int getColumns() public int getColumns()
{ {
return this.columns; return columns;
} }
@Nullable @Nullable
public Text[] getHeaders() public Text[] getHeaders()
{ {
return this.headers; return headers;
} }
@Nonnull @Nonnull
public List<Text[]> getRows() public List<Text[]> getRows()
{ {
return this.rows; return rows;
} }
public int getAdditional() public int getAdditional()
{ {
return this.additional; return additional;
} }
public void setAdditional( int additional ) public void setAdditional( int additional )
@@ -126,12 +126,12 @@ public class TableBuilder
{ {
if( CommandUtils.isPlayer( source ) ) if( CommandUtils.isPlayer( source ) )
{ {
this.trim( 18 ); trim( 18 );
NetworkHandler.sendToPlayer( (ServerPlayerEntity) source.getEntity(), new ChatTableClientMessage( this ) ); NetworkHandler.sendToPlayer( (ServerPlayerEntity) source.getEntity(), new ChatTableClientMessage( this ) );
} }
else else
{ {
this.trim( 100 ); trim( 100 );
new ServerTableFormatter( source ).display( this ); new ServerTableFormatter( source ).display( this );
} }
} }
@@ -143,10 +143,10 @@ public class TableBuilder
*/ */
public void trim( int height ) public void trim( int height )
{ {
if( this.rows.size() > height ) if( rows.size() > height )
{ {
this.additional += this.rows.size() - height - 1; additional += rows.size() - height - 1;
this.rows.subList( height - 1, this.rows.size() ) rows.subList( height - 1, rows.size() )
.clear(); .clear();
} }
} }

View File

@@ -37,7 +37,7 @@ public interface TableFormatter
{ {
for( int i = 0; i < columns; i++ ) 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++ ) for( int i = 0; i < row.length; i++ )
{ {
int width = this.getWidth( row[i] ); int width = getWidth( row[i] );
if( width > maxWidths[i] ) if( width > maxWidths[i] )
{ {
maxWidths[i] = width; maxWidths[i] = width;
@@ -55,7 +55,7 @@ public interface TableFormatter
// Add a small amount of padding after each column // 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++ ) for( int i = 0; i < maxWidths.length - 1; i++ )
{ {
maxWidths[i] += padding; maxWidths[i] += padding;
@@ -63,7 +63,7 @@ public interface TableFormatter
} }
// And compute the total width // And compute the total width
int totalWidth = (columns - 1) * this.getWidth( SEPARATOR ); int totalWidth = (columns - 1) * getWidth( SEPARATOR );
for( int x : maxWidths ) for( int x : maxWidths )
{ {
totalWidth += x; totalWidth += x;
@@ -75,7 +75,7 @@ public interface TableFormatter
for( int i = 0; i < columns - 1; i++ ) for( int i = 0; i < columns - 1; i++ )
{ {
line.append( headers[i] ); line.append( headers[i] );
Text padding = this.getPadding( headers[i], maxWidths[i] ); Text padding = getPadding( headers[i], maxWidths[i] );
if( padding != null ) if( padding != null )
{ {
line.append( padding ); line.append( padding );
@@ -84,13 +84,13 @@ public interface TableFormatter
} }
line.append( headers[columns - 1] ); 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 // Write a separator line. We round the width up rather than down to make
// it a tad prettier. // it a tad prettier.
int rowCharWidth = this.getWidth( HEADER ); int rowCharWidth = getWidth( HEADER );
int rowWidth = totalWidth / rowCharWidth + (totalWidth % rowCharWidth == 0 ? 0 : 1); 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() ) for( Text[] row : table.getRows() )
@@ -99,7 +99,7 @@ public interface TableFormatter
for( int i = 0; i < columns - 1; i++ ) for( int i = 0; i < columns - 1; i++ )
{ {
line.append( row[i] ); line.append( row[i] );
Text padding = this.getPadding( row[i], maxWidths[i] ); Text padding = getPadding( row[i], maxWidths[i] );
if( padding != null ) if( padding != null )
{ {
line.append( padding ); line.append( padding );
@@ -107,12 +107,12 @@ public interface TableFormatter
line.append( SEPARATOR ); line.append( SEPARATOR );
} }
line.append( row[columns - 1] ); line.append( row[columns - 1] );
this.writeLine( rowId++, line ); writeLine( rowId++, line );
} }
if( table.getAdditional() > 0 ) 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(); return rowId - table.getId();

View File

@@ -96,6 +96,6 @@ public abstract class BlockGeneric extends BlockWithEntity
@Override @Override
public BlockEntity createBlockEntity( @Nonnull BlockView world ) public BlockEntity createBlockEntity( @Nonnull BlockView world )
{ {
return this.type.instantiate(); return type.instantiate();
} }
} }

View File

@@ -19,14 +19,14 @@ public class ClientTerminal implements ITerminal
public ClientTerminal( boolean colour ) public ClientTerminal( boolean colour )
{ {
this.colour = colour; this.colour = colour;
this.terminal = null; terminal = null;
this.terminalChanged = false; terminalChanged = false;
} }
public boolean pollTerminalChanged() public boolean pollTerminalChanged()
{ {
boolean changed = this.terminalChanged; boolean changed = terminalChanged;
this.terminalChanged = false; terminalChanged = false;
return changed; return changed;
} }
@@ -35,63 +35,63 @@ public class ClientTerminal implements ITerminal
@Override @Override
public Terminal getTerminal() public Terminal getTerminal()
{ {
return this.terminal; return terminal;
} }
@Override @Override
public boolean isColour() public boolean isColour()
{ {
return this.colour; return colour;
} }
public void read( TerminalState state ) public void read( TerminalState state )
{ {
this.colour = state.colour; colour = state.colour;
if( state.hasTerminal() ) if( state.hasTerminal() )
{ {
this.resizeTerminal( state.width, state.height ); resizeTerminal( state.width, state.height );
state.apply( this.terminal ); state.apply( terminal );
} }
else else
{ {
this.deleteTerminal(); deleteTerminal();
} }
} }
private void resizeTerminal( int width, int height ) private void resizeTerminal( int width, int height )
{ {
if( this.terminal == null ) if( terminal == null )
{ {
this.terminal = new Terminal( width, height, () -> this.terminalChanged = true ); terminal = new Terminal( width, height, () -> terminalChanged = true );
this.terminalChanged = true; terminalChanged = true;
} }
else else
{ {
this.terminal.resize( width, height ); terminal.resize( width, height );
} }
} }
private void deleteTerminal() private void deleteTerminal()
{ {
if( this.terminal != null ) if( terminal != null )
{ {
this.terminal = null; terminal = null;
this.terminalChanged = true; terminalChanged = true;
} }
} }
public void readDescription( CompoundTag nbt ) public void readDescription( CompoundTag nbt )
{ {
this.colour = nbt.getBoolean( "colour" ); colour = nbt.getBoolean( "colour" );
if( nbt.contains( "terminal" ) ) if( nbt.contains( "terminal" ) )
{ {
CompoundTag terminal = nbt.getCompound( "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 ); this.terminal.readFromNBT( terminal );
} }
else else
{ {
this.deleteTerminal(); deleteTerminal();
} }
} }
} }

View File

@@ -13,7 +13,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@@ -33,7 +32,7 @@ public class ContainerHeldItem extends ScreenHandler
super( type, id ); super( type, id );
this.hand = hand; this.hand = hand;
this.stack = player.getStackInHand( hand ) stack = player.getStackInHand( hand )
.copy(); .copy();
} }
@@ -50,7 +49,7 @@ public class ContainerHeldItem extends ScreenHandler
@Nonnull @Nonnull
public ItemStack getStack() public ItemStack getStack()
{ {
return this.stack; return stack;
} }
@Override @Override
@@ -61,11 +60,11 @@ public class ContainerHeldItem extends ScreenHandler
return false; 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(); 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<ContainerHeldItem> type; private final ScreenHandlerType<ContainerHeldItem> type;
private final Text name; private final Text name;
@@ -74,7 +73,7 @@ public class ContainerHeldItem extends ScreenHandler
public Factory( ScreenHandlerType<ContainerHeldItem> type, ItemStack stack, Hand hand ) public Factory( ScreenHandlerType<ContainerHeldItem> type, ItemStack stack, Hand hand )
{ {
this.type = type; this.type = type;
this.name = stack.getName(); name = stack.getName();
this.hand = hand; this.hand = hand;
} }
@@ -82,20 +81,20 @@ public class ContainerHeldItem extends ScreenHandler
@Override @Override
public Text getDisplayName() public Text getDisplayName()
{ {
return this.name; return name;
} }
@Nullable @Nullable
@Override @Override
public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player ) 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 @Override
public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf ) public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf )
{ {
packetByteBuf.writeEnumConstant( this.hand ); packetByteBuf.writeEnumConstant( hand );
} }
} }
} }

View File

@@ -22,73 +22,73 @@ public class ServerTerminal implements ITerminal
public ServerTerminal( boolean colour ) public ServerTerminal( boolean colour )
{ {
this.colour = colour; this.colour = colour;
this.terminal = null; terminal = null;
} }
public ServerTerminal( boolean colour, int terminalWidth, int terminalHeight ) public ServerTerminal( boolean colour, int terminalWidth, int terminalHeight )
{ {
this.colour = colour; this.colour = colour;
this.terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged ); terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged );
} }
protected void markTerminalChanged() protected void markTerminalChanged()
{ {
this.terminalChanged.set( true ); terminalChanged.set( true );
} }
protected void resize( int width, int height ) protected void resize( int width, int height )
{ {
if( this.terminal == null ) if( terminal == null )
{ {
this.terminal = new Terminal( width, height, this::markTerminalChanged ); terminal = new Terminal( width, height, this::markTerminalChanged );
this.markTerminalChanged(); markTerminalChanged();
} }
else else
{ {
this.terminal.resize( width, height ); terminal.resize( width, height );
} }
} }
public void delete() public void delete()
{ {
if( this.terminal != null ) if( terminal != null )
{ {
this.terminal = null; terminal = null;
this.markTerminalChanged(); markTerminalChanged();
} }
} }
public void update() public void update()
{ {
this.terminalChangedLastFrame = this.terminalChanged.getAndSet( false ); terminalChangedLastFrame = terminalChanged.getAndSet( false );
} }
public boolean hasTerminalChanged() public boolean hasTerminalChanged()
{ {
return this.terminalChangedLastFrame; return terminalChangedLastFrame;
} }
@Override @Override
public Terminal getTerminal() public Terminal getTerminal()
{ {
return this.terminal; return terminal;
} }
@Override @Override
public boolean isColour() public boolean isColour()
{ {
return this.colour; return colour;
} }
public TerminalState write() public TerminalState write()
{ {
return new TerminalState( this.colour, this.terminal ); return new TerminalState( colour, terminal );
} }
public void writeDescription( CompoundTag nbt ) public void writeDescription( CompoundTag nbt )
{ {
nbt.putBoolean( "colour", this.colour ); nbt.putBoolean( "colour", colour );
if( this.terminal != null ) if( terminal != null )
{ {
CompoundTag terminal = new CompoundTag(); CompoundTag terminal = new CompoundTag();
terminal.putInt( "term_width", this.terminal.getWidth() ); terminal.putInt( "term_width", this.terminal.getWidth() );

View File

@@ -36,10 +36,10 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
public final void updateBlock() public final void updateBlock()
{ {
this.markDirty(); markDirty();
BlockPos pos = this.getPos(); BlockPos pos = getPos();
BlockState state = this.getCachedState(); BlockState state = getCachedState();
this.getWorld().updateListeners( pos, state, state, 3 ); getWorld().updateListeners( pos, state, state, 3 );
} }
@Nonnull @Nonnull
@@ -62,7 +62,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
public boolean isUsable( PlayerEntity player, boolean ignoreRange ) 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; return false;
} }
@@ -71,9 +71,9 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
return true; return true;
} }
double range = this.getInteractRange( player ); double range = getInteractRange( player );
BlockPos pos = this.getPos(); BlockPos pos = getPos();
return player.getEntityWorld() == this.getWorld() && player.squaredDistanceTo( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range; 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 ) protected double getInteractRange( PlayerEntity player )
@@ -84,7 +84,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
@Override @Override
public void fromClientTag( CompoundTag compoundTag ) public void fromClientTag( CompoundTag compoundTag )
{ {
this.readDescription( compoundTag ); readDescription( compoundTag );
} }
protected void readDescription( @Nonnull CompoundTag nbt ) protected void readDescription( @Nonnull CompoundTag nbt )
@@ -94,7 +94,7 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
@Override @Override
public CompoundTag toClientTag( CompoundTag compoundTag ) public CompoundTag toClientTag( CompoundTag compoundTag )
{ {
this.writeDescription( compoundTag ); writeDescription( compoundTag );
return compoundTag; return compoundTag;
} }

View File

@@ -61,12 +61,12 @@ public class CommandAPI implements ILuaAPI
@LuaFunction( mainThread = true ) @LuaFunction( mainThread = true )
public final Object[] exec( String command ) public final Object[] exec( String command )
{ {
return this.doCommand( command ); return doCommand( command );
} }
private Object[] doCommand( String command ) private Object[] doCommand( String command )
{ {
MinecraftServer server = this.computer.getWorld() MinecraftServer server = computer.getWorld()
.getServer(); .getServer();
if( server == null || !server.areCommandBlocksEnabled() ) if( server == null || !server.areCommandBlocksEnabled() )
{ {
@@ -74,11 +74,11 @@ public class CommandAPI implements ILuaAPI
} }
CommandManager commandManager = server.getCommandManager(); CommandManager commandManager = server.getCommandManager();
TileCommandComputer.CommandReceiver receiver = this.computer.getReceiver(); TileCommandComputer.CommandReceiver receiver = computer.getReceiver();
try try
{ {
receiver.clearOutput(); 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 }; return new Object[] { result > 0, receiver.copyOutput(), result };
} }
catch( Throwable t ) catch( Throwable t )
@@ -118,7 +118,7 @@ public class CommandAPI implements ILuaAPI
@LuaFunction @LuaFunction
public final long execAsync( ILuaContext context, String command ) throws LuaException 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 ) @LuaFunction( mainThread = true )
public final List<String> list( IArguments args ) throws LuaException public final List<String> list( IArguments args ) throws LuaException
{ {
MinecraftServer server = this.computer.getWorld() MinecraftServer server = computer.getWorld()
.getServer(); .getServer();
if( server == null ) if( server == null )
@@ -176,7 +176,7 @@ public class CommandAPI implements ILuaAPI
public final Object[] getBlockPosition() public final Object[] getBlockPosition()
{ {
// This is probably safe to do on the Lua thread. Probably. // 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() }; return new Object[] { pos.getX(), pos.getY(), pos.getZ() };
} }
@@ -201,7 +201,7 @@ public class CommandAPI implements ILuaAPI
public final List<Map<?, ?>> getBlockInfos( int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) throws LuaException public final List<Map<?, ?>> getBlockInfos( int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) throws LuaException
{ {
// Get the details of the block // 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 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 ) ); BlockPos max = new BlockPos( Math.max( minX, maxX ), Math.max( minY, maxY ), Math.max( minZ, maxZ ) );
if( !World.isInBuildLimit( min ) || !World.isInBuildLimit( max ) ) 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 public final Map<?, ?> getBlockInfo( int x, int y, int z ) throws LuaException
{ {
// Get the details of the block // Get the details of the block
World world = this.computer.getWorld(); World world = computer.getWorld();
BlockPos position = new BlockPos( x, y, z ); BlockPos position = new BlockPos( x, y, z );
if( World.isInBuildLimit( position ) ) if( World.isInBuildLimit( position ) )
{ {

View File

@@ -31,7 +31,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
public BlockComputer( Settings settings, ComputerFamily family, BlockEntityType<? extends TileComputer> type ) public BlockComputer( Settings settings, ComputerFamily family, BlockEntityType<? extends TileComputer> type )
{ {
super( settings, family, type ); super( settings, family, type );
this.setDefaultState( this.getDefaultState().with( FACING, Direction.NORTH ) setDefaultState( getDefaultState().with( FACING, Direction.NORTH )
.with( STATE, ComputerState.OFF ) ); .with( STATE, ComputerState.OFF ) );
} }
@@ -39,7 +39,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
@Override @Override
public BlockState getPlacementState( ItemPlacementContext placement ) public BlockState getPlacementState( ItemPlacementContext placement )
{ {
return this.getDefaultState().with( FACING, return getDefaultState().with( FACING,
placement.getPlayerFacing() placement.getPlayerFacing()
.getOpposite() ); .getOpposite() );
} }

View File

@@ -69,7 +69,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
@Deprecated @Deprecated
public int getWeakRedstonePower( @Nonnull BlockState state, @Nonnull BlockView world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide ) 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 @Override
@@ -95,7 +95,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
public ComputerFamily getFamily() public ComputerFamily getFamily()
{ {
return this.family; return family;
} }
@Override @Override
@@ -165,7 +165,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
BlockEntity tile = world.getBlockEntity( pos ); BlockEntity tile = world.getBlockEntity( pos );
if( tile instanceof TileComputerBase ) if( tile instanceof TileComputerBase )
{ {
ItemStack result = this.getItem( (TileComputerBase) tile ); ItemStack result = getItem( (TileComputerBase) tile );
if( !result.isEmpty() ) if( !result.isEmpty() )
{ {
return result; return result;
@@ -202,7 +202,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
.parameter( LootContextParameters.TOOL, player.getMainHandStack() ) .parameter( LootContextParameters.TOOL, player.getMainHandStack() )
.parameter( LootContextParameters.THIS_ENTITY, player ) .parameter( LootContextParameters.THIS_ENTITY, player )
.parameter( LootContextParameters.BLOCK_ENTITY, tile ) .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 ) ) for( ItemStack item : state.getDroppedStacks( context ) )
{ {
dropStack( world, pos, item ); dropStack( world, pos, item );

View File

@@ -36,20 +36,20 @@ public class ComputerPeripheral implements IPeripheral
@Override @Override
public String getType() public String getType()
{ {
return this.type; return type;
} }
@Nonnull @Nonnull
@Override @Override
public Object getTarget() public Object getTarget()
{ {
return this.computer.getTile(); return computer.getTile();
} }
@Override @Override
public boolean equals( IPeripheral other ) 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 @LuaFunction
public final void turnOn() public final void turnOn()
{ {
this.computer.turnOn(); computer.turnOn();
} }
/** /**
@@ -67,7 +67,7 @@ public class ComputerPeripheral implements IPeripheral
@LuaFunction @LuaFunction
public final void shutdown() public final void shutdown()
{ {
this.computer.shutdown(); computer.shutdown();
} }
/** /**
@@ -76,7 +76,7 @@ public class ComputerPeripheral implements IPeripheral
@LuaFunction @LuaFunction
public final void reboot() public final void reboot()
{ {
this.computer.reboot(); computer.reboot();
} }
/** /**
@@ -88,7 +88,7 @@ public class ComputerPeripheral implements IPeripheral
@LuaFunction @LuaFunction
public final int getID() public final int getID()
{ {
return this.computer.assignID(); return computer.assignID();
} }
/** /**
@@ -99,7 +99,7 @@ public class ComputerPeripheral implements IPeripheral
@LuaFunction @LuaFunction
public final boolean isOn() public final boolean isOn()
{ {
return this.computer.isOn(); return computer.isOn();
} }
/** /**
@@ -112,6 +112,6 @@ public class ComputerPeripheral implements IPeripheral
@LuaFunction @LuaFunction
public final String getLabel() public final String getLabel()
{ {
return this.computer.getLabel(); return computer.getLabel();
} }
} }

View File

@@ -25,7 +25,7 @@ public class ComputerProxy
public void turnOn() public void turnOn()
{ {
TileComputerBase tile = this.getTile(); TileComputerBase tile = getTile();
ServerComputer computer = tile.getServerComputer(); ServerComputer computer = tile.getServerComputer();
if( computer == null ) if( computer == null )
{ {
@@ -39,12 +39,12 @@ public class ComputerProxy
protected TileComputerBase getTile() protected TileComputerBase getTile()
{ {
return this.get.get(); return get.get();
} }
public void shutdown() public void shutdown()
{ {
TileComputerBase tile = this.getTile(); TileComputerBase tile = getTile();
ServerComputer computer = tile.getServerComputer(); ServerComputer computer = tile.getServerComputer();
if( computer == null ) if( computer == null )
{ {
@@ -58,7 +58,7 @@ public class ComputerProxy
public void reboot() public void reboot()
{ {
TileComputerBase tile = this.getTile(); TileComputerBase tile = getTile();
ServerComputer computer = tile.getServerComputer(); ServerComputer computer = tile.getServerComputer();
if( computer == null ) if( computer == null )
{ {
@@ -72,20 +72,20 @@ public class ComputerProxy
public int assignID() public int assignID()
{ {
TileComputerBase tile = this.getTile(); TileComputerBase tile = getTile();
ServerComputer computer = tile.getServerComputer(); ServerComputer computer = tile.getServerComputer();
return computer == null ? tile.getComputerID() : computer.getID(); return computer == null ? tile.getComputerID() : computer.getID();
} }
public boolean isOn() public boolean isOn()
{ {
ServerComputer computer = this.getTile().getServerComputer(); ServerComputer computer = getTile().getServerComputer();
return computer != null && computer.isOn(); return computer != null && computer.isOn();
} }
public String getLabel() public String getLabel()
{ {
TileComputerBase tile = this.getTile(); TileComputerBase tile = getTile();
ServerComputer computer = tile.getServerComputer(); ServerComputer computer = tile.getServerComputer();
return computer == null ? tile.getLabel() : computer.getLabel(); return computer == null ? tile.getLabel() : computer.getLabel();
} }

View File

@@ -35,17 +35,17 @@ public class TileCommandComputer extends TileComputer
public TileCommandComputer( ComputerFamily family, BlockEntityType<? extends TileCommandComputer> type ) public TileCommandComputer( ComputerFamily family, BlockEntityType<? extends TileCommandComputer> type )
{ {
super( family, type ); super( family, type );
this.receiver = new CommandReceiver(); receiver = new CommandReceiver();
} }
public CommandReceiver getReceiver() public CommandReceiver getReceiver()
{ {
return this.receiver; return receiver;
} }
public ServerCommandSource getSource() public ServerCommandSource getSource()
{ {
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
String name = "@"; String name = "@";
if( computer != null ) if( computer != null )
{ {
@@ -56,14 +56,14 @@ public class TileCommandComputer extends TileComputer
} }
} }
return new ServerCommandSource( this.receiver, return new ServerCommandSource( receiver,
new Vec3d( this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5 ), new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ),
Vec2f.ZERO, Vec2f.ZERO,
(ServerWorld) this.getWorld(), (ServerWorld) getWorld(),
2, 2,
name, name,
new LiteralText( name ), new LiteralText( name ),
this.getWorld().getServer(), getWorld().getServer(),
null ); null );
} }
@@ -105,29 +105,29 @@ public class TileCommandComputer extends TileComputer
public void clearOutput() public void clearOutput()
{ {
this.output.clear(); output.clear();
} }
public Map<Integer, String> getOutput() public Map<Integer, String> getOutput()
{ {
return this.output; return output;
} }
public Map<Integer, String> copyOutput() public Map<Integer, String> copyOutput()
{ {
return new HashMap<>( this.output ); return new HashMap<>( output );
} }
@Override @Override
public void sendSystemMessage( @Nonnull Text textComponent, @Nonnull UUID id ) 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 @Override
public boolean shouldReceiveFeedback() public boolean shouldReceiveFeedback()
{ {
return TileCommandComputer.this.getWorld().getGameRules() return getWorld().getGameRules()
.getBoolean( GameRules.SEND_COMMAND_FEEDBACK ); .getBoolean( GameRules.SEND_COMMAND_FEEDBACK );
} }
@@ -140,7 +140,7 @@ public class TileCommandComputer extends TileComputer
@Override @Override
public boolean shouldBroadcastConsoleToOps() public boolean shouldBroadcastConsoleToOps()
{ {
return TileCommandComputer.this.getWorld().getGameRules() return getWorld().getGameRules()
.getBoolean( GameRules.COMMAND_BLOCK_OUTPUT ); .getBoolean( GameRules.COMMAND_BLOCK_OUTPUT );
} }
} }

View File

@@ -33,23 +33,23 @@ public class TileComputer extends TileComputerBase
public boolean isUsableByPlayer( PlayerEntity player ) public boolean isUsableByPlayer( PlayerEntity player )
{ {
return this.isUsable( player, false ); return isUsable( player, false );
} }
@Override @Override
protected void updateBlockState( ComputerState newState ) protected void updateBlockState( ComputerState newState )
{ {
BlockState existing = this.getCachedState(); BlockState existing = getCachedState();
if( existing.get( BlockComputer.STATE ) != newState ) 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 @Override
public Direction getDirection() public Direction getDirection()
{ {
return this.getCachedState().get( BlockComputer.FACING ); return getCachedState().get( BlockComputer.FACING );
} }
@Override @Override
@@ -71,23 +71,23 @@ public class TileComputer extends TileComputerBase
@Override @Override
protected ServerComputer createComputer( int instanceID, int id ) protected ServerComputer createComputer( int instanceID, int id )
{ {
ComputerFamily family = this.getFamily(); ComputerFamily family = getFamily();
ServerComputer computer = new ServerComputer( this.getWorld(), ServerComputer computer = new ServerComputer( getWorld(),
id, this.label, id, label,
instanceID, instanceID,
family, family,
ComputerCraft.computerTermWidth, ComputerCraft.computerTermWidth,
ComputerCraft.computerTermHeight ); ComputerCraft.computerTermHeight );
computer.setPosition( this.getPos() ); computer.setPosition( getPos() );
return computer; return computer;
} }
@Override @Override
public ComputerProxy createProxy() public ComputerProxy createProxy()
{ {
if( this.proxy == null ) if( proxy == null )
{ {
this.proxy = new ComputerProxy( () -> this ) proxy = new ComputerProxy( () -> this )
{ {
@Override @Override
protected TileComputerBase getTile() protected TileComputerBase getTile()
@@ -96,7 +96,7 @@ public class TileComputer extends TileComputerBase
} }
}; };
} }
return this.proxy; return proxy;
} }
@Nullable @Nullable

View File

@@ -30,7 +30,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@@ -48,7 +47,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Objects; 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 ExtendedScreenHandlerFactory
{ {
private static final String NBT_ID = "ComputerId"; private static final String NBT_ID = "ComputerId";
@@ -71,10 +70,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public void destroy() public void destroy()
{ {
this.unload(); unload();
for( Direction dir : DirectionUtil.FACINGS ) 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() 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 ) public ActionResult onActivate( PlayerEntity player, Hand hand, BlockHitResult hit )
{ {
ItemStack currentItem = player.getStackInHand( hand ); 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 // Label to rename computer
if( !this.getWorld().isClient ) if( !getWorld().isClient )
{ {
this.setLabel( currentItem.getName() setLabel( currentItem.getName()
.getString() ); .getString() );
currentItem.decrement( 1 ); currentItem.decrement( 1 );
} }
@@ -115,11 +114,11 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
else if( !player.isInSneakingPose() ) else if( !player.isInSneakingPose() )
{ {
// Regular right click to activate computer // Regular right click to activate computer
if( !this.getWorld().isClient && this.isUsable( player, false ) ) if( !getWorld().isClient && isUsable( player, false ) )
{ {
this.createServerComputer().turnOn(); createServerComputer().turnOn();
this.createServerComputer().sendTerminalState( player ); createServerComputer().sendTerminalState( player );
new ComputerContainerData( this.createServerComputer() ).open( player, this ); new ComputerContainerData( createServerComputer() ).open( player, this );
} }
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
@@ -133,48 +132,48 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
public ServerComputer createServerComputer() public ServerComputer createServerComputer()
{ {
if( this.getWorld().isClient ) if( getWorld().isClient )
{ {
return null; return null;
} }
boolean changed = false; boolean changed = false;
if( this.instanceID < 0 ) if( instanceID < 0 )
{ {
this.instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID(); instanceID = ComputerCraft.serverComputerRegistry.getUnusedInstanceID();
changed = true; changed = true;
} }
if( !ComputerCraft.serverComputerRegistry.contains( this.instanceID ) ) if( !ComputerCraft.serverComputerRegistry.contains( instanceID ) )
{ {
ServerComputer computer = this.createComputer( this.instanceID, this.computerID ); ServerComputer computer = createComputer( instanceID, computerID );
ComputerCraft.serverComputerRegistry.add( this.instanceID, computer ); ComputerCraft.serverComputerRegistry.add( instanceID, computer );
this.fresh = true; fresh = true;
changed = true; changed = true;
} }
if( changed ) if( changed )
{ {
this.updateBlock(); updateBlock();
this.updateInput(); updateInput();
} }
return ComputerCraft.serverComputerRegistry.get( this.instanceID ); return ComputerCraft.serverComputerRegistry.get( instanceID );
} }
public ServerComputer getServerComputer() 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 ); protected abstract ServerComputer createComputer( int instanceID, int id );
public void updateInput() public void updateInput()
{ {
if( this.getWorld() == null || this.getWorld().isClient ) if( getWorld() == null || getWorld().isClient )
{ {
return; return;
} }
// Update all sides // Update all sides
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
if( computer == null ) if( computer == null )
{ {
return; return;
@@ -183,27 +182,27 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
BlockPos pos = computer.getPosition(); BlockPos pos = computer.getPosition();
for( Direction dir : DirectionUtil.FACINGS ) 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 ) private void updateSideInput( ServerComputer computer, Direction dir, BlockPos offset )
{ {
Direction offsetSide = dir.getOpposite(); Direction offsetSide = dir.getOpposite();
ComputerSide localDir = this.remapToLocalSide( dir ); ComputerSide localDir = remapToLocalSide( dir );
computer.setRedstoneInput( localDir, getRedstoneInput( this.world, offset, dir ) ); computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) );
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( this.getWorld(), offset, offsetSide ) ); computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) );
if( !this.isPeripheralBlockedOnSide( localDir ) ) if( !isPeripheralBlockedOnSide( localDir ) )
{ {
IPeripheral peripheral = Peripherals.getPeripheral( this.getWorld(), offset, offsetSide ); IPeripheral peripheral = Peripherals.getPeripheral( getWorld(), offset, offsetSide );
computer.setPeripheral( localDir, peripheral ); computer.setPeripheral( localDir, peripheral );
} }
} }
protected ComputerSide remapToLocalSide( Direction globalSide ) 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 @Override
public void onNeighbourChange( @Nonnull BlockPos neighbour ) public void onNeighbourChange( @Nonnull BlockPos neighbour )
{ {
this.updateInput( neighbour ); updateInput( neighbour );
} }
@Override @Override
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
{ {
this.updateInput( neighbour ); updateInput( neighbour );
} }
@Override @Override
protected void readDescription( @Nonnull CompoundTag nbt ) protected void readDescription( @Nonnull CompoundTag nbt )
{ {
super.readDescription( nbt ); super.readDescription( nbt );
this.label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null;
this.computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
} }
@Override @Override
protected void writeDescription( @Nonnull CompoundTag nbt ) protected void writeDescription( @Nonnull CompoundTag nbt )
{ {
super.writeDescription( 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 @Override
public void tick() public void tick()
{ {
if( !this.getWorld().isClient ) if( !getWorld().isClient )
{ {
ServerComputer computer = this.createServerComputer(); ServerComputer computer = createServerComputer();
if( computer == null ) if( computer == null )
{ {
return; return;
} }
// If the computer isn't on and should be, then turn it on // 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(); computer.turnOn();
this.startOn = false; startOn = false;
} }
computer.keepAlive(); computer.keepAlive();
this.fresh = false; fresh = false;
this.computerID = computer.getID(); computerID = computer.getID();
this.label = computer.getLabel(); label = computer.getLabel();
this.on = computer.isOn(); on = computer.isOn();
if( computer.hasOutputChanged() ) if( computer.hasOutputChanged() )
{ {
this.updateOutput(); updateOutput();
} }
// Update the block state if needed. We don't fire a block update intentionally, // Update the block state if needed. We don't fire a block update intentionally,
// as this only really is needed on the client side. // as this only really is needed on the client side.
this.updateBlockState( computer.getState() ); updateBlockState( computer.getState() );
if( computer.hasOutputChanged() ) if( computer.hasOutputChanged() )
{ {
this.updateOutput(); updateOutput();
} }
} }
} }
@@ -316,10 +315,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
public void updateOutput() public void updateOutput()
{ {
// Update redstone // Update redstone
this.updateBlock(); updateBlock();
for( Direction dir : DirectionUtil.FACINGS ) 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 ); super.fromTag( state, nbt );
// Load ID, label and power state // Load ID, label and power state
this.computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
this.label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null; label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null;
this.on = this.startOn = nbt.getBoolean( NBT_ON ); on = startOn = nbt.getBoolean( NBT_ON );
} }
@Nonnull @Nonnull
@@ -341,15 +340,15 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
public CompoundTag toTag( @Nonnull CompoundTag nbt ) public CompoundTag toTag( @Nonnull CompoundTag nbt )
{ {
// Save ID, label and power state // 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 ); return super.toTag( nbt );
} }
@@ -357,18 +356,18 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public void markRemoved() public void markRemoved()
{ {
this.unload(); unload();
super.markRemoved(); super.markRemoved();
} }
private void updateInput( BlockPos neighbour ) private void updateInput( BlockPos neighbour )
{ {
if( this.getWorld() == null || this.getWorld().isClient ) if( getWorld() == null || getWorld().isClient )
{ {
return; return;
} }
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
if( computer == null ) if( computer == null )
{ {
return; return;
@@ -376,61 +375,61 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
for( Direction dir : DirectionUtil.FACINGS ) for( Direction dir : DirectionUtil.FACINGS )
{ {
BlockPos offset = this.pos.offset( dir ); BlockPos offset = pos.offset( dir );
if( offset.equals( neighbour ) ) if( offset.equals( neighbour ) )
{ {
this.updateSideInput( computer, dir, offset ); updateSideInput( computer, dir, offset );
return; return;
} }
} }
// If the position is not any adjacent one, update all inputs. // If the position is not any adjacent one, update all inputs.
this.updateInput(); updateInput();
} }
private void updateInput( Direction dir ) private void updateInput( Direction dir )
{ {
if( this.getWorld() == null || this.getWorld().isClient ) if( getWorld() == null || getWorld().isClient )
{ {
return; return;
} }
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
if( computer == null ) if( computer == null )
{ {
return; return;
} }
this.updateSideInput( computer, dir, this.pos.offset( dir ) ); updateSideInput( computer, dir, pos.offset( dir ) );
} }
@Override @Override
public final int getComputerID() public final int getComputerID()
{ {
return this.computerID; return computerID;
} }
@Override @Override
public final void setComputerID( int id ) public final void setComputerID( int id )
{ {
if( this.getWorld().isClient || this.computerID == id ) if( getWorld().isClient || computerID == id )
{ {
return; return;
} }
this.computerID = id; computerID = id;
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
if( computer != null ) if( computer != null )
{ {
computer.setID( this.computerID ); computer.setID( computerID );
} }
this.markDirty(); markDirty();
} }
@Override @Override
public final String getLabel() public final String getLabel()
{ {
return this.label; return label;
} }
// Networking stuff // Networking stuff
@@ -438,37 +437,37 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public final void setLabel( String label ) public final void setLabel( String label )
{ {
if( this.getWorld().isClient || Objects.equals( this.label, label ) ) if( getWorld().isClient || Objects.equals( this.label, label ) )
{ {
return; return;
} }
this.label = label; this.label = label;
ServerComputer computer = this.getServerComputer(); ServerComputer computer = getServerComputer();
if( computer != null ) if( computer != null )
{ {
computer.setLabel( label ); computer.setLabel( label );
} }
this.markDirty(); markDirty();
} }
@Override @Override
public ComputerFamily getFamily() public ComputerFamily getFamily()
{ {
return this.family; return family;
} }
protected void transferStateFrom( TileComputerBase copy ) protected void transferStateFrom( TileComputerBase copy )
{ {
if( copy.computerID != this.computerID || copy.instanceID != this.instanceID ) if( copy.computerID != computerID || copy.instanceID != instanceID )
{ {
this.unload(); unload();
this.instanceID = copy.instanceID; instanceID = copy.instanceID;
this.computerID = copy.computerID; computerID = copy.computerID;
this.label = copy.label; label = copy.label;
this.on = copy.on; on = copy.on;
this.startOn = copy.startOn; startOn = copy.startOn;
this.updateBlock(); updateBlock();
} }
copy.instanceID = -1; copy.instanceID = -1;
} }
@@ -477,7 +476,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public IPeripheral getPeripheral( Direction side ) public IPeripheral getPeripheral( Direction side )
{ {
return new ComputerPeripheral( "computer", this.createProxy() ); return new ComputerPeripheral( "computer", createProxy() );
} }
public abstract ComputerProxy createProxy(); public abstract ComputerProxy createProxy();
@@ -486,14 +485,14 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public Text getName() 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() ); .getTranslationKey() );
} }
@Override @Override
public boolean hasCustomName() public boolean hasCustomName()
{ {
return !Strings.isNullOrEmpty( this.label ); return !Strings.isNullOrEmpty( label );
} }
@Nonnull @Nonnull
@@ -507,13 +506,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override @Override
public Text getCustomName() public Text getCustomName()
{ {
return this.hasCustomName() ? new LiteralText( this.label ) : null; return hasCustomName() ? new LiteralText( label ) : null;
} }
@Override @Override
public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf ) public void writeScreenOpeningData( ServerPlayerEntity serverPlayerEntity, PacketByteBuf packetByteBuf )
{ {
packetByteBuf.writeInt( this.getServerComputer().getInstanceID() ); packetByteBuf.writeInt( getServerComputer().getInstanceID() );
packetByteBuf.writeEnumConstant( this.getServerComputer().getFamily() ); packetByteBuf.writeEnumConstant( getServerComputer().getFamily() );
} }
} }

View File

@@ -28,13 +28,13 @@ public class ClientComputer extends ClientTerminal implements IComputer
public CompoundTag getUserData() public CompoundTag getUserData()
{ {
return this.userData; return userData;
} }
public void requestState() public void requestState()
{ {
// Request state from server // Request state from server
NetworkHandler.sendToServer( new RequestComputerMessage( this.getInstanceID() ) ); NetworkHandler.sendToServer( new RequestComputerMessage( getInstanceID() ) );
} }
// IComputer // IComputer
@@ -42,53 +42,53 @@ public class ClientComputer extends ClientTerminal implements IComputer
@Override @Override
public int getInstanceID() public int getInstanceID()
{ {
return this.instanceID; return instanceID;
} }
@Override @Override
public void turnOn() public void turnOn()
{ {
// Send turnOn to server // Send turnOn to server
NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.TURN_ON ) ); NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.TURN_ON ) );
} }
@Override @Override
public void shutdown() public void shutdown()
{ {
// Send shutdown to server // Send shutdown to server
NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.SHUTDOWN ) ); NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.SHUTDOWN ) );
} }
@Override @Override
public void reboot() public void reboot()
{ {
// Send reboot to server // Send reboot to server
NetworkHandler.sendToServer( new ComputerActionServerMessage( this.instanceID, ComputerActionServerMessage.Action.REBOOT ) ); NetworkHandler.sendToServer( new ComputerActionServerMessage( instanceID, ComputerActionServerMessage.Action.REBOOT ) );
} }
@Override @Override
public void queueEvent( String event, Object[] arguments ) public void queueEvent( String event, Object[] arguments )
{ {
// Send event to server // Send event to server
NetworkHandler.sendToServer( new QueueEventServerMessage( this.instanceID, event, arguments ) ); NetworkHandler.sendToServer( new QueueEventServerMessage( instanceID, event, arguments ) );
} }
@Override @Override
public boolean isOn() public boolean isOn()
{ {
return this.on; return on;
} }
@Override @Override
public boolean isCursorDisplayed() public boolean isCursorDisplayed()
{ {
return this.on && this.blinking; return on && blinking;
} }
@Override @Override
public void keyDown( int key, boolean repeat ) 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, repeat ? KeyEventServerMessage.TYPE_REPEAT : KeyEventServerMessage.TYPE_DOWN,
key ) ); key ) );
} }
@@ -96,37 +96,37 @@ public class ClientComputer extends ClientTerminal implements IComputer
@Override @Override
public void keyUp( int key ) 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 @Override
public void mouseClick( int button, int x, int y ) 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 @Override
public void mouseUp( int button, int x, int y ) 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 @Override
public void mouseDrag( int button, int x, int y ) 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 @Override
public void mouseScroll( int direction, int x, int y ) 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 ) public void setState( ComputerState state, CompoundTag userData )
{ {
this.on = state != ComputerState.OFF; on = state != ComputerState.OFF;
this.blinking = state == ComputerState.BLINKING; blinking = state == ComputerState.BLINKING;
this.userData = userData; this.userData = userData;
} }
} }

View File

@@ -19,39 +19,39 @@ public class ComputerRegistry<T extends IComputer>
protected ComputerRegistry() protected ComputerRegistry()
{ {
this.computers = new HashMap<>(); computers = new HashMap<>();
this.reset(); reset();
} }
public void reset() public void reset()
{ {
this.computers.clear(); computers.clear();
this.nextUnusedInstanceID = 0; nextUnusedInstanceID = 0;
this.sessionID = new Random().nextInt(); sessionID = new Random().nextInt();
} }
public int getSessionID() public int getSessionID()
{ {
return this.sessionID; return sessionID;
} }
public int getUnusedInstanceID() public int getUnusedInstanceID()
{ {
return this.nextUnusedInstanceID++; return nextUnusedInstanceID++;
} }
public Collection<T> getComputers() public Collection<T> getComputers()
{ {
return this.computers.values(); return computers.values();
} }
public T get( int instanceID ) public T get( int instanceID )
{ {
if( instanceID >= 0 ) if( instanceID >= 0 )
{ {
if( this.computers.containsKey( instanceID ) ) if( computers.containsKey( instanceID ) )
{ {
return this.computers.get( instanceID ); return computers.get( instanceID );
} }
} }
return null; return null;
@@ -59,21 +59,21 @@ public class ComputerRegistry<T extends IComputer>
public boolean contains( int instanceID ) public boolean contains( int instanceID )
{ {
return this.computers.containsKey( instanceID ); return computers.containsKey( instanceID );
} }
public void add( int instanceID, T computer ) 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 ); computers.put( instanceID, computer );
this.nextUnusedInstanceID = Math.max( this.nextUnusedInstanceID, instanceID + 1 ); nextUnusedInstanceID = Math.max( nextUnusedInstanceID, instanceID + 1 );
} }
public void remove( int instanceID ) public void remove( int instanceID )
{ {
this.computers.remove( instanceID ); computers.remove( instanceID );
} }
} }

View File

@@ -25,12 +25,12 @@ public enum ComputerState implements StringIdentifiable
@Override @Override
public String asString() public String asString()
{ {
return this.name; return name;
} }
@Override @Override
public String toString() public String toString()
{ {
return this.name; return name;
} }
} }

View File

@@ -20,7 +20,7 @@ public interface IComputer extends ITerminal, InputHandler
default void queueEvent( String event ) default void queueEvent( String event )
{ {
this.queueEvent( event, null ); queueEvent( event, null );
} }
@Override @Override
@@ -28,11 +28,11 @@ public interface IComputer extends ITerminal, InputHandler
default ComputerState getState() default ComputerState getState()
{ {
if( !this.isOn() ) if( !isOn() )
{ {
return ComputerState.OFF; return ComputerState.OFF;
} }
return this.isCursorDisplayed() ? ComputerState.BLINKING : ComputerState.ON; return isCursorDisplayed() ? ComputerState.BLINKING : ComputerState.ON;
} }
boolean isOn(); boolean isOn();

View File

@@ -30,7 +30,7 @@ public class InputState implements InputHandler
@Override @Override
public void queueEvent( String event, Object[] arguments ) public void queueEvent( String event, Object[] arguments )
{ {
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.queueEvent( event, arguments ); computer.queueEvent( event, arguments );
@@ -40,8 +40,8 @@ public class InputState implements InputHandler
@Override @Override
public void keyDown( int key, boolean repeat ) public void keyDown( int key, boolean repeat )
{ {
this.keysDown.add( key ); keysDown.add( key );
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.keyDown( key, repeat ); computer.keyDown( key, repeat );
@@ -51,8 +51,8 @@ public class InputState implements InputHandler
@Override @Override
public void keyUp( int key ) public void keyUp( int key )
{ {
this.keysDown.remove( key ); keysDown.remove( key );
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.keyUp( key ); computer.keyUp( key );
@@ -62,11 +62,11 @@ public class InputState implements InputHandler
@Override @Override
public void mouseClick( int button, int x, int y ) public void mouseClick( int button, int x, int y )
{ {
this.lastMouseX = x; lastMouseX = x;
this.lastMouseY = y; lastMouseY = y;
this.lastMouseDown = button; lastMouseDown = button;
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.mouseClick( button, x, y ); computer.mouseClick( button, x, y );
@@ -76,11 +76,11 @@ public class InputState implements InputHandler
@Override @Override
public void mouseUp( int button, int x, int y ) public void mouseUp( int button, int x, int y )
{ {
this.lastMouseX = x; lastMouseX = x;
this.lastMouseY = y; lastMouseY = y;
this.lastMouseDown = -1; lastMouseDown = -1;
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.mouseUp( button, x, y ); computer.mouseUp( button, x, y );
@@ -90,11 +90,11 @@ public class InputState implements InputHandler
@Override @Override
public void mouseDrag( int button, int x, int y ) public void mouseDrag( int button, int x, int y )
{ {
this.lastMouseX = x; lastMouseX = x;
this.lastMouseY = y; lastMouseY = y;
this.lastMouseDown = button; lastMouseDown = button;
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.mouseDrag( button, x, y ); computer.mouseDrag( button, x, y );
@@ -104,10 +104,10 @@ public class InputState implements InputHandler
@Override @Override
public void mouseScroll( int direction, int x, int y ) public void mouseScroll( int direction, int x, int y )
{ {
this.lastMouseX = x; lastMouseX = x;
this.lastMouseY = y; lastMouseY = y;
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
computer.mouseScroll( direction, x, y ); computer.mouseScroll( direction, x, y );
@@ -116,22 +116,22 @@ public class InputState implements InputHandler
public void close() public void close()
{ {
IComputer computer = this.owner.getComputer(); IComputer computer = owner.getComputer();
if( computer != null ) if( computer != null )
{ {
IntIterator keys = this.keysDown.iterator(); IntIterator keys = keysDown.iterator();
while( keys.hasNext() ) while( keys.hasNext() )
{ {
computer.keyUp( keys.nextInt() ); 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(); keysDown.clear();
this.lastMouseDown = -1; lastMouseDown = -1;
} }
} }

View File

@@ -54,26 +54,26 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
this.instanceID = instanceID; this.instanceID = instanceID;
this.world = world; this.world = world;
this.position = null; position = null;
this.family = family; this.family = family;
this.computer = new Computer( this, this.getTerminal(), computerID ); computer = new Computer( this, getTerminal(), computerID );
this.computer.setLabel( label ); computer.setLabel( label );
this.userData = null; userData = null;
this.changed = false; changed = false;
this.changedLastFrame = false; changedLastFrame = false;
this.ticksSincePing = 0; ticksSincePing = 0;
} }
public ComputerFamily getFamily() public ComputerFamily getFamily()
{ {
return this.family; return family;
} }
public World getWorld() public World getWorld()
{ {
return this.world; return world;
} }
public void setWorld( World world ) public void setWorld( World world )
@@ -83,78 +83,78 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
public BlockPos getPosition() public BlockPos getPosition()
{ {
return this.position; return position;
} }
public void setPosition( BlockPos pos ) public void setPosition( BlockPos pos )
{ {
this.position = new BlockPos( pos ); position = new BlockPos( pos );
} }
public IAPIEnvironment getAPIEnvironment() public IAPIEnvironment getAPIEnvironment()
{ {
return this.computer.getAPIEnvironment(); return computer.getAPIEnvironment();
} }
public Computer getComputer() public Computer getComputer()
{ {
return this.computer; return computer;
} }
@Override @Override
public void update() public void update()
{ {
super.update(); super.update();
this.computer.tick(); computer.tick();
this.changedLastFrame = this.computer.pollAndResetChanged() || this.changed; changedLastFrame = computer.pollAndResetChanged() || changed;
this.changed = false; changed = false;
this.ticksSincePing++; ticksSincePing++;
} }
public void keepAlive() public void keepAlive()
{ {
this.ticksSincePing = 0; ticksSincePing = 0;
} }
public boolean hasTimedOut() public boolean hasTimedOut()
{ {
return this.ticksSincePing > 100; return ticksSincePing > 100;
} }
public void unload() public void unload()
{ {
this.computer.unload(); computer.unload();
} }
public CompoundTag getUserData() 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() public void updateUserData()
{ {
this.changed = true; changed = true;
} }
public void broadcastState( boolean force ) public void broadcastState( boolean force )
{ {
if( this.hasOutputChanged() || force ) if( hasOutputChanged() || force )
{ {
// Send computer state to all clients // Send computer state to all clients
MinecraftServer server = GameInstanceUtils.getServer(); MinecraftServer server = GameInstanceUtils.getServer();
if( server != null ) if( server != null )
{ {
NetworkHandler.sendToAllPlayers( server, this.createComputerPacket() ); NetworkHandler.sendToAllPlayers( server, createComputerPacket() );
} }
} }
if( this.hasTerminalChanged() || force ) if( hasTerminalChanged() || force )
{ {
MinecraftServer server = GameInstanceUtils.getServer(); MinecraftServer server = GameInstanceUtils.getServer();
if( server != null ) if( server != null )
@@ -165,11 +165,11 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
for( PlayerEntity player : server.getPlayerManager() for( PlayerEntity player : server.getPlayerManager()
.getPlayerList() ) .getPlayerList() )
{ {
if( this.isInteracting( player ) ) if( isInteracting( player ) )
{ {
if( packet == null ) if( packet == null )
{ {
packet = this.createTerminalPacket(); packet = createTerminalPacket();
} }
NetworkHandler.sendToPlayer( player, packet ); NetworkHandler.sendToPlayer( player, packet );
} }
@@ -180,7 +180,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
public boolean hasOutputChanged() public boolean hasOutputChanged()
{ {
return this.changedLastFrame; return changedLastFrame;
} }
private NetworkMessage createComputerPacket() private NetworkMessage createComputerPacket()
@@ -190,12 +190,12 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
protected boolean isInteracting( PlayerEntity player ) protected boolean isInteracting( PlayerEntity player )
{ {
return this.getContainer( player ) != null; return getContainer( player ) != null;
} }
protected NetworkMessage createTerminalPacket() protected NetworkMessage createTerminalPacket()
{ {
return new ComputerTerminalClientMessage( this.getInstanceID(), this.write() ); return new ComputerTerminalClientMessage( getInstanceID(), write() );
} }
@Nullable @Nullable
@@ -219,14 +219,14 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
@Override @Override
public int getInstanceID() public int getInstanceID()
{ {
return this.instanceID; return instanceID;
} }
@Override @Override
public void turnOn() public void turnOn()
{ {
// Turn on // Turn on
this.computer.turnOn(); computer.turnOn();
} }
// IComputer // IComputer
@@ -235,45 +235,45 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
public void shutdown() public void shutdown()
{ {
// Shutdown // Shutdown
this.computer.shutdown(); computer.shutdown();
} }
@Override @Override
public void reboot() public void reboot()
{ {
// Reboot // Reboot
this.computer.reboot(); computer.reboot();
} }
@Override @Override
public void queueEvent( String event, Object[] arguments ) public void queueEvent( String event, Object[] arguments )
{ {
// Queue event // Queue event
this.computer.queueEvent( event, arguments ); computer.queueEvent( event, arguments );
} }
@Override @Override
public boolean isOn() public boolean isOn()
{ {
return this.computer.isOn(); return computer.isOn();
} }
@Override @Override
public boolean isCursorDisplayed() public boolean isCursorDisplayed()
{ {
return this.computer.isOn() && this.computer.isBlinking(); return computer.isOn() && computer.isBlinking();
} }
public void sendComputerState( PlayerEntity player ) public void sendComputerState( PlayerEntity player )
{ {
// Send state to client // Send state to client
NetworkHandler.sendToPlayer( player, this.createComputerPacket() ); NetworkHandler.sendToPlayer( player, createComputerPacket() );
} }
public void sendTerminalState( PlayerEntity player ) public void sendTerminalState( PlayerEntity player )
{ {
// Send terminal state to client // Send terminal state to client
NetworkHandler.sendToPlayer( player, this.createTerminalPacket() ); NetworkHandler.sendToPlayer( player, createTerminalPacket() );
} }
public void broadcastDelete() public void broadcastDelete()
@@ -282,83 +282,83 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
MinecraftServer server = GameInstanceUtils.getServer(); MinecraftServer server = GameInstanceUtils.getServer();
if( server != null ) if( server != null )
{ {
NetworkHandler.sendToAllPlayers( server, new ComputerDeletedClientMessage( this.getInstanceID() ) ); NetworkHandler.sendToAllPlayers( server, new ComputerDeletedClientMessage( getInstanceID() ) );
} }
} }
public int getID() public int getID()
{ {
return this.computer.getID(); return computer.getID();
} }
public void setID( int id ) public void setID( int id )
{ {
this.computer.setID( id ); computer.setID( id );
} }
public String getLabel() public String getLabel()
{ {
return this.computer.getLabel(); return computer.getLabel();
} }
public void setLabel( String label ) public void setLabel( String label )
{ {
this.computer.setLabel( label ); computer.setLabel( label );
} }
public int getRedstoneOutput( ComputerSide side ) public int getRedstoneOutput( ComputerSide side )
{ {
return this.computer.getEnvironment() return computer.getEnvironment()
.getExternalRedstoneOutput( side ); .getExternalRedstoneOutput( side );
} }
public void setRedstoneInput( ComputerSide side, int level ) public void setRedstoneInput( ComputerSide side, int level )
{ {
this.computer.getEnvironment() computer.getEnvironment()
.setRedstoneInput( side, level ); .setRedstoneInput( side, level );
} }
public int getBundledRedstoneOutput( ComputerSide side ) public int getBundledRedstoneOutput( ComputerSide side )
{ {
return this.computer.getEnvironment() return computer.getEnvironment()
.getExternalBundledRedstoneOutput( side ); .getExternalBundledRedstoneOutput( side );
} }
public void setBundledRedstoneInput( ComputerSide side, int combination ) public void setBundledRedstoneInput( ComputerSide side, int combination )
{ {
this.computer.getEnvironment() computer.getEnvironment()
.setBundledRedstoneInput( side, combination ); .setBundledRedstoneInput( side, combination );
} }
public void addAPI( ILuaAPI api ) public void addAPI( ILuaAPI api )
{ {
this.computer.addApi( api ); computer.addApi( api );
} }
// IComputerEnvironment implementation // IComputerEnvironment implementation
public void setPeripheral( ComputerSide side, IPeripheral peripheral ) public void setPeripheral( ComputerSide side, IPeripheral peripheral )
{ {
this.computer.getEnvironment() computer.getEnvironment()
.setPeripheral( side, peripheral ); .setPeripheral( side, peripheral );
} }
public IPeripheral getPeripheral( ComputerSide side ) public IPeripheral getPeripheral( ComputerSide side )
{ {
return this.computer.getEnvironment() return computer.getEnvironment()
.getPeripheral( side ); .getPeripheral( side );
} }
@Override @Override
public int getDay() public int getDay()
{ {
return (int) ((this.world.getTimeOfDay() + 6000) / 24000) + 1; return (int) ((world.getTimeOfDay() + 6000) / 24000) + 1;
} }
@Override @Override
public double getTimeOfDay() public double getTimeOfDay()
{ {
return (this.world.getTimeOfDay() + 6000) % 24000 / 1000.0; return (world.getTimeOfDay() + 6000) % 24000 / 1000.0;
} }
@Override @Override
@@ -384,13 +384,13 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
@Override @Override
public int assignNewID() public int assignNewID()
{ {
return ComputerCraftAPI.createUniqueNumberedSaveDir( this.world, "computer" ); return ComputerCraftAPI.createUniqueNumberedSaveDir( world, "computer" );
} }
@Override @Override
public IWritableMount createSaveDirMount( String subPath, long capacity ) public IWritableMount createSaveDirMount( String subPath, long capacity )
{ {
return ComputerCraftAPI.createSaveDirMount( this.world, subPath, capacity ); return ComputerCraftAPI.createSaveDirMount( world, subPath, capacity );
} }
@Override @Override

View File

@@ -12,7 +12,7 @@ public class ServerComputerRegistry extends ComputerRegistry<ServerComputer>
{ {
public void update() public void update()
{ {
Iterator<ServerComputer> it = this.getComputers().iterator(); Iterator<ServerComputer> it = getComputers().iterator();
while( it.hasNext() ) while( it.hasNext() )
{ {
ServerComputer computer = it.next(); ServerComputer computer = it.next();
@@ -39,7 +39,7 @@ public class ServerComputerRegistry extends ComputerRegistry<ServerComputer>
public void reset() public void reset()
{ {
//System.out.println( "RESET SERVER COMPUTERS" ); //System.out.println( "RESET SERVER COMPUTERS" );
for( ServerComputer computer : this.getComputers() ) for( ServerComputer computer : getComputers() )
{ {
computer.unload(); computer.unload();
} }
@@ -60,7 +60,7 @@ public class ServerComputerRegistry extends ComputerRegistry<ServerComputer>
public void remove( int instanceID ) public void remove( int instanceID )
{ {
//System.out.println( "REMOVE SERVER COMPUTER " + instanceID ); //System.out.println( "REMOVE SERVER COMPUTER " + instanceID );
ServerComputer computer = this.get( instanceID ); ServerComputer computer = get( instanceID );
if( computer != null ) if( computer != null )
{ {
computer.unload(); computer.unload();
@@ -77,7 +77,7 @@ public class ServerComputerRegistry extends ComputerRegistry<ServerComputer>
return null; return null;
} }
for( ServerComputer computer : this.getComputers() ) for( ServerComputer computer : getComputers() )
{ {
if( computer.getID() == computerID ) if( computer.getID() == computerID )
{ {

View File

@@ -64,33 +64,33 @@ public class ContainerComputerBase extends ScreenHandler implements IContainerCo
@Nonnull @Nonnull
public ComputerFamily getFamily() public ComputerFamily getFamily()
{ {
return this.family; return family;
} }
@Nullable @Nullable
@Override @Override
public IComputer getComputer() public IComputer getComputer()
{ {
return this.computer; return computer;
} }
@Nonnull @Nonnull
@Override @Override
public InputState getInput() public InputState getInput()
{ {
return this.input; return input;
} }
@Override @Override
public void close( @Nonnull PlayerEntity player ) public void close( @Nonnull PlayerEntity player )
{ {
super.close( player ); super.close( player );
this.input.close(); input.close();
} }
@Override @Override
public boolean canUse( @Nonnull PlayerEntity player ) public boolean canUse( @Nonnull PlayerEntity player )
{ {
return this.canUse.test( player ); return canUse.test( player );
} }
} }

View File

@@ -10,7 +10,6 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.computer.blocks.TileCommandComputer; import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
import dan200.computercraft.shared.computer.core.ComputerFamily; 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.computer.core.ServerComputer;
import dan200.computercraft.shared.network.container.ViewComputerContainerData; import dan200.computercraft.shared.network.container.ViewComputerContainerData;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -19,7 +18,7 @@ import net.minecraft.network.PacketByteBuf;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class ContainerViewComputer extends ContainerComputerBase implements IContainerComputer public class ContainerViewComputer extends ContainerComputerBase
{ {
private final int width; private final int width;
private final int height; private final int height;
@@ -27,15 +26,15 @@ public class ContainerViewComputer extends ContainerComputerBase implements ICon
public ContainerViewComputer( int id, ServerComputer computer ) public ContainerViewComputer( int id, ServerComputer computer )
{ {
super( ComputerCraftRegistry.ModContainers.VIEW_COMPUTER, id, player -> canInteractWith( computer, player ), computer, computer.getFamily() ); 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 ) public ContainerViewComputer( int id, PlayerInventory player, PacketByteBuf packetByteBuf )
{ {
super( ComputerCraftRegistry.ModContainers.VIEW_COMPUTER, id, player, packetByteBuf ); super( ComputerCraftRegistry.ModContainers.VIEW_COMPUTER, id, player, packetByteBuf );
ViewComputerContainerData data = new ViewComputerContainerData( new PacketByteBuf( packetByteBuf.copy() ) ); ViewComputerContainerData data = new ViewComputerContainerData( new PacketByteBuf( packetByteBuf.copy() ) );
this.width = data.getWidth(); width = data.getWidth();
this.height = data.getHeight(); height = data.getHeight();
} }
private static boolean canInteractWith( @Nonnull ServerComputer computer, @Nonnull PlayerEntity player ) private static boolean canInteractWith( @Nonnull ServerComputer computer, @Nonnull PlayerEntity player )
@@ -52,11 +51,11 @@ public class ContainerViewComputer extends ContainerComputerBase implements ICon
public int getWidth() public int getWidth()
{ {
return this.width; return width;
} }
public int getHeight() public int getHeight()
{ {
return this.height; return height;
} }
} }

View File

@@ -38,7 +38,7 @@ public class ItemComputer extends ItemComputerBase
@Override @Override
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family ) 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() ) if( stack.hasCustomName() )
{ {
result.setCustomName( stack.getName() ); result.setCustomName( stack.getName() );

View File

@@ -32,15 +32,15 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
public ItemComputerBase( BlockComputerBase<?> block, Settings settings ) public ItemComputerBase( BlockComputerBase<?> block, Settings settings )
{ {
super( block, settings ); super( block, settings );
this.family = block.getFamily(); family = block.getFamily();
} }
@Override @Override
public void appendTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<Text> list, @Nonnull TooltipContext options ) public void appendTooltip( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<Text> 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 ) if( id >= 0 )
{ {
list.add( new TranslatableText( "gui.computercraft.tooltip.computer_id", id ).formatted( Formatting.GRAY ) ); 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 @Override
public final ComputerFamily getFamily() public final ComputerFamily getFamily()
{ {
return this.family; return family;
} }
// IMedia implementation // IMedia implementation
@@ -79,10 +79,10 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
@Override @Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
ComputerFamily family = this.getFamily(); ComputerFamily family = getFamily();
if( family != ComputerFamily.COMMAND ) if( family != ComputerFamily.COMMAND )
{ {
int id = this.getComputerID( stack ); int id = getComputerID( stack );
if( id >= 0 ) if( id >= 0 )
{ {
return ComputerCraftAPI.createSaveDirMount( world, "computer/" + id, ComputerCraft.computerSpaceLimit ); return ComputerCraftAPI.createSaveDirMount( world, "computer/" + id, ComputerCraft.computerSpaceLimit );

View File

@@ -34,7 +34,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe
@Override @Override
public String getGroup() public String getGroup()
{ {
return this.group; return group;
} }
@Override @Override
@@ -67,7 +67,7 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe
ItemStack stack = inventory.getStack( i ); ItemStack stack = inventory.getStack( i );
if( stack.getItem() instanceof IComputerItem ) if( stack.getItem() instanceof IComputerItem )
{ {
return this.convert( (IComputerItem) stack.getItem(), stack ); return convert( (IComputerItem) stack.getItem(), stack );
} }
} }

View File

@@ -32,7 +32,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
public ComputerFamily getFamily() public ComputerFamily getFamily()
{ {
return this.family; return family;
} }
public abstract static class Serializer<T extends ComputerFamilyRecipe> implements RecipeSerializer<T> public abstract static class Serializer<T extends ComputerFamilyRecipe> implements RecipeSerializer<T>
@@ -47,7 +47,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json ); RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json );
ItemStack result = getItemStack( JsonHelper.getObject( json, "result" ) ); 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<Ingredient> ingredients, ItemStack result, protected abstract T create( Identifier identifier, String group, int width, int height, DefaultedList<Ingredient> ingredients, ItemStack result,
@@ -69,7 +69,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
ItemStack result = buf.readItemStack(); ItemStack result = buf.readItemStack();
ComputerFamily family = buf.readEnumConstant( ComputerFamily.class ); 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 @Override

View File

@@ -19,7 +19,7 @@ import javax.annotation.Nonnull;
public class ComputerUpgradeRecipe extends ComputerFamilyRecipe public class ComputerUpgradeRecipe extends ComputerFamilyRecipe
{ {
public static final RecipeSerializer<ComputerUpgradeRecipe> SERIALIZER = public static final RecipeSerializer<ComputerUpgradeRecipe> SERIALIZER =
new dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe.Serializer<ComputerUpgradeRecipe>() new ComputerFamilyRecipe.Serializer<ComputerUpgradeRecipe>()
{ {
@Override @Override
protected ComputerUpgradeRecipe create( Identifier identifier, String group, int width, int height, DefaultedList<Ingredient> ingredients, protected ComputerUpgradeRecipe create( Identifier identifier, String group, int width, int height, DefaultedList<Ingredient> ingredients,
@@ -39,7 +39,7 @@ public class ComputerUpgradeRecipe extends ComputerFamilyRecipe
@Override @Override
protected ItemStack convert( @Nonnull IComputerItem item, @Nonnull ItemStack stack ) protected ItemStack convert( @Nonnull IComputerItem item, @Nonnull ItemStack stack )
{ {
return item.withFamily( stack, this.getFamily() ); return item.withFamily( stack, getFamily() );
} }
@Nonnull @Nonnull

View File

@@ -38,6 +38,6 @@ public final class ConstantLootConditionSerializer<T extends LootCondition> impl
@Override @Override
public T fromJson( @Nonnull JsonObject json, @Nonnull JsonDeserializationContext context ) public T fromJson( @Nonnull JsonObject json, @Nonnull JsonDeserializationContext context )
{ {
return this.instance; return instance;
} }
} }

View File

@@ -54,7 +54,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
@Override @Override
public void appendStacks( @Nonnull ItemGroup tabs, @Nonnull DefaultedList<ItemStack> list ) public void appendStacks( @Nonnull ItemGroup tabs, @Nonnull DefaultedList<ItemStack> list )
{ {
if( !this.isIn( tabs ) ) if( !isIn( tabs ) )
{ {
return; return;
} }

View File

@@ -158,7 +158,7 @@ public class ItemPrintout extends Item
public Type getType() public Type getType()
{ {
return this.type; return type;
} }
public enum Type public enum Type

View File

@@ -30,7 +30,7 @@ public final class RecordMedia implements IMedia
@Override @Override
public String getLabel( @Nonnull ItemStack stack ) public String getLabel( @Nonnull ItemStack stack )
{ {
return this.getAudioTitle( stack ); return getAudioTitle( stack );
} }
@Override @Override

View File

@@ -47,7 +47,7 @@ public class DiskRecipe extends SpecialCraftingRecipe
if( !stack.isEmpty() ) if( !stack.isEmpty() )
{ {
if( this.paper.test( stack ) ) if( paper.test( stack ) )
{ {
if( paperFound ) if( paperFound )
{ {
@@ -55,7 +55,7 @@ public class DiskRecipe extends SpecialCraftingRecipe
} }
paperFound = true; paperFound = true;
} }
else if( this.redstone.test( stack ) ) else if( redstone.test( stack ) )
{ {
if( redstoneFound ) if( redstoneFound )
{ {

View File

@@ -22,8 +22,8 @@ import javax.annotation.Nonnull;
public final class PrintoutRecipe extends SpecialCraftingRecipe public final class PrintoutRecipe extends SpecialCraftingRecipe
{ {
public static final RecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( PrintoutRecipe::new ); public static final RecipeSerializer<?> SERIALIZER = new SpecialRecipeSerializer<>( PrintoutRecipe::new );
private final Ingredient paper = Ingredient.ofItems( net.minecraft.item.Items.PAPER ); private final Ingredient paper = Ingredient.ofItems( Items.PAPER );
private final Ingredient leather = Ingredient.ofItems( net.minecraft.item.Items.LEATHER ); private final Ingredient leather = Ingredient.ofItems( Items.LEATHER );
private final Ingredient string = Ingredient.ofItems( Items.STRING ); private final Ingredient string = Ingredient.ofItems( Items.STRING );
private PrintoutRecipe( Identifier id ) private PrintoutRecipe( Identifier id )
@@ -41,7 +41,7 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe
@Override @Override
public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world ) public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world )
{ {
return !this.craft( inventory ).isEmpty(); return !craft( inventory ).isEmpty();
} }
@Nonnull @Nonnull
@@ -73,7 +73,7 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe
numPrintouts++; numPrintouts++;
printoutFound = true; printoutFound = true;
} }
else if( this.paper.test( stack ) ) else if( paper.test( stack ) )
{ {
if( printouts == null ) if( printouts == null )
{ {
@@ -83,11 +83,11 @@ public final class PrintoutRecipe extends SpecialCraftingRecipe
numPages++; numPages++;
numPrintouts++; numPrintouts++;
} }
else if( this.string.test( stack ) && !stringFound ) else if( string.test( stack ) && !stringFound )
{ {
stringFound = true; stringFound = true;
} }
else if( this.leather.test( stack ) && !leatherFound ) else if( leather.test( stack ) && !leatherFound )
{ {
leatherFound = true; leatherFound = true;
} }

View File

@@ -37,20 +37,20 @@ public class ChatTableClientMessage implements NetworkMessage
@Override @Override
public void toBytes( @Nonnull PacketByteBuf buf ) public void toBytes( @Nonnull PacketByteBuf buf )
{ {
buf.writeVarInt( this.table.getId() ); buf.writeVarInt( table.getId() );
buf.writeVarInt( this.table.getColumns() ); buf.writeVarInt( table.getColumns() );
buf.writeBoolean( this.table.getHeaders() != null ); buf.writeBoolean( table.getHeaders() != null );
if( this.table.getHeaders() != null ) if( table.getHeaders() != null )
{ {
for( Text header : this.table.getHeaders() ) for( Text header : table.getHeaders() )
{ {
buf.writeText( header ); buf.writeText( header );
} }
} }
buf.writeVarInt( this.table.getRows() buf.writeVarInt( table.getRows()
.size() ); .size() );
for( Text[] row : this.table.getRows() ) for( Text[] row : table.getRows() )
{ {
for( Text column : row ) for( Text column : row )
{ {
@@ -58,7 +58,7 @@ public class ChatTableClientMessage implements NetworkMessage
} }
} }
buf.writeVarInt( this.table.getAdditional() ); buf.writeVarInt( table.getAdditional() );
} }
@Override @Override
@@ -100,6 +100,6 @@ public class ChatTableClientMessage implements NetworkMessage
@Environment( EnvType.CLIENT ) @Environment( EnvType.CLIENT )
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
ClientTableFormatter.INSTANCE.display( this.table ); ClientTableFormatter.INSTANCE.display( table );
} }
} }

View File

@@ -31,27 +31,27 @@ public abstract class ComputerClientMessage implements NetworkMessage
public int getInstanceId() public int getInstanceId()
{ {
return this.instanceId; return instanceId;
} }
@Override @Override
public void toBytes( @Nonnull PacketByteBuf buf ) public void toBytes( @Nonnull PacketByteBuf buf )
{ {
buf.writeVarInt( this.instanceId ); buf.writeVarInt( instanceId );
} }
@Override @Override
public void fromBytes( @Nonnull PacketByteBuf buf ) public void fromBytes( @Nonnull PacketByteBuf buf )
{ {
this.instanceId = buf.readVarInt(); instanceId = buf.readVarInt();
} }
public ClientComputer getComputer() public ClientComputer getComputer()
{ {
ClientComputer computer = ComputerCraft.clientComputerRegistry.get( this.instanceId ); ClientComputer computer = ComputerCraft.clientComputerRegistry.get( instanceId );
if( computer == null ) if( computer == null )
{ {
ComputerCraft.clientComputerRegistry.add( this.instanceId, computer = new ClientComputer( this.instanceId ) ); ComputerCraft.clientComputerRegistry.add( instanceId, computer = new ClientComputer( instanceId ) );
} }
return computer; return computer;
} }

View File

@@ -25,8 +25,8 @@ public class ComputerDataClientMessage extends ComputerClientMessage
public ComputerDataClientMessage( ServerComputer computer ) public ComputerDataClientMessage( ServerComputer computer )
{ {
super( computer.getInstanceID() ); super( computer.getInstanceID() );
this.state = computer.getState(); state = computer.getState();
this.userData = computer.getUserData(); userData = computer.getUserData();
} }
public ComputerDataClientMessage() public ComputerDataClientMessage()
@@ -37,21 +37,21 @@ public class ComputerDataClientMessage extends ComputerClientMessage
public void toBytes( @Nonnull PacketByteBuf buf ) public void toBytes( @Nonnull PacketByteBuf buf )
{ {
super.toBytes( buf ); super.toBytes( buf );
buf.writeEnumConstant( this.state ); buf.writeEnumConstant( state );
buf.writeCompoundTag( this.userData ); buf.writeCompoundTag( userData );
} }
@Override @Override
public void fromBytes( @Nonnull PacketByteBuf buf ) public void fromBytes( @Nonnull PacketByteBuf buf )
{ {
super.fromBytes( buf ); super.fromBytes( buf );
this.state = buf.readEnumConstant( ComputerState.class ); state = buf.readEnumConstant( ComputerState.class );
this.userData = buf.readCompoundTag(); userData = buf.readCompoundTag();
} }
@Override @Override
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
this.getComputer().setState( this.state, this.userData ); getComputer().setState( state, userData );
} }
} }

View File

@@ -23,6 +23,6 @@ public class ComputerDeletedClientMessage extends ComputerClientMessage
@Override @Override
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
ComputerCraft.clientComputerRegistry.remove( this.getInstanceId() ); ComputerCraft.clientComputerRegistry.remove( getInstanceId() );
} }
} }

View File

@@ -29,19 +29,19 @@ public class ComputerTerminalClientMessage extends ComputerClientMessage
public void toBytes( @Nonnull PacketByteBuf buf ) public void toBytes( @Nonnull PacketByteBuf buf )
{ {
super.toBytes( buf ); super.toBytes( buf );
this.state.write( buf ); state.write( buf );
} }
@Override @Override
public void fromBytes( @Nonnull PacketByteBuf buf ) public void fromBytes( @Nonnull PacketByteBuf buf )
{ {
super.fromBytes( buf ); super.fromBytes( buf );
this.state = new TerminalState( buf ); state = new TerminalState( buf );
} }
@Override @Override
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
this.getComputer().read( this.state ); getComputer().read( state );
} }
} }

View File

@@ -29,15 +29,15 @@ public class MonitorClientMessage implements NetworkMessage
public MonitorClientMessage( @Nonnull PacketByteBuf buf ) public MonitorClientMessage( @Nonnull PacketByteBuf buf )
{ {
this.pos = buf.readBlockPos(); pos = buf.readBlockPos();
this.state = new TerminalState( buf ); state = new TerminalState( buf );
} }
@Override @Override
public void toBytes( @Nonnull PacketByteBuf buf ) public void toBytes( @Nonnull PacketByteBuf buf )
{ {
buf.writeBlockPos( this.pos ); buf.writeBlockPos( pos );
this.state.write( buf ); state.write( buf );
} }
@Override @Override
@@ -49,12 +49,12 @@ public class MonitorClientMessage implements NetworkMessage
return; return;
} }
BlockEntity te = player.world.getBlockEntity( this.pos ); BlockEntity te = player.world.getBlockEntity( pos );
if( !(te instanceof TileMonitor) ) if( !(te instanceof TileMonitor) )
{ {
return; return;
} }
((TileMonitor) te).read( this.state ); ((TileMonitor) te).read( state );
} }
} }

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