mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-08 17:33:01 +00:00
Merge pull request #207 from SquidDev-CC/feature/cleanup
Fix a couple of warnings
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -8,6 +8,8 @@ package dan200.computercraft.shared.peripheral;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum PeripheralType implements IStringSerializable
|
||||
{
|
||||
DiskDrive( "disk_drive" ),
|
||||
@@ -22,11 +24,12 @@ public enum PeripheralType implements IStringSerializable
|
||||
|
||||
private String m_name;
|
||||
|
||||
private PeripheralType( String name )
|
||||
PeripheralType( String name )
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -14,6 +14,8 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CommandBlockPeripheral implements IPeripheral
|
||||
{
|
||||
private final TileEntityCommandBlock m_commandBlock;
|
||||
@@ -25,12 +27,14 @@ public class CommandBlockPeripheral implements IPeripheral
|
||||
|
||||
// IPeripheral methods
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "command";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -42,7 +46,7 @@ public class CommandBlockPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, final Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull final Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
@@ -108,12 +112,12 @@ public class CommandBlockPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
public void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -14,10 +14,12 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CommandBlockPeripheralProvider implements IPeripheralProvider
|
||||
{
|
||||
@Override
|
||||
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side )
|
||||
public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileEntityCommandBlock )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -10,24 +10,25 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.modem.TileCable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockCable extends BlockPeripheralBase
|
||||
{
|
||||
// Statics
|
||||
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyEnum<BlockCableModemVariant> MODEM = PropertyEnum.<BlockCableModemVariant>create( "modem", BlockCableModemVariant.class );
|
||||
public static final PropertyEnum<BlockCableModemVariant> MODEM = PropertyEnum.create( "modem", BlockCableModemVariant.class );
|
||||
public static final PropertyBool CABLE = PropertyBool.create( "cable" );
|
||||
public static final PropertyBool NORTH = PropertyBool.create( "north" );
|
||||
public static final PropertyBool SOUTH = PropertyBool.create( "south" );
|
||||
@@ -73,10 +74,11 @@ public class BlockCable extends BlockPeripheralBase
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
return new BlockStateContainer( this,
|
||||
Properties.MODEM,
|
||||
Properties.CABLE,
|
||||
Properties.NORTH,
|
||||
@@ -84,11 +86,13 @@ public class BlockCable extends BlockPeripheralBase
|
||||
Properties.EAST,
|
||||
Properties.WEST,
|
||||
Properties.UP,
|
||||
Properties.DOWN,
|
||||
});
|
||||
Properties.DOWN
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
IBlockState state = getDefaultState();
|
||||
@@ -114,8 +118,8 @@ public class BlockCable extends BlockPeripheralBase
|
||||
public int getMetaFromState( IBlockState state )
|
||||
{
|
||||
int meta = 0;
|
||||
boolean cable = (Boolean)state.getValue( Properties.CABLE );
|
||||
BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( Properties.MODEM );
|
||||
boolean cable = state.getValue( Properties.CABLE );
|
||||
BlockCableModemVariant modem = state.getValue( Properties.MODEM );
|
||||
if( cable && modem != BlockCableModemVariant.None )
|
||||
{
|
||||
meta = 6 + modem.getFacing().getIndex();
|
||||
@@ -160,11 +164,11 @@ public class BlockCable extends BlockPeripheralBase
|
||||
|
||||
private boolean doesConnect( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing dir )
|
||||
{
|
||||
if( !((Boolean)state.getValue( Properties.CABLE )) )
|
||||
if( !state.getValue( Properties.CABLE ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if( ((BlockCableModemVariant)state.getValue( Properties.MODEM )).getFacing() == dir )
|
||||
else if( state.getValue( Properties.MODEM ).getFacing() == dir )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -174,8 +178,10 @@ public class BlockCable extends BlockPeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
@Deprecated
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
state = state.withProperty( Properties.NORTH, doesConnect( state, world, pos, EnumFacing.NORTH ) );
|
||||
state = state.withProperty( Properties.SOUTH, doesConnect( state, world, pos, EnumFacing.SOUTH ) );
|
||||
@@ -196,7 +202,7 @@ public class BlockCable extends BlockPeripheralBase
|
||||
anim = 0;
|
||||
}
|
||||
|
||||
BlockCableModemVariant modem = ((BlockCableModemVariant)state.getValue( Properties.MODEM ));
|
||||
BlockCableModemVariant modem = state.getValue( Properties.MODEM );
|
||||
if( modem != BlockCableModemVariant.None )
|
||||
{
|
||||
modem = BlockCableModemVariant.values()[
|
||||
@@ -209,7 +215,8 @@ public class BlockCable extends BlockPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side )
|
||||
@Deprecated
|
||||
public boolean shouldSideBeRendered( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -223,8 +230,8 @@ public class BlockCable extends BlockPeripheralBase
|
||||
@Override
|
||||
public PeripheralType getPeripheralType( IBlockState state )
|
||||
{
|
||||
boolean cable = (Boolean)state.getValue( Properties.CABLE );
|
||||
BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( Properties.MODEM );
|
||||
boolean cable = state.getValue( Properties.CABLE );
|
||||
BlockCableModemVariant modem = state.getValue( Properties.MODEM );
|
||||
if( cable && modem != BlockCableModemVariant.None )
|
||||
{
|
||||
return PeripheralType.WiredModemWithCable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -9,6 +9,8 @@ package dan200.computercraft.shared.peripheral.common;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum BlockCableModemVariant implements IStringSerializable
|
||||
{
|
||||
None( "none", null ),
|
||||
@@ -54,12 +56,13 @@ public enum BlockCableModemVariant implements IStringSerializable
|
||||
private String m_name;
|
||||
private EnumFacing m_facing;
|
||||
|
||||
private BlockCableModemVariant( String name, EnumFacing facing )
|
||||
BlockCableModemVariant( String name, EnumFacing facing )
|
||||
{
|
||||
m_name = name;
|
||||
m_facing = facing;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,7 +13,6 @@ import dan200.computercraft.shared.peripheral.modem.TileWirelessModem;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
@@ -22,20 +21,22 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockPeripheral extends BlockPeripheralBase
|
||||
{
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL );
|
||||
public static final PropertyEnum<BlockPeripheralVariant> VARIANT = PropertyEnum.<BlockPeripheralVariant>create( "variant", BlockPeripheralVariant.class );
|
||||
public static final PropertyEnum<BlockPeripheralVariant> VARIANT = PropertyEnum.create( "variant", BlockPeripheralVariant.class );
|
||||
}
|
||||
|
||||
public BlockPeripheral()
|
||||
@@ -49,22 +50,23 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SideOnly( Side.CLIENT)
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.VARIANT
|
||||
});
|
||||
return new BlockStateContainer( this, Properties.FACING, Properties.VARIANT );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
IBlockState state = getDefaultState();
|
||||
@@ -110,12 +112,12 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
public int getMetaFromState( IBlockState state )
|
||||
{
|
||||
int meta = 0;
|
||||
BlockPeripheralVariant variant = (BlockPeripheralVariant)state.getValue( Properties.VARIANT );
|
||||
BlockPeripheralVariant variant = state.getValue( Properties.VARIANT );
|
||||
switch( variant.getPeripheralType() )
|
||||
{
|
||||
case DiskDrive:
|
||||
{
|
||||
EnumFacing dir = (EnumFacing)state.getValue( Properties.FACING );
|
||||
EnumFacing dir = state.getValue( Properties.FACING );
|
||||
if( dir.getAxis() == EnumFacing.Axis.Y ) {
|
||||
dir = EnumFacing.NORTH;
|
||||
}
|
||||
@@ -140,7 +142,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
}
|
||||
default:
|
||||
{
|
||||
EnumFacing dir = (EnumFacing)state.getValue( Properties.FACING );
|
||||
EnumFacing dir = state.getValue( Properties.FACING );
|
||||
meta = dir.getIndex() + 4;
|
||||
break;
|
||||
}
|
||||
@@ -166,8 +168,10 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
@Deprecated
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
int anim;
|
||||
EnumFacing dir;
|
||||
@@ -181,8 +185,8 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
else
|
||||
{
|
||||
anim = 0;
|
||||
dir = (EnumFacing)state.getValue( Properties.FACING );
|
||||
switch( (BlockPeripheralVariant)state.getValue( BlockPeripheral.Properties.VARIANT ) )
|
||||
dir = state.getValue( Properties.FACING );
|
||||
switch( state.getValue( Properties.VARIANT ) )
|
||||
{
|
||||
case WirelessModemDownOff:
|
||||
case WirelessModemDownOn:
|
||||
@@ -497,7 +501,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
@Override
|
||||
public PeripheralType getPeripheralType( IBlockState state )
|
||||
{
|
||||
return ((BlockPeripheralVariant)state.getValue( Properties.VARIANT )).getPeripheralType();
|
||||
return state.getValue( Properties.VARIANT ).getPeripheralType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -17,6 +17,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class BlockPeripheralBase extends BlockDirectional
|
||||
{
|
||||
public BlockPeripheralBase()
|
||||
@@ -30,19 +32,21 @@ public abstract class BlockPeripheralBase extends BlockDirectional
|
||||
protected abstract TilePeripheralBase createTile( PeripheralType type );
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final boolean isOpaqueCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canPlaceBlockOnSide( World world, BlockPos pos, EnumFacing side )
|
||||
public final boolean canPlaceBlockOnSide( @Nonnull World world, @Nonnull BlockPos pos, EnumFacing side )
|
||||
{
|
||||
return true; // ItemPeripheralBase handles this
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -9,6 +9,8 @@ package dan200.computercraft.shared.peripheral.common;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum BlockPeripheralVariant implements IStringSerializable
|
||||
{
|
||||
DiskDriveEmpty( "disk_drive_empty", PeripheralType.DiskDrive ),
|
||||
@@ -124,12 +126,13 @@ public enum BlockPeripheralVariant implements IStringSerializable
|
||||
private String m_name;
|
||||
private PeripheralType m_peripheralType;
|
||||
|
||||
private BlockPeripheralVariant( String name, PeripheralType peripheralType )
|
||||
BlockPeripheralVariant( String name, PeripheralType peripheralType )
|
||||
{
|
||||
m_name = name;
|
||||
m_peripheralType = peripheralType;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -16,6 +16,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DefaultPeripheralProvider implements IPeripheralProvider
|
||||
{
|
||||
public DefaultPeripheralProvider()
|
||||
@@ -23,7 +25,7 @@ public class DefaultPeripheralProvider implements IPeripheralProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPeripheral getPeripheral( World world, BlockPos pos, EnumFacing side )
|
||||
public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -11,5 +11,5 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IPeripheralItem
|
||||
{
|
||||
public PeripheralType getPeripheralType( ItemStack stack );
|
||||
PeripheralType getPeripheralType( ItemStack stack );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IPeripheralTile extends IDirectionalTile
|
||||
{
|
||||
public PeripheralType getPeripheralType();
|
||||
public IPeripheral getPeripheral( EnumFacing side );
|
||||
public String getLabel();
|
||||
PeripheralType getPeripheralType();
|
||||
IPeripheral getPeripheral( EnumFacing side );
|
||||
String getLabel();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAdvancedModem extends ItemPeripheralBase
|
||||
@@ -48,7 +49,7 @@ public class ItemAdvancedModem extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( Item itemID, CreativeTabs tabs, List list )
|
||||
public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List<ItemStack> list )
|
||||
{
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,6 +23,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCable extends ItemPeripheralBase
|
||||
@@ -63,14 +63,15 @@ public class ItemCable extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( Item itemID, CreativeTabs tabs, List list )
|
||||
public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List<ItemStack> list )
|
||||
{
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 ) );
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.Cable, null, 1 ) );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float fx, float fy, float fz )
|
||||
public EnumActionResult onItemUse( ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumHand hand, @Nonnull EnumFacing side, float fx, float fy, float fz )
|
||||
{
|
||||
if( !canPlaceBlockOnSide( world, pos, side, player, stack ) )
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPeripheral extends ItemPeripheralBase
|
||||
@@ -68,7 +69,7 @@ public class ItemPeripheral extends ItemPeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( Item itemID, CreativeTabs tabs, List list )
|
||||
public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List<ItemStack> list )
|
||||
{
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 ) );
|
||||
list.add( PeripheralItemFactory.create( PeripheralType.Printer, null, 1 ) );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class ItemPeripheralBase extends ItemBlock implements IPeripheralItem
|
||||
{
|
||||
protected ItemPeripheralBase( Block block )
|
||||
@@ -33,7 +35,7 @@ public abstract class ItemPeripheralBase extends ItemBlock implements IPeriphera
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide( World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack ) // canPlaceItemBlockOnSide
|
||||
public boolean canPlaceBlockOnSide( World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, EntityPlayer player, @Nonnull ItemStack stack ) // canPlaceItemBlockOnSide
|
||||
{
|
||||
PeripheralType type = getPeripheralType( stack );
|
||||
switch( type )
|
||||
@@ -55,6 +57,7 @@ public abstract class ItemPeripheralBase extends ItemBlock implements IPeriphera
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedName( ItemStack stack )
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TilePeripheralBase extends TileGeneric
|
||||
@@ -45,7 +46,7 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
@@ -149,7 +150,8 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
// Write properties
|
||||
@@ -164,7 +166,7 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDescription( NBTTagCompound nbttagcompound )
|
||||
public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
m_dir = EnumFacing.getFront( nbttagcompound.getInteger( "dir" ) );
|
||||
@@ -180,7 +182,7 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
nbttagcompound.setInteger( "dir", m_dir.getIndex() );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -12,6 +12,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerDiskDrive extends Container
|
||||
{
|
||||
private final TileDiskDrive m_diskDrive;
|
||||
@@ -36,7 +38,7 @@ public class ContainerDiskDrive extends Container
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( EntityPlayer player )
|
||||
public boolean canInteractWith( @Nonnull EntityPlayer player )
|
||||
{
|
||||
return m_diskDrive.isUseableByPlayer( player );
|
||||
}
|
||||
@@ -45,7 +47,7 @@ public class ContainerDiskDrive extends Container
|
||||
public ItemStack transferStackInSlot( EntityPlayer player, int i )
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(i);
|
||||
Slot slot = inventorySlots.get(i);
|
||||
if(slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -16,6 +16,8 @@ import dan200.computercraft.shared.util.StringUtil;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DiskDrivePeripheral implements IPeripheral
|
||||
{
|
||||
private final TileDiskDrive m_diskDrive;
|
||||
@@ -25,12 +27,14 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
m_diskDrive = diskDrive;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "drive";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -50,7 +54,7 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@@ -174,13 +178,13 @@ public class DiskDrivePeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
m_diskDrive.mount( computer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
public void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
m_diskDrive.unmount( computer );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -17,20 +17,18 @@ import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.audio.Sound;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -120,7 +118,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
IBlockState state = getBlockState();
|
||||
return (EnumFacing)state.getValue( BlockPeripheral.Properties.FACING );
|
||||
return state.getValue( BlockPeripheral.Properties.FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +143,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
@@ -276,10 +275,8 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
if( m_diskStack != null )
|
||||
{
|
||||
Set<IComputerAccess> computers = m_computers.keySet();
|
||||
Iterator<IComputerAccess> it = computers.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IComputerAccess computer : computers )
|
||||
{
|
||||
IComputerAccess computer = it.next();
|
||||
unmountDisk( computer );
|
||||
}
|
||||
}
|
||||
@@ -304,10 +301,8 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
if( m_diskStack != null )
|
||||
{
|
||||
Set<IComputerAccess> computers = m_computers.keySet();
|
||||
Iterator<IComputerAccess> it = computers.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IComputerAccess computer : computers )
|
||||
{
|
||||
IComputerAccess computer = it.next();
|
||||
mountDisk( computer );
|
||||
}
|
||||
}
|
||||
@@ -320,6 +315,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
return getLabel() != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@@ -334,6 +330,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
@@ -354,23 +351,23 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory( EntityPlayer player )
|
||||
public void openInventory( @Nonnull EntityPlayer player )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory( EntityPlayer player )
|
||||
public void closeInventory( @Nonnull EntityPlayer player )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, @Nonnull ItemStack itemstack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer player )
|
||||
public boolean isUseableByPlayer( @Nonnull EntityPlayer player )
|
||||
{
|
||||
return isUsable( player, false );
|
||||
}
|
||||
@@ -613,7 +610,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
if( nbttagcompound.hasKey( "item" ) )
|
||||
@@ -628,7 +625,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
if( m_diskStack != null )
|
||||
@@ -659,7 +656,7 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState )
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.DiskDrive;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -10,18 +10,16 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheralBase;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockAdvancedModem extends BlockPeripheralBase
|
||||
{
|
||||
@@ -42,16 +40,16 @@ public class BlockAdvancedModem extends BlockPeripheralBase
|
||||
);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.ON
|
||||
});
|
||||
return new BlockStateContainer(this, Properties.FACING, Properties.ON );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IBlockState getStateFromMeta( int meta )
|
||||
{
|
||||
IBlockState state = getDefaultState();
|
||||
@@ -63,12 +61,14 @@ public class BlockAdvancedModem extends BlockPeripheralBase
|
||||
@Override
|
||||
public int getMetaFromState( IBlockState state )
|
||||
{
|
||||
EnumFacing dir = (EnumFacing) state.getValue( Properties.FACING );
|
||||
EnumFacing dir = state.getValue( Properties.FACING );
|
||||
return dir.getIndex();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
@Deprecated
|
||||
public IBlockState getActualState( @Nonnull IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
int anim;
|
||||
EnumFacing dir;
|
||||
@@ -82,7 +82,7 @@ public class BlockAdvancedModem extends BlockPeripheralBase
|
||||
else
|
||||
{
|
||||
anim = 0;
|
||||
dir = (EnumFacing)state.getValue( Properties.FACING );
|
||||
dir = state.getValue( Properties.FACING );
|
||||
}
|
||||
|
||||
state = state.withProperty( Properties.FACING, dir );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -11,8 +11,8 @@ import net.minecraft.world.World;
|
||||
|
||||
public interface INetwork
|
||||
{
|
||||
public void addReceiver( IReceiver receiver );
|
||||
public void removeReceiver( IReceiver receiver );
|
||||
public void transmit( int channel, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject );
|
||||
public boolean isWireless();
|
||||
void addReceiver( IReceiver receiver );
|
||||
void removeReceiver( IReceiver receiver );
|
||||
void transmit( int channel, int replyChannel, Object payload, World world, Vec3d pos, double range, boolean interdimensional, Object senderObject );
|
||||
boolean isWireless();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -10,11 +10,11 @@ import net.minecraft.world.World;
|
||||
|
||||
public interface IReceiver
|
||||
{
|
||||
public int getChannel();
|
||||
public World getWorld();
|
||||
public Vec3d getWorldPosition();
|
||||
public boolean isInterdimensional();
|
||||
public double getReceiveRange();
|
||||
public void receiveSameDimension( int replyChannel, Object payload, double distance, Object senderObject );
|
||||
public void receiveDifferentDimension( int replyChannel, Object payload, Object senderObject );
|
||||
int getChannel();
|
||||
World getWorld();
|
||||
Vec3d getWorldPosition();
|
||||
boolean isInterdimensional();
|
||||
double getReceiveRange();
|
||||
void receiveSameDimension( int replyChannel, Object payload, double distance, Object senderObject );
|
||||
void receiveDifferentDimension( int replyChannel, Object payload, Object senderObject );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -13,8 +13,8 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ModemPeripheral
|
||||
@@ -84,7 +84,7 @@ public abstract class ModemPeripheral
|
||||
|
||||
private INetwork m_network;
|
||||
private IComputerAccess m_computer;
|
||||
private Map<Integer, IReceiver> m_channels;
|
||||
private final Map<Integer, IReceiver> m_channels;
|
||||
|
||||
private boolean m_open;
|
||||
private boolean m_changed;
|
||||
@@ -106,10 +106,9 @@ public abstract class ModemPeripheral
|
||||
// Leave old network
|
||||
if( m_network != null )
|
||||
{
|
||||
Iterator<IReceiver> it = m_channels.values().iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver iReceiver : m_channels.values() )
|
||||
{
|
||||
m_network.removeReceiver( it.next() );
|
||||
m_network.removeReceiver( iReceiver );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +118,9 @@ public abstract class ModemPeripheral
|
||||
// Join new network
|
||||
if( m_network != null )
|
||||
{
|
||||
Iterator<IReceiver> it = m_channels.values().iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver iReceiver : m_channels.values() )
|
||||
{
|
||||
m_network.addReceiver( it.next() );
|
||||
m_network.addReceiver( iReceiver );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,12 +201,14 @@ public abstract class ModemPeripheral
|
||||
|
||||
// IPeripheral implementation
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "modem";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -237,7 +237,7 @@ public abstract class ModemPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@@ -312,10 +312,9 @@ public abstract class ModemPeripheral
|
||||
{
|
||||
if( m_network != null )
|
||||
{
|
||||
Iterator<IReceiver> it = m_channels.values().iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver iReceiver : m_channels.values() )
|
||||
{
|
||||
m_network.removeReceiver( it.next() );
|
||||
m_network.removeReceiver( iReceiver );
|
||||
}
|
||||
}
|
||||
m_channels.clear();
|
||||
@@ -366,7 +365,7 @@ public abstract class ModemPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void attach( IComputerAccess computer )
|
||||
public synchronized void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
m_computer = computer;
|
||||
setNetwork( getNetwork() );
|
||||
@@ -374,14 +373,13 @@ public abstract class ModemPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void detach( IComputerAccess computer )
|
||||
public synchronized void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
if( m_network != null )
|
||||
{
|
||||
Iterator<IReceiver> it = m_channels.values().iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver iReceiver : m_channels.values() )
|
||||
{
|
||||
m_network.removeReceiver( it.next() );
|
||||
m_network.removeReceiver( iReceiver );
|
||||
}
|
||||
m_channels.clear();
|
||||
m_network = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -7,7 +7,6 @@
|
||||
package dan200.computercraft.shared.peripheral.modem;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.BlockPeripheral;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -64,7 +63,7 @@ public class TileAdvancedModem extends TileModemBase
|
||||
{
|
||||
// Wireless Modem
|
||||
IBlockState state = getBlockState();
|
||||
return (EnumFacing)state.getValue( BlockAdvancedModem.Properties.FACING );
|
||||
return state.getValue( BlockAdvancedModem.Properties.FACING );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -26,11 +26,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
@@ -93,6 +96,7 @@ public class TileCable extends TileModemBase
|
||||
return new Vec3d( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -117,7 +121,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
String[] methods = super.getMethodNames();
|
||||
switch( method - methods.length )
|
||||
@@ -129,10 +133,8 @@ public class TileCable extends TileModemBase
|
||||
{
|
||||
int idx = 1;
|
||||
Map<Object,Object> table = new HashMap<Object,Object>();
|
||||
Iterator<String> it = m_entity.m_peripheralWrappersByName.keySet().iterator();
|
||||
while( it.hasNext() )
|
||||
for( String name : m_entity.m_peripheralWrappersByName.keySet() )
|
||||
{
|
||||
String name = it.next();
|
||||
table.put( idx++, name );
|
||||
}
|
||||
return new Object[] { table };
|
||||
@@ -186,15 +188,13 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
super.attach( computer );
|
||||
synchronized( m_entity.m_peripheralsByName )
|
||||
{
|
||||
Iterator<String> it = m_entity.m_peripheralsByName.keySet().iterator();
|
||||
while( it.hasNext() )
|
||||
for (String periphName : m_entity.m_peripheralsByName.keySet())
|
||||
{
|
||||
String periphName = it.next();
|
||||
IPeripheral peripheral = m_entity.m_peripheralsByName.get( periphName );
|
||||
if( peripheral != null )
|
||||
{
|
||||
@@ -205,14 +205,12 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void detach( IComputerAccess computer )
|
||||
public synchronized void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
synchronized( m_entity.m_peripheralsByName )
|
||||
{
|
||||
Iterator<String> it = m_entity.m_peripheralsByName.keySet().iterator();
|
||||
while( it.hasNext() )
|
||||
for (String periphName : m_entity.m_peripheralsByName.keySet())
|
||||
{
|
||||
String periphName = it.next();
|
||||
m_entity.detachPeripheral( periphName );
|
||||
}
|
||||
}
|
||||
@@ -235,13 +233,13 @@ public class TileCable extends TileModemBase
|
||||
|
||||
// Members
|
||||
|
||||
private Map<Integer, Set<IReceiver>> m_receivers;
|
||||
private Queue<Packet> m_transmitQueue;
|
||||
private final Map<Integer, Set<IReceiver>> m_receivers;
|
||||
private final Queue<Packet> m_transmitQueue;
|
||||
|
||||
private boolean m_peripheralAccessAllowed;
|
||||
private int m_attachedPeripheralID;
|
||||
|
||||
private Map<String, IPeripheral> m_peripheralsByName;
|
||||
private final Map<String, IPeripheral> m_peripheralsByName;
|
||||
private Map<String, RemotePeripheralWrapper> m_peripheralWrappersByName;
|
||||
private boolean m_peripheralsKnown;
|
||||
private boolean m_destroyed;
|
||||
@@ -279,7 +277,7 @@ public class TileCable extends TileModemBase
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
IBlockState state = getBlockState();
|
||||
BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( BlockCable.Properties.MODEM );
|
||||
BlockCableModemVariant modem = state.getValue( BlockCable.Properties.MODEM );
|
||||
if( modem != BlockCableModemVariant.None )
|
||||
{
|
||||
return modem.getFacing();
|
||||
@@ -294,7 +292,7 @@ public class TileCable extends TileModemBase
|
||||
public void setDirection( EnumFacing dir )
|
||||
{
|
||||
IBlockState state = getBlockState();
|
||||
BlockCableModemVariant modem = ( BlockCableModemVariant )state.getValue( BlockCable.Properties.MODEM );
|
||||
BlockCableModemVariant modem = state.getValue( BlockCable.Properties.MODEM );
|
||||
if( modem != BlockCableModemVariant.None )
|
||||
{
|
||||
setBlockState( state.withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.fromFacing( dir ) ) );
|
||||
@@ -302,7 +300,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
if( !creative )
|
||||
{
|
||||
@@ -409,6 +407,7 @@ public class TileCable extends TileModemBase
|
||||
return new AxisAlignedBB( xMin, yMin, zMin, xMax, yMax, zMax );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBounds()
|
||||
{
|
||||
@@ -434,7 +433,7 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCollisionBounds( List<AxisAlignedBB> bounds )
|
||||
public void getCollisionBounds( @Nonnull List<AxisAlignedBB> bounds )
|
||||
{
|
||||
PeripheralType type = getPeripheralType();
|
||||
if( type == PeripheralType.WiredModem || type == PeripheralType.WiredModemWithCable )
|
||||
@@ -503,7 +502,8 @@ public class TileCable extends TileModemBase
|
||||
m_attachedPeripheralID = nbttagcompound.getInteger( "peripheralID" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
// Write properties
|
||||
@@ -752,11 +752,9 @@ public class TileCable extends TileModemBase
|
||||
Set<IReceiver> receivers = m_receivers.get( packet.channel );
|
||||
if( receivers != null )
|
||||
{
|
||||
Iterator<IReceiver> it = receivers.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver receiver : receivers )
|
||||
{
|
||||
IReceiver receiver = it.next();
|
||||
receiver.receiveSameDimension( packet.replyChannel, packet.payload, (double)distanceTravelled, packet.senderObject );
|
||||
receiver.receiveSameDimension( packet.replyChannel, packet.payload, (double) distanceTravelled, packet.senderObject );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -828,25 +826,25 @@ public class TileCable extends TileModemBase
|
||||
// IComputerAccess implementation
|
||||
|
||||
@Override
|
||||
public String mount( String desiredLocation, IMount mount )
|
||||
public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount )
|
||||
{
|
||||
return m_computer.mount( desiredLocation, mount, m_name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mount( String desiredLocation, IMount mount, String driveName )
|
||||
public String mount( @Nonnull String desiredLocation, @Nonnull IMount mount, @Nonnull String driveName )
|
||||
{
|
||||
return m_computer.mount( desiredLocation, mount, driveName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount )
|
||||
public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount )
|
||||
{
|
||||
return m_computer.mountWritable( desiredLocation, mount, m_name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName )
|
||||
public String mountWritable( @Nonnull String desiredLocation, @Nonnull IWritableMount mount, @Nonnull String driveName )
|
||||
{
|
||||
return m_computer.mountWritable( desiredLocation, mount, driveName );
|
||||
}
|
||||
@@ -864,11 +862,12 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queueEvent( String event, Object[] arguments )
|
||||
public void queueEvent( @Nonnull String event, Object[] arguments )
|
||||
{
|
||||
m_computer.queueEvent( event, arguments );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getAttachmentName()
|
||||
{
|
||||
@@ -915,10 +914,8 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
// Attach all the new peripherals
|
||||
Iterator<String> it2 = newPeripheralsByName.keySet().iterator();
|
||||
while( it2.hasNext() )
|
||||
for( String periphName : newPeripheralsByName.keySet() )
|
||||
{
|
||||
String periphName = it2.next();
|
||||
if( !m_peripheralsByName.containsKey( periphName ) )
|
||||
{
|
||||
IPeripheral peripheral = newPeripheralsByName.get( periphName );
|
||||
@@ -989,9 +986,9 @@ public class TileCable extends TileModemBase
|
||||
|
||||
// Generic network search stuff
|
||||
|
||||
private static interface ICableVisitor
|
||||
private interface ICableVisitor
|
||||
{
|
||||
public void visit( TileCable modem, int distance );
|
||||
void visit( TileCable modem, int distance );
|
||||
}
|
||||
|
||||
private static class SearchLoc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public abstract class TileModemBase extends TilePeripheralBase
|
||||
{
|
||||
private static final AxisAlignedBB[] BOXES = new AxisAlignedBB[] {
|
||||
@@ -65,6 +67,7 @@ public abstract class TileModemBase extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBounds()
|
||||
{
|
||||
@@ -95,7 +98,7 @@ public abstract class TileModemBase extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
updateBlock();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -17,6 +17,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileWirelessModem extends TileModemBase
|
||||
{
|
||||
// Statics
|
||||
@@ -67,7 +69,7 @@ public class TileWirelessModem extends TileModemBase
|
||||
{
|
||||
// Wireless Modem
|
||||
IBlockState state = getBlockState();
|
||||
switch( (BlockPeripheralVariant)state.getValue( BlockPeripheral.Properties.VARIANT ) )
|
||||
switch( state.getValue( BlockPeripheral.Properties.VARIANT ) )
|
||||
{
|
||||
case WirelessModemDownOff:
|
||||
case WirelessModemDownOn:
|
||||
@@ -81,7 +83,7 @@ public class TileWirelessModem extends TileModemBase
|
||||
}
|
||||
default:
|
||||
{
|
||||
return (EnumFacing)state.getValue( BlockPeripheral.Properties.FACING );
|
||||
return state.getValue( BlockPeripheral.Properties.FACING );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +122,7 @@ public class TileWirelessModem extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState )
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.WirelessModem;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -66,10 +66,8 @@ public class WirelessNetwork implements INetwork
|
||||
Set<IReceiver> receivers = m_receivers.get( channel );
|
||||
if( receivers != null )
|
||||
{
|
||||
Iterator<IReceiver> it = receivers.iterator();
|
||||
while( it.hasNext() )
|
||||
for( IReceiver receiver : receivers )
|
||||
{
|
||||
IReceiver receiver = it.next();
|
||||
tryTransmit( receiver, replyChannel, payload, world, pos, range, interdimensional, senderObject );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -16,6 +16,8 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class MonitorPeripheral implements IPeripheral
|
||||
{
|
||||
private final TileMonitor m_monitor;
|
||||
@@ -27,12 +29,14 @@ public class MonitorPeripheral implements IPeripheral
|
||||
|
||||
// IPeripheral implementation
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "monitor";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -65,7 +69,7 @@ public class MonitorPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object args[] ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object args[] ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@@ -115,7 +119,7 @@ public class MonitorPeripheral implements IPeripheral
|
||||
throw new LuaException( "Expected boolean" );
|
||||
}
|
||||
Terminal terminal = m_monitor.getTerminal().getTerminal();
|
||||
terminal.setCursorBlink( ((Boolean)args[0]).booleanValue() );
|
||||
terminal.setCursorBlink( (Boolean) args[ 0 ] );
|
||||
return null;
|
||||
}
|
||||
case 4:
|
||||
@@ -273,13 +277,13 @@ public class MonitorPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
m_monitor.addComputer( computer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
public void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
m_monitor.removeComputer( computer );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -111,6 +112,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
@@ -206,7 +208,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
// Networking stuff
|
||||
|
||||
@Override
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
nbttagcompound.setInteger( "xIndex", m_xIndex );
|
||||
@@ -219,7 +221,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
|
||||
@@ -815,6 +817,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
@@ -840,7 +843,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState )
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
if( super.shouldRefresh( world, pos, oldState, newState ) )
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerPrinter extends Container
|
||||
{
|
||||
private TilePrinter m_printer;
|
||||
@@ -75,12 +77,11 @@ public class ContainerPrinter extends Container
|
||||
if( !m_printer.getWorld().isRemote )
|
||||
{
|
||||
boolean printing = m_printer.isPrinting();
|
||||
for (int i=0; i<listeners.size(); ++i)
|
||||
for( IContainerListener listener : listeners )
|
||||
{
|
||||
IContainerListener icrafting = (IContainerListener)listeners.get(i);
|
||||
if( printing != m_lastPrinting )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, 0, printing ? 1 : 0 );
|
||||
listener.sendProgressBarUpdate( this, 0, printing ? 1 : 0 );
|
||||
}
|
||||
}
|
||||
m_lastPrinting = printing;
|
||||
@@ -97,7 +98,7 @@ public class ContainerPrinter extends Container
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( EntityPlayer player )
|
||||
public boolean canInteractWith( @Nonnull EntityPlayer player )
|
||||
{
|
||||
return m_printer.isUseableByPlayer( player );
|
||||
}
|
||||
@@ -106,7 +107,7 @@ public class ContainerPrinter extends Container
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(i);
|
||||
Slot slot = inventorySlots.get(i);
|
||||
if( slot != null && slot.getHasStack() )
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -12,6 +12,8 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PrinterPeripheral implements IPeripheral
|
||||
{
|
||||
private final TilePrinter m_printer;
|
||||
@@ -21,12 +23,14 @@ public class PrinterPeripheral implements IPeripheral
|
||||
m_printer = printer;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "printer";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
@@ -44,7 +48,7 @@ public class PrinterPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] args ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
@@ -139,12 +143,12 @@ public class PrinterPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
public void attach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
public void detach( @Nonnull IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
@@ -29,6 +29,8 @@ import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TilePrinter extends TilePeripheralBase
|
||||
implements IInventory, ISidedInventory
|
||||
{
|
||||
@@ -102,7 +104,8 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
@@ -136,14 +139,14 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh( World world, BlockPos pos, IBlockState oldState, IBlockState newState )
|
||||
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
|
||||
{
|
||||
return super.shouldRefresh( world, pos, oldState, newState ) || ComputerCraft.Blocks.peripheral.getPeripheralType( newState ) != PeripheralType.Printer;
|
||||
}
|
||||
@@ -243,6 +246,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
return getLabel() != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@@ -257,6 +261,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
@@ -277,23 +282,23 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory( EntityPlayer player )
|
||||
public void openInventory( @Nonnull EntityPlayer player )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory( EntityPlayer player )
|
||||
public void closeInventory( @Nonnull EntityPlayer player )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int slot, ItemStack itemstack )
|
||||
public boolean isItemValidForSlot( int slot, @Nonnull ItemStack itemstack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer player )
|
||||
public boolean isUseableByPlayer( @Nonnull EntityPlayer player )
|
||||
{
|
||||
return isUsable( player, false );
|
||||
}
|
||||
@@ -317,8 +322,9 @@ public class TilePrinter extends TilePeripheralBase
|
||||
|
||||
// ISidedInventory implementation
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace( EnumFacing side )
|
||||
@Nonnull
|
||||
@Override
|
||||
public int[] getSlotsForFace( @Nonnull EnumFacing side )
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
@@ -329,13 +335,13 @@ public class TilePrinter extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( int slot, ItemStack itemstack, EnumFacing face )
|
||||
public boolean canInsertItem( int slot, @Nonnull ItemStack itemstack, @Nonnull EnumFacing face )
|
||||
{
|
||||
return isItemValidForSlot( slot, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slot, ItemStack itemstack, EnumFacing face )
|
||||
public boolean canExtractItem( int slot, @Nonnull ItemStack itemstack, @Nonnull EnumFacing face )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -441,16 +447,8 @@ public class TilePrinter extends TilePeripheralBase
|
||||
{
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
ItemStack inkStack = m_inventory[0];
|
||||
if( inkStack == null || !isInk(inkStack) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( getPaperLevel() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
ItemStack inkStack = m_inventory[ 0 ];
|
||||
return inkStack != null && isInk( inkStack ) && getPaperLevel() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user