1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-28 08:12:18 +00:00

What is this?

This's -> gone
This commit is contained in:
ToadDev 2021-06-11 13:03:21 -07:00
parent 668cdcdd39
commit 9129da2e3d
199 changed files with 2556 additions and 2603 deletions

View File

@ -80,11 +80,11 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
@Override
public String getInstalledVersion()
{
if( this.version != null )
if( version != null )
{
return this.version;
return version;
}
return this.version = FabricLoader.getInstance()
return version = FabricLoader.getInstance()
.getModContainer( ComputerCraft.MOD_ID )
.map( x -> x.getMetadata()
.getVersion()

View File

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

View File

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

View File

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

View File

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

View File

@ -30,10 +30,10 @@ public interface IArguments
default Object[] getAll()
{
Object[] result = new Object[this.count()];
Object[] result = new Object[count()];
for( int i = 0; i < result.length; i++ )
{
result[i] = this.get( i );
result[i] = get( i );
}
return result;
}
@ -71,7 +71,7 @@ public interface IArguments
*/
default int getInt( int index ) throws LuaException
{
return (int) this.getLong( index );
return (int) getLong( index );
}
/**
@ -83,7 +83,7 @@ public interface IArguments
*/
default long getLong( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( !(value instanceof Number) )
{
throw LuaValues.badArgumentOf( index, "number", value );
@ -101,7 +101,7 @@ public interface IArguments
*/
default double getFiniteDouble( int index ) throws LuaException
{
return checkFinite( index, this.getDouble( index ) );
return checkFinite( index, getDouble( index ) );
}
/**
@ -114,7 +114,7 @@ public interface IArguments
*/
default double getDouble( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( !(value instanceof Number) )
{
throw LuaValues.badArgumentOf( index, "number", value );
@ -131,7 +131,7 @@ public interface IArguments
*/
default boolean getBoolean( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( !(value instanceof Boolean) )
{
throw LuaValues.badArgumentOf( index, "boolean", value );
@ -149,7 +149,7 @@ public interface IArguments
@Nonnull
default ByteBuffer getBytes( int index ) throws LuaException
{
return LuaValues.encode( this.getString( index ) );
return LuaValues.encode( getString( index ) );
}
/**
@ -162,7 +162,7 @@ public interface IArguments
@Nonnull
default String getString( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( !(value instanceof String) )
{
throw LuaValues.badArgumentOf( index, "string", value );
@ -182,7 +182,7 @@ public interface IArguments
@Nonnull
default <T 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
default Map<?, ?> getTable( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( !(value instanceof Map) )
{
throw LuaValues.badArgumentOf( index, "table", value );
@ -212,7 +212,7 @@ public interface IArguments
*/
default Optional<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
{
Object value = this.get( index );
Object value = get( index );
if( value == null )
{
return Optional.empty();
@ -248,7 +248,7 @@ public interface IArguments
@Nonnull
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();
}
@ -262,7 +262,7 @@ public interface IArguments
*/
default double optDouble( int index, double def ) throws LuaException
{
return this.optDouble( index ).orElse( def );
return optDouble( index ).orElse( def );
}
/**
@ -275,7 +275,7 @@ public interface IArguments
@Nonnull
default Optional<Double> optDouble( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( value == null )
{
return Optional.empty();
@ -297,7 +297,7 @@ public interface IArguments
*/
default int optInt( int index, int def ) throws LuaException
{
return this.optInt( index ).orElse( def );
return optInt( index ).orElse( def );
}
/**
@ -310,7 +310,7 @@ public interface IArguments
@Nonnull
default Optional<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
{
Object value = this.get( index );
Object value = get( index );
if( value == null )
{
return Optional.empty();
@ -345,7 +345,7 @@ public interface IArguments
*/
default long optLong( int index, long def ) throws LuaException
{
return this.optLong( index ).orElse( def );
return optLong( index ).orElse( def );
}
/**
@ -358,7 +358,7 @@ public interface IArguments
*/
default double optFiniteDouble( int index, double def ) throws LuaException
{
return this.optFiniteDouble( index ).orElse( def );
return optFiniteDouble( index ).orElse( def );
}
/**
@ -370,7 +370,7 @@ public interface IArguments
*/
default Optional<Double> optFiniteDouble( int index ) throws LuaException
{
Optional<Double> value = this.optDouble( index );
Optional<Double> value = optDouble( index );
if( value.isPresent() )
{
LuaValues.checkFiniteNum( index, value.get() );
@ -388,7 +388,7 @@ public interface IArguments
*/
default boolean optBoolean( int index, boolean def ) throws LuaException
{
return this.optBoolean( index ).orElse( def );
return optBoolean( index ).orElse( def );
}
/**
@ -400,7 +400,7 @@ public interface IArguments
*/
default Optional<Boolean> optBoolean( int index ) throws LuaException
{
Object value = this.get( index );
Object value = get( index );
if( value == null )
{
return Optional.empty();
@ -422,7 +422,7 @@ public interface IArguments
*/
default String optString( int index, String def ) throws LuaException
{
return this.optString( index ).orElse( def );
return optString( index ).orElse( def );
}
/**
@ -435,7 +435,7 @@ public interface IArguments
*/
default Map<?, ?> optTable( int index, Map<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
{
Object value = this.get( index );
Object value = get( index );
if( value == null )
{
return Optional.empty();

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ public interface IWiredNode extends IPacketNetwork
*/
default boolean connectTo( @Nonnull IWiredNode node )
{
return this.getNetwork().connect( this, node );
return getNetwork().connect( this, node );
}
/**
@ -72,7 +72,7 @@ public interface IWiredNode extends IPacketNetwork
*/
default boolean disconnectFrom( @Nonnull IWiredNode node )
{
return this.getNetwork().disconnect( this, node );
return getNetwork().disconnect( this, node );
}
/**
@ -86,7 +86,7 @@ public interface IWiredNode extends IPacketNetwork
*/
default boolean remove()
{
return this.getNetwork().remove( this );
return getNetwork().remove( this );
}
/**
@ -99,6 +99,6 @@ public interface IWiredNode extends IPacketNetwork
*/
default void updatePeripherals( @Nonnull Map<String, IPeripheral> peripherals )
{
this.getNetwork().updatePeripherals( this, peripherals );
getNetwork().updatePeripherals( this, peripherals );
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -267,7 +267,7 @@ public interface ITurtleAccess
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()
{
return this.success;
return success;
}
/**
@ -102,7 +102,7 @@ public final class TurtleCommandResult
@Nullable
public String getErrorMessage()
{
return this.errorMessage;
return errorMessage;
}
/**
@ -113,6 +113,6 @@ public final class TurtleCommandResult
@Nullable
public Object[] getResults()
{
return this.results;
return results;
}
}

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
*/
public World getWorld()
{
return this.world;
return world;
}
/**
@ -62,7 +62,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
*/
public BlockPos getPos()
{
return this.pos;
return pos;
}
/**
@ -97,7 +97,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public BlockState getBlock()
{
return this.block;
return block;
}
/**
@ -108,7 +108,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public ITurtleUpgrade getUpgrade()
{
return this.upgrade;
return upgrade;
}
/**
@ -119,7 +119,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public TurtleSide getSide()
{
return this.side;
return side;
}
}
@ -161,7 +161,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public ItemStack getStack()
{
return this.stack;
return stack;
}
}
@ -196,7 +196,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public BlockState getState()
{
return this.state;
return state;
}
/**
@ -207,7 +207,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent
@Nonnull
public Map<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 )
{
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
public ITurtleAccess getTurtle()
{
return this.turtle;
return turtle;
}
}

View File

@ -53,7 +53,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
@Nonnull
public ItemStack getStack()
{
return this.stack;
return stack;
}
/**
@ -64,7 +64,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
@Nonnull
public Map<String, Object> getData()
{
return this.data;
return data;
}
/**
@ -74,7 +74,7 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
*/
public boolean onMainThread()
{
return this.mainThread;
return mainThread;
}
/**
@ -85,6 +85,6 @@ public class TurtleInspectItemEvent extends TurtleActionEvent
public void addData( @Nonnull Map<String, ?> newData )
{
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
public Inventory getItemHandler()
{
return this.handler;
return handler;
}
/**
@ -81,7 +81,7 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent
@Nonnull
public ItemStack getStack()
{
return this.stack;
return stack;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,22 +36,22 @@ public class GuiPrinter extends HandledScreen<ContainerPrinter>
@Override
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
{
this.renderBackground( stack );
renderBackground( stack );
super.render( stack, mouseX, mouseY, partialTicks );
this.drawMouseoverTooltip( stack, mouseX, mouseY );
drawMouseoverTooltip( stack, mouseX, mouseY );
}
@Override
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.client.getTextureManager()
client.getTextureManager()
.bindTexture( BACKGROUND );
this.drawTexture( transform, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight );
drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight );
if( this.getScreenHandler().isPrinting() )
if( getScreenHandler().isPrinting() )
{
this.drawTexture( transform, this.x + 34, this.y + 21, 176, 0, 25, 45 );
drawTexture( transform, x + 34, y + 21, 176, 0, 25, 45 );
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,11 +33,11 @@ public abstract class ItemMapLikeRenderer
transform.push();
if( hand == Hand.MAIN_HAND && player.getOffHandStack().isEmpty() )
{
this.renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack );
renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack );
}
else
{
this.renderItemFirstPersonSide( transform,
renderItemFirstPersonSide( transform,
render,
lightTexture,
hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(),
@ -89,7 +89,7 @@ public abstract class ItemMapLikeRenderer
transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) );
transform.scale( 2.0F, 2.0F, 2.0F );
this.renderItem( transform, render, stack );
renderItem( transform, render, stack );
}
/**
@ -133,7 +133,7 @@ public abstract class ItemMapLikeRenderer
transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( f2 * -45f ) );
transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) );
this.renderItem( transform, render, stack );
renderItem( transform, render, stack );
transform.pop();
}

View File

@ -229,7 +229,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer<TileMonitor>
}
case VBO:
{
VertexBuffer vbo = monitor.buffer;
if( redraw )
{
@ -259,7 +258,6 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer<TileMonitor>
FixedWidthFontRenderer.TYPE.getVertexFormat()
.endDrawing();
break;
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.
*

View File

@ -66,7 +66,7 @@ public final class Generator<T>
{
this.base = base;
this.context = context;
this.interfaces = new String[] { Type.getInternalName( base ) };
interfaces = new String[] { Type.getInternalName( base ) };
this.wrap = wrap;
StringBuilder methodDesc = new StringBuilder().append( "(Ljava/lang/Object;" );
@ -223,62 +223,60 @@ public final class Generator<T>
mw.visitEnd();
}
MethodVisitor mw = cw.visitMethod( ACC_PUBLIC, METHOD_NAME, methodDesc, null, EXCEPTIONS );
mw.visitCode();
// If we're an instance method, load the this parameter.
if( !Modifier.isStatic( method.getModifiers() ) )
{
MethodVisitor mw = cw.visitMethod( ACC_PUBLIC, METHOD_NAME, methodDesc, null, EXCEPTIONS );
mw.visitCode();
// If we're an instance method, load the this parameter.
if( !Modifier.isStatic( method.getModifiers() ) )
{
mw.visitVarInsn( ALOAD, 1 );
mw.visitTypeInsn( CHECKCAST, Type.getInternalName( target ) );
}
int argIndex = 0;
for( java.lang.reflect.Type genericArg : method.getGenericParameterTypes() )
{
Boolean loadedArg = loadArg( mw, target, method, genericArg, argIndex );
if( loadedArg == null ) return null;
if( loadedArg ) argIndex++;
}
mw.visitMethodInsn(
Modifier.isStatic( method.getModifiers() ) ? INVOKESTATIC : INVOKEVIRTUAL,
Type.getInternalName( method.getDeclaringClass() ), method.getName(),
Type.getMethodDescriptor( method ), false
);
// We allow a reasonable amount of flexibility on the return value's type. Alongside the obvious MethodResult,
// we convert basic types into an immediate result.
Class<?> ret = method.getReturnType();
if( ret != MethodResult.class )
{
if( ret == void.class )
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "()" + DESC_METHOD_RESULT, false );
}
else if( ret.isPrimitive() )
{
Class<?> boxed = Primitives.wrap( ret );
mw.visitMethodInsn( INVOKESTATIC, Type.getInternalName( boxed ), "valueOf", "(" + Type.getDescriptor( ret ) + ")" + Type.getDescriptor( boxed ), false );
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
else if( ret == Object[].class )
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "([Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
else
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
}
mw.visitInsn( ARETURN );
mw.visitMaxs( 0, 0 );
mw.visitEnd();
mw.visitVarInsn( ALOAD, 1 );
mw.visitTypeInsn( CHECKCAST, Type.getInternalName( target ) );
}
int argIndex = 0;
for( java.lang.reflect.Type genericArg : method.getGenericParameterTypes() )
{
Boolean loadedArg = loadArg( mw, target, method, genericArg, argIndex );
if( loadedArg == null ) return null;
if( loadedArg ) argIndex++;
}
mw.visitMethodInsn(
Modifier.isStatic( method.getModifiers() ) ? INVOKESTATIC : INVOKEVIRTUAL,
Type.getInternalName( method.getDeclaringClass() ), method.getName(),
Type.getMethodDescriptor( method ), false
);
// We allow a reasonable amount of flexibility on the return value's type. Alongside the obvious MethodResult,
// we convert basic types into an immediate result.
Class<?> ret = method.getReturnType();
if( ret != MethodResult.class )
{
if( ret == void.class )
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "()" + DESC_METHOD_RESULT, false );
}
else if( ret.isPrimitive() )
{
Class<?> boxed = Primitives.wrap( ret );
mw.visitMethodInsn( INVOKESTATIC, Type.getInternalName( boxed ), "valueOf", "(" + Type.getDescriptor( ret ) + ")" + Type.getDescriptor( boxed ), false );
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
else if( ret == Object[].class )
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "([Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
else
{
mw.visitMethodInsn( INVOKESTATIC, INTERNAL_METHOD_RESULT, "of", "(Ljava/lang/Object;)" + DESC_METHOD_RESULT, false );
}
}
mw.visitInsn( ARETURN );
mw.visitMaxs( 0, 0 );
mw.visitEnd();
cw.visitEnd();
return cw.toByteArray();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -79,12 +79,12 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
}
int startParse = reader.getCursor();
this.appender.accept( out, this.child.parse( reader ) );
appender.accept( out, child.parse( reader ) );
hadSome = true;
if( reader.getCursor() == startParse )
{
throw new IllegalStateException( this.child + " did not consume any input on " + reader.getRemaining() );
throw new IllegalStateException( child + " did not consume any input on " + reader.getRemaining() );
}
}
@ -93,7 +93,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
// We should probably review that this is sensible in the future.
if( !hadSome )
{
throw this.some.createWithContext( reader );
throw some.createWithContext( reader );
}
return Collections.unmodifiableList( out );
@ -109,7 +109,7 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
{
try
{
this.child.parse( reader );
child.parse( reader );
}
catch( CommandSyntaxException e )
{
@ -126,13 +126,13 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
}
reader.setCursor( previous );
return this.child.listSuggestions( context, builder.createOffset( previous ) );
return child.listSuggestions( context, builder.createOffset( previous ) );
}
@Override
public Collection<String> getExamples()
{
return this.child.getExamples();
return child.getExamples();
}
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 )
{
this.requires = this.requires == null ? predicate : this.requires.and( predicate );
requires = requires == null ? predicate : requires.and( predicate );
return this;
}
public CommandBuilder<S> arg( String name, ArgumentType<?> type )
{
this.args.add( RequiredArgumentBuilder.argument( name, type ) );
args.add( RequiredArgumentBuilder.argument( name, type ) );
return this;
}
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 )
{
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 )
{
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 )
{
if( this.args.isEmpty() )
if( args.isEmpty() )
{
throw new IllegalStateException( "Cannot have empty arg chain builder" );
}
return command -> {
// 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
ArgumentBuilder<S, ?> moreArg = RequiredArgumentBuilder.<S, List<T>>argument( name, type ).executes( ctx -> command.run( ctx, getList( ctx, name ) ) );
// Chain all of them together!
tail.then( moreArg );
return this.link( tail );
return link( tail );
};
}
private ArgumentBuilder<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 );
if( this.requires != null )
if( requires != null )
{
defaultTail.requires( this.requires );
defaultTail.requires( requires );
}
return defaultTail;
}
@ -112,9 +112,9 @@ public class CommandBuilder<S> implements CommandNodeBuilder<S, Command<S>>
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 );
}
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 )
{
return this.argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty );
return argMany( name, RepeatArgumentType.someFlat( type, ARGUMENT_EXPECTED ), empty );
}
@Override
public CommandNode<S> executes( Command<S> command )
{
if( this.args.isEmpty() )
if( args.isEmpty() )
{
throw new IllegalStateException( "Cannot have empty arg chain builder" );
}
return this.link( this.tail( command ) );
return link( tail( command ) );
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@ public class ItemComputer extends ItemComputerBase
@Override
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
{
ItemStack result = ComputerItemFactory.create( this.getComputerID( stack ), null, family );
ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family );
if( stack.hasCustomName() )
{
result.setCustomName( stack.getName() );

View File

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

View File

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

View File

@ -32,7 +32,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
public ComputerFamily getFamily()
{
return this.family;
return family;
}
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 );
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,
@ -69,7 +69,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
ItemStack result = buf.readItemStack();
ComputerFamily family = buf.readEnumConstant( ComputerFamily.class );
return this.create( identifier, group, width, height, ingredients, result, family );
return create( identifier, group, width, height, ingredients, result, family );
}
@Override

View File

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

View File

@ -38,6 +38,6 @@ public final class ConstantLootConditionSerializer<T extends LootCondition> impl
@Override
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
public void appendStacks( @Nonnull ItemGroup tabs, @Nonnull DefaultedList<ItemStack> list )
{
if( !this.isIn( tabs ) )
if( !isIn( tabs ) )
{
return;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,6 +23,6 @@ public class ComputerDeletedClientMessage extends ComputerClientMessage
@Override
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 )
{
super.toBytes( buf );
this.state.write( buf );
state.write( buf );
}
@Override
public void fromBytes( @Nonnull PacketByteBuf buf )
{
super.fromBytes( buf );
this.state = new TerminalState( buf );
state = new TerminalState( buf );
}
@Override
public void handle( PacketContext context )
{
this.getComputer().read( this.state );
getComputer().read( state );
}
}

View File

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

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