diff --git a/src/main/java/com/klikli_dev/occultism/api/common/data/MachineReference.java b/src/main/java/com/klikli_dev/occultism/api/common/data/MachineReference.java index 7ec2467e0..0983fa8e5 100644 --- a/src/main/java/com/klikli_dev/occultism/api/common/data/MachineReference.java +++ b/src/main/java/com/klikli_dev/occultism/api/common/data/MachineReference.java @@ -42,6 +42,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.neoforged.neoforge.common.util.INBTSerializable; +import java.util.Objects; import java.util.Optional; public class MachineReference implements INBTSerializable { @@ -210,4 +211,39 @@ public BlockEntity getInsertBlockEntity(Level level) { public boolean isValidFor(Level level) { return this.getExtractBlockEntity(level) != null && this.getInsertBlockEntity(level) != null; } + + @Override + public boolean equals(Object obj) { + if(obj == this) + return true; + + if (obj instanceof MachineReference) { + MachineReference other = (MachineReference) obj; + return this.extractGlobalPos.equals(other.extractGlobalPos) && + this.extractRegistryName.equals(other.extractRegistryName) && + this.extractChunkLoaded == other.extractChunkLoaded && + this.extractFacing == other.extractFacing && + this.insertGlobalPos.equals(other.insertGlobalPos) && + this.insertRegistryName.equals(other.insertRegistryName) && + this.insertChunkLoaded == other.insertChunkLoaded && + this.insertFacing == other.insertFacing && + this.customName.equals(other.customName); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash( + this.extractGlobalPos, + this.extractRegistryName, + this.extractChunkLoaded, + this.extractFacing, + this.insertGlobalPos, + this.insertRegistryName, + this.insertChunkLoaded, + this.insertFacing, + this.customName + ); + } }