Skip to content

Commit 1131bb2

Browse files
committed
fix: machine references do not work as item components
Due to not implementing equals and hashCode Closes #1254
1 parent ef1f881 commit 1131bb2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/main/java/com/klikli_dev/occultism/api/common/data/MachineReference.java

+36
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import net.minecraft.world.level.block.state.BlockState;
4343
import net.neoforged.neoforge.common.util.INBTSerializable;
4444

45+
import java.util.Objects;
4546
import java.util.Optional;
4647

4748
public class MachineReference implements INBTSerializable<CompoundTag> {
@@ -210,4 +211,39 @@ public BlockEntity getInsertBlockEntity(Level level) {
210211
public boolean isValidFor(Level level) {
211212
return this.getExtractBlockEntity(level) != null && this.getInsertBlockEntity(level) != null;
212213
}
214+
215+
@Override
216+
public boolean equals(Object obj) {
217+
if(obj == this)
218+
return true;
219+
220+
if (obj instanceof MachineReference) {
221+
MachineReference other = (MachineReference) obj;
222+
return this.extractGlobalPos.equals(other.extractGlobalPos) &&
223+
this.extractRegistryName.equals(other.extractRegistryName) &&
224+
this.extractChunkLoaded == other.extractChunkLoaded &&
225+
this.extractFacing == other.extractFacing &&
226+
this.insertGlobalPos.equals(other.insertGlobalPos) &&
227+
this.insertRegistryName.equals(other.insertRegistryName) &&
228+
this.insertChunkLoaded == other.insertChunkLoaded &&
229+
this.insertFacing == other.insertFacing &&
230+
this.customName.equals(other.customName);
231+
}
232+
return false;
233+
}
234+
235+
@Override
236+
public int hashCode() {
237+
return Objects.hash(
238+
this.extractGlobalPos,
239+
this.extractRegistryName,
240+
this.extractChunkLoaded,
241+
this.extractFacing,
242+
this.insertGlobalPos,
243+
this.insertRegistryName,
244+
this.insertChunkLoaded,
245+
this.insertFacing,
246+
this.customName
247+
);
248+
}
213249
}

0 commit comments

Comments
 (0)