feature/enhancement/farm-fortune: Initial commit

This commit is contained in:
James Edington 2021-04-27 22:55:37 -05:00
parent fccac8ed74
commit 136d040ee0
1 changed files with 5 additions and 0 deletions

View File

@ -122,6 +122,8 @@ public class ToolSet {
double highestSpeed = Double.NEGATIVE_INFINITY;
int lowestCost = Integer.MIN_VALUE;
boolean bestSilkTouch = false;
int bestFortune = Integer.MIN_VALUE;
boolean isCrop = b instanceof CropBlock;
IBlockState blockState = b.getDefaultState();
for (int i = 0; i < 9; i++) {
ItemStack itemStack = player.inventory.getStackInSlot(i);
@ -134,11 +136,13 @@ public class ToolSet {
}
double speed = calculateSpeedVsBlock(itemStack, blockState);
boolean silkTouch = hasSilkTouch(itemStack);
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemStack);
if (speed > highestSpeed) {
highestSpeed = speed;
best = i;
lowestCost = getMaterialCost(itemStack);
bestSilkTouch = silkTouch;
bestFortune = fortune;
} else if (speed == highestSpeed) {
int cost = getMaterialCost(itemStack);
if ((cost < lowestCost && (silkTouch || !bestSilkTouch)) ||
@ -147,6 +151,7 @@ public class ToolSet {
best = i;
lowestCost = cost;
bestSilkTouch = silkTouch;
bestFortune = fortune;
}
}
}