mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 13:13:00 +00:00 
			
		
		
		
	Add @Nullable and @NonNull annotations
This commit is contained in:
		| @@ -25,6 +25,7 @@ import net.minecraft.world.Explosion; | ||||
| import net.minecraft.world.IBlockAccess; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| @@ -43,12 +44,13 @@ public abstract class BlockGeneric extends Block implements | ||||
|     protected abstract TileGeneric createTile( int damage ); | ||||
|  | ||||
|     @Override | ||||
|     public final void dropBlockAsItemWithChance( World world, BlockPos pos, IBlockState state, float chance, int fortune ) | ||||
|     public final void dropBlockAsItemWithChance( World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, float chance, int fortune ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, IBlockState state, int fortune ) | ||||
|     public final List<ItemStack> getDrops( IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune ) | ||||
|     { | ||||
|         ArrayList<ItemStack> drops = new ArrayList<ItemStack>( 1 ); | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
| @@ -60,6 +62,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|         return drops; | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final IBlockState onBlockPlaced( World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int damage, EntityLivingBase placer ) | ||||
|     { | ||||
| @@ -67,7 +70,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public final boolean removedByPlayer( IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest ) | ||||
|     public final boolean removedByPlayer( @Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest ) | ||||
|     { | ||||
|         if( !world.isRemote ) | ||||
|         { | ||||
| @@ -109,7 +112,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public final void breakBlock( World world, BlockPos pos, IBlockState newState ) | ||||
|     public final void breakBlock( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric ) | ||||
| @@ -121,8 +124,9 @@ public abstract class BlockGeneric extends Block implements | ||||
|         world.removeTileEntity( pos ); | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player ) | ||||
|     public final ItemStack getPickBlock( @Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric ) | ||||
| @@ -134,7 +138,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected final ItemStack createStackedBlock( IBlockState state ) | ||||
|     protected final ItemStack createStackedBlock( @Nonnull IBlockState state ) | ||||
|     { | ||||
|         return null; | ||||
|     } | ||||
| @@ -174,7 +178,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public final boolean isSideSolid( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side ) | ||||
|     public final boolean isSideSolid( IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric ) | ||||
| @@ -192,7 +196,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public float getExplosionResistance( World world, BlockPos pos, Entity exploder, Explosion explosion ) | ||||
|     public float getExplosionResistance( World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) | ||||
| @@ -206,6 +210,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|         return super.getExplosionResistance( exploder ); | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess world, BlockPos pos ) | ||||
|     { | ||||
| @@ -218,14 +223,15 @@ public abstract class BlockGeneric extends Block implements | ||||
|         return FULL_BLOCK_AABB; | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public AxisAlignedBB getSelectedBoundingBox( IBlockState state, World worldIn, BlockPos pos ) | ||||
|     public final AxisAlignedBB getSelectedBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos ) | ||||
|     { | ||||
|         return getBoundingBox( state, worldIn, pos ).offset( pos ); | ||||
|         return getBoundingBox( state, world, pos ).offset( pos ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos ) | ||||
|     public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) | ||||
| @@ -252,7 +258,7 @@ public abstract class BlockGeneric extends Block implements | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public final void addCollisionBoxToList( IBlockState state, World world, BlockPos pos, AxisAlignedBB bigBox, List<AxisAlignedBB> list, Entity entity ) | ||||
|     public final void addCollisionBoxToList( IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB bigBox, @Nonnull List<AxisAlignedBB> list, Entity entity ) | ||||
|     { | ||||
|         TileEntity tile = world.getTileEntity( pos ); | ||||
|         if( tile != null && tile instanceof TileGeneric && tile.hasWorldObj() ) | ||||
| @@ -349,14 +355,16 @@ public abstract class BlockGeneric extends Block implements | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final TileEntity createTileEntity( World world, IBlockState state ) | ||||
|     public final TileEntity createTileEntity( @Nonnull World world, @Nonnull IBlockState state ) | ||||
|     { | ||||
|         return createTile( state ); | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public final TileEntity createNewTileEntity( World world, int damage ) | ||||
|     public final TileEntity createNewTileEntity( @Nonnull World world, int damage ) | ||||
|     { | ||||
|         return createTile( damage ); | ||||
|     } | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
|  | ||||
| public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider | ||||
| { | ||||
|     public DefaultBundledRedstoneProvider() | ||||
| @@ -19,7 +21,7 @@ public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) | ||||
|     public int getBundledRedstoneOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side ) | ||||
|     { | ||||
|         return getDefaultBundledRedstoneOutput( world, pos, side ); | ||||
|     } | ||||
|   | ||||
| @@ -23,6 +23,8 @@ import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import javax.annotation.Nullable; | ||||
| import java.util.List; | ||||
|  | ||||
| public abstract class TileGeneric extends TileEntity | ||||
| @@ -48,6 +50,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     @Nullable | ||||
|     public BlockGeneric getBlock() | ||||
|     { | ||||
|         Block block = worldObj.getBlockState( getPos() ).getBlock(); | ||||
| @@ -77,7 +80,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|         worldObj.setBlockState( getPos(), newState, 3 ); | ||||
|     } | ||||
|  | ||||
|     public void getDroppedItems( List<ItemStack> drops, boolean creative ) | ||||
|     public void getDroppedItems( @Nonnull List<ItemStack> drops, boolean creative ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
| @@ -95,7 +98,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public void onNeighbourTileEntityChange( BlockPos neighbour ) | ||||
|     public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
| @@ -109,12 +112,13 @@ public abstract class TileGeneric extends TileEntity | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     public AxisAlignedBB getBounds() | ||||
|     { | ||||
|         return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ); | ||||
|     } | ||||
|  | ||||
|     public void getCollisionBounds( List<AxisAlignedBB> bounds ) | ||||
|     public void getCollisionBounds( @Nonnull List<AxisAlignedBB> bounds ) | ||||
|     { | ||||
|         bounds.add( getBounds() ); | ||||
|     } | ||||
| @@ -129,12 +133,12 @@ public abstract class TileGeneric extends TileEntity | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     public boolean getBundledRedstoneConnectivity( EnumFacing side ) | ||||
|     public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side ) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public int getBundledRedstoneOutput( EnumFacing side ) | ||||
|     public int getBundledRedstoneOutput( @Nonnull EnumFacing side ) | ||||
|     { | ||||
|         return 0; | ||||
|     } | ||||
| @@ -163,11 +167,11 @@ public abstract class TileGeneric extends TileEntity | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     protected void writeDescription( NBTTagCompound nbttagcompound ) | ||||
|     protected void writeDescription( @Nonnull NBTTagCompound nbttagcompound ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     protected void readDescription( NBTTagCompound nbttagcompound ) | ||||
|     protected void readDescription( @Nonnull NBTTagCompound nbttagcompound ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
| @@ -186,7 +190,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|     } | ||||
|  | ||||
|     @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 newState.getBlock() != oldState.getBlock(); | ||||
|     } | ||||
| @@ -215,6 +219,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|     @Override | ||||
|     public NBTTagCompound getUpdateTag () | ||||
|     { | ||||
| @@ -224,7 +229,7 @@ public abstract class TileGeneric extends TileEntity | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleUpdateTag (NBTTagCompound tag) | ||||
|     public void handleUpdateTag ( @Nonnull NBTTagCompound tag) | ||||
|     { | ||||
|         super.handleUpdateTag(tag); | ||||
|         readDescription( tag ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 SquidDev
					SquidDev