Fix improper treatment of unbreakable blocks

This commit is contained in:
Brady 2018-09-07 19:00:36 -05:00
parent dcad5fb79e
commit 99323463e3
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 8 additions and 5 deletions

View File

@ -259,7 +259,11 @@ public interface MovementHelper extends ActionCosts, Helper {
return COST_INF;
}
double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table
double result = m / context.getToolSet().getStrVsBlock(state);
double strVsBlock = context.getToolSet().getStrVsBlock(state);
if (strVsBlock < 0)
return COST_INF;
double result = m / strVsBlock;
if (includeFalling) {
BlockPos up = position.up();
IBlockState above = BlockStateInterface.get(up);

View File

@ -77,7 +77,7 @@ public class ToolSet implements Helper {
/**
* Calculates how long would it take to mine the specified block given the best tool
* in this toolset is used.
* in this toolset is used. A negative value is returned if the specified block is unbreakable.
*
* @param state the blockstate to be mined
* @return how long it would take in ticks
@ -87,9 +87,8 @@ public class ToolSet implements Helper {
ItemStack contents = player().inventory.getStackInSlot(slot);
float blockHard = state.getBlockHardness(null, null);
if (blockHard < 0) {
return 0;
}
if (blockHard < 0)
return -1;
float speed = contents.getDestroySpeed(state);
if (speed > 1) {