mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-19 15:09:25 +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 net.momirealms.customcrops.api.core.block.CustomCropsBlock;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CustomCropsBlockStateImpl implements CustomCropsBlockState {
|
public class CustomCropsBlockStateImpl implements CustomCropsBlockState {
|
||||||
|
|
||||||
private final SynchronizedCompoundMap compoundMap;
|
private final SynchronizedCompoundMap compoundMap;
|
||||||
@@ -66,4 +68,21 @@ public class CustomCropsBlockStateImpl implements CustomCropsBlockState {
|
|||||||
"}, " + compoundMap +
|
"}, " + 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,7 +412,8 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor<World> {
|
|||||||
for (int j = 0; j < blockAmount; j++){
|
for (int j = 0; j < blockAmount; j++){
|
||||||
byte[] blockData = new byte[sectionData.readInt()];
|
byte[] blockData = new byte[sectionData.readInt()];
|
||||||
sectionData.read(blockData);
|
sectionData.read(blockData);
|
||||||
CompoundMap block = readCompound(blockData).getValue();
|
CompoundTag tag = readCompound(blockData);
|
||||||
|
CompoundMap block = tag.getValue();
|
||||||
Key key = keyFunction.apply((String) block.get("type").getValue());
|
Key key = keyFunction.apply((String) block.get("type").getValue());
|
||||||
CompoundMap data = (CompoundMap) block.get("data").getValue();
|
CompoundMap data = (CompoundMap) block.get("data").getValue();
|
||||||
CustomCropsBlock customBlock = InternalRegistries.BLOCK.get(key);
|
CustomCropsBlock customBlock = InternalRegistries.BLOCK.get(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user