mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
block property: cache hashCode
That makes checking if a block is waterlogged WAY faster
This commit is contained in:
parent
4619101de2
commit
36d43bc8fb
@ -17,6 +17,7 @@ package de.bixilon.minosoft.data.registries.blocks.properties
|
||||
abstract class BlockProperty<T>(
|
||||
val name: String,
|
||||
) : Iterable<T> {
|
||||
private val hashCode = name.hashCode()
|
||||
|
||||
override fun toString(): String {
|
||||
return name
|
||||
@ -25,11 +26,12 @@ abstract class BlockProperty<T>(
|
||||
abstract fun parse(value: Any): T
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
return hashCode
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is BlockProperty<*>) return false
|
||||
if (hashCode != other.hashCode) return false
|
||||
return other.name == name
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user