Skip to content

Commit

Permalink
fix: stream codec for machine references
Browse files Browse the repository at this point in the history
(Hopefully) Closes #1254
  • Loading branch information
klikli-dev committed Dec 22, 2024
1 parent 9b58196 commit 0a4ae7e
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ public class MachineReference implements INBTSerializable<CompoundTag> {
).apply(instance, MachineReference::new));

public static final StreamCodec<RegistryFriendlyByteBuf, MachineReference> STREAM_CODEC = OccultismExtraStreamCodecs.composite(
GlobalBlockPos.STREAM_CODEC,
(m) -> m.extractGlobalPos,
ResourceLocation.STREAM_CODEC,
(m) -> m.extractRegistryName,
ByteBufCodecs.optional(GlobalBlockPos.STREAM_CODEC),
(m) -> Optional.ofNullable(m.extractGlobalPos),
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC),
(m) -> Optional.ofNullable(m.extractRegistryName),
ByteBufCodecs.BOOL,
(m) -> m.extractChunkLoaded,
Direction.STREAM_CODEC,
(m) -> m.extractFacing,
GlobalBlockPos.STREAM_CODEC,
(m) -> m.insertGlobalPos,
ResourceLocation.STREAM_CODEC,
(m) -> m.insertRegistryName,
ByteBufCodecs.optional(GlobalBlockPos.STREAM_CODEC),
(m) -> Optional.ofNullable(m.insertGlobalPos),
ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC),
(m) -> Optional.ofNullable(m.insertRegistryName),
ByteBufCodecs.BOOL,
(m) -> m.insertChunkLoaded,
Direction.STREAM_CODEC,
Expand Down Expand Up @@ -214,11 +214,10 @@ public boolean isValidFor(Level level) {

@Override
public boolean equals(Object obj) {
if(obj == this)
if (obj == this)
return true;

if (obj instanceof MachineReference) {
MachineReference other = (MachineReference) obj;
if (obj instanceof MachineReference other) {
return this.extractGlobalPos.equals(other.extractGlobalPos) &&
this.extractRegistryName.equals(other.extractRegistryName) &&
this.extractChunkLoaded == other.extractChunkLoaded &&
Expand Down

0 comments on commit 0a4ae7e

Please sign in to comment.