9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-28 03:19:15 +00:00

Fix hashcode

This commit is contained in:
XiaoMoMi
2024-09-07 01:05:13 +08:00
parent 3a8fb364fe
commit 262209eda8
2 changed files with 21 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import net.momirealms.customcrops.api.core.SynchronizedCompoundMap;
import net.momirealms.customcrops.api.core.block.CustomCropsBlock;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class CustomCropsBlockStateImpl implements CustomCropsBlockState {
private final SynchronizedCompoundMap compoundMap;
@@ -66,4 +68,21 @@ public class CustomCropsBlockStateImpl implements CustomCropsBlockState {
"}, " + compoundMap +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomCropsBlockStateImpl that = (CustomCropsBlockStateImpl) o;
return Objects.equals(compoundMap, that.compoundMap);
}
@Override
public int hashCode() {
Tag<?> id = compoundMap.get("id");
if (id != null) {
return 7 * id.hashCode() + 13 * owner.type().hashCode();
}
return owner.type().hashCode();
}
}