BartMassey/mc-level — pull request #5 by XaaK (2013-02-26 07:43:23+00:00)
Title: Filtering by enchantment and enchantment levels

The itemId, enchantmentId, and enchantment level qualifiers will all work to filter the full item list (which includes both free and contained items). Things like this will work (assuming you setup a new world with some qualifying data):

>mc-level XaaK$ mc-finder "item=276[ench=16[level=1]]" "TestWorld/"
item=276[x=-240,y=72,z=462,source=free[dim=surface],enchantments=[ItemEnchantment {enchantmentId = 16, enchantmentLevel = 1}]]

>mc-level XaaK$ mc-finder "item=276[ench=19[level=1]]" "TestWorld/"
item=-1[x=-234,y=72,z=480,source=tile[dim=surface],enchantments=[]
containedItems=
item=276[x=-234,y=72,z=480,source=inside[Chest],enchantments=[ItemEnchantment {enchantmentId = 19, enchantmentLevel = 1}]]
]

>mc-level XaaK$ mc-finder "item=276" "TestWorld/"
item=276[x=-240,y=72,z=462,source=free[dim=surface],enchantments=[ItemEnchantment {enchantmentId = 16, enchantmentLevel = 1}]]
item=-1[x=-234,y=72,z=480,source=tile[dim=surface],enchantments=[]
containedItems=
item=276[x=-234,y=72,z=480,source=inside[Chest],enchantments=[ItemEnchantment {enchantmentId = 19, enchantmentLevel = 1}]]
]

Note that the first query finds the free item and the second one finds the item contained within the chest (thus displaying both the container and the found item).

This might be a good time to add unit tests to the project - as it would be easier to construct tests to exercise some of these scenarios than create minecraft levels.

As always - let me know if there are improvements or suggestions you have for the code.

Thanks.