the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.item.h"
3#include "DigDurabilityEnchantment.h"
4
5DigDurabilityEnchantment::DigDurabilityEnchantment(int id, int frequency) : Enchantment(id, frequency, EnchantmentCategory::digger)
6{
7 setDescriptionId(IDS_ENCHANTMENT_DURABILITY);
8}
9
10int DigDurabilityEnchantment::getMinCost(int level)
11{
12 return 5 + (level - 1) * 8;
13}
14
15int DigDurabilityEnchantment::getMaxCost(int level)
16{
17 return Enchantment::getMinCost(level) + 50;
18}
19
20int DigDurabilityEnchantment::getMaxLevel()
21{
22 return 3;
23}
24
25bool DigDurabilityEnchantment::canEnchant(shared_ptr<ItemInstance> item)
26{
27 if (item->isDamageableItem()) return true;
28 return Enchantment::canEnchant(item);
29}
30
31bool DigDurabilityEnchantment::shouldIgnoreDurabilityDrop(shared_ptr<ItemInstance> item, int level, Random *random)
32{
33 ArmorItem *armor = dynamic_cast<ArmorItem *>(item->getItem());
34 if (armor && random->nextFloat() < 0.6f) return false;
35 return random->nextInt(level + 1) > 0;
36}