mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Cache BlockImpl hashcode
This commit is contained in:
parent
bfdc5a53ca
commit
2339fe1c07
@ -69,6 +69,8 @@ final class BlockImpl implements Block {
|
||||
private final NBTCompound nbt;
|
||||
private final BlockHandler handler;
|
||||
|
||||
private int hashCode; // Cache
|
||||
|
||||
BlockImpl(@NotNull Registry.BlockEntry registry,
|
||||
@NotNull Map<Map<String, String>, Block> propertyEntry,
|
||||
@NotNull Map<String, String> properties,
|
||||
@ -151,7 +153,12 @@ final class BlockImpl implements Block {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(stateId(), nbt, handler);
|
||||
int result = hashCode;
|
||||
if (result == 0) {
|
||||
result = Objects.hash(stateId(), nbt, handler);
|
||||
this.hashCode = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user