use of cn.nukkit.item.Item in project Nukkit by Nukkit.
the class BlockOreDiamond method getDrops.
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[] { new ItemDiamond(0, count) };
} else {
return new Item[0];
}
}
use of cn.nukkit.item.Item in project Nukkit by Nukkit.
the class CraftingManager method getMultiItemHash.
private String getMultiItemHash(Collection<Item> items) {
BinaryStream stream = new BinaryStream();
for (Item item : items) {
stream.putUnsignedVarInt(item.getId());
stream.putVarInt(item.getDamage());
}
return new String(stream.getByteArray());
}
use of cn.nukkit.item.Item in project Nukkit by Nukkit.
the class CraftingManager method cloneItemMap.
private Item[][] cloneItemMap(Item[][] map) {
Item[][] newMap = new Item[map.length][];
for (int i = 0; i < newMap.length; i++) {
Item[] old = map[i];
Item[] n = new Item[old.length];
System.arraycopy(old, 0, n, 0, n.length);
newMap[i] = n;
}
for (int y = 0; y < newMap.length; y++) {
Item[] row = newMap[y];
for (int x = 0; x < row.length; x++) {
Item item = newMap[y][x];
newMap[y][x] = item.clone();
}
}
return newMap;
}
use of cn.nukkit.item.Item in project Nukkit by Nukkit.
the class CraftingManager method registerFurnaceRecipe.
public void registerFurnaceRecipe(FurnaceRecipe recipe) {
Item input = recipe.getInput();
this.furnaceRecipes.put(getItemHash(input), recipe);
}
use of cn.nukkit.item.Item in project Nukkit by Nukkit.
the class CraftingManager method registerBrewingRecipe.
public void registerBrewingRecipe(BrewingRecipe recipe) {
Item input = recipe.getInput();
Item potion = recipe.getPotion();
this.brewingRecipes.put(getItemHash(input.getId(), (!potion.hasMeta() ? 0 : potion.getDamage())), recipe);
}
Aggregations