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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user