cache on block not blockstate

This commit is contained in:
Leijurv 2018-09-04 10:06:48 -07:00
parent c367297136
commit 3fd1063e3c
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -72,10 +72,10 @@ public class ToolSet implements Helper {
private Map<Block, Byte> slotCache = new HashMap<>(); private Map<Block, Byte> slotCache = new HashMap<>();
/** /**
* A cache mapping a {@link IBlockState} to how long it will take to break * A cache mapping a {@link Block} to how long it will take to break
* with this toolset, given the optimum tool is used. * with this toolset, given the optimum tool is used.
*/ */
private Map<IBlockState, Double> breakStrengthCache = new HashMap<>(); private Map<Block, Double> breakStrengthCache = new HashMap<>();
/** /**
* Create a toolset from the current player's inventory (but don't calculate any hardness values just yet) * Create a toolset from the current player's inventory (but don't calculate any hardness values just yet)
@ -146,7 +146,7 @@ public class ToolSet implements Helper {
* @return how long it would take in ticks * @return how long it would take in ticks
*/ */
public double getStrVsBlock(IBlockState state, BlockPos pos) { public double getStrVsBlock(IBlockState state, BlockPos pos) {
return this.breakStrengthCache.computeIfAbsent(state, s -> calculateStrVsBlock(s, pos)); return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(state, pos));
} }
/** /**