mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -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>(
|
abstract class BlockProperty<T>(
|
||||||
val name: String,
|
val name: String,
|
||||||
) : Iterable<T> {
|
) : Iterable<T> {
|
||||||
|
private val hashCode = name.hashCode()
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return name
|
return name
|
||||||
@ -25,11 +26,12 @@ abstract class BlockProperty<T>(
|
|||||||
abstract fun parse(value: Any): T
|
abstract fun parse(value: Any): T
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return name.hashCode()
|
return hashCode
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other !is BlockProperty<*>) return false
|
if (other !is BlockProperty<*>) return false
|
||||||
|
if (hashCode != other.hashCode) return false
|
||||||
return other.name == name
|
return other.name == name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user