Skip to content

Commit

Permalink
feat: ITEM_STACK and COMPOUND_TAG sync types
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Apr 2, 2024
1 parent f16bc6f commit 16959d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ enum Type {
FLOAT,
DOUBLE,
BOOLEAN,
UUID
UUID,
ITEM_STACK,
COMPOUND_TAG
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.aetherteam.nitrogen.capability.INBTSynchable;
import com.aetherteam.nitrogen.network.BasePacket;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.tuple.Triple;

import java.util.UUID;
Expand Down Expand Up @@ -37,6 +39,8 @@ public void encode(FriendlyByteBuf buf) {
case DOUBLE -> buf.writeDouble((double) this.value);
case BOOLEAN -> buf.writeBoolean((boolean) this.value);
case UUID -> buf.writeUUID((UUID) this.value);
case ITEM_STACK -> buf.writeItem((ItemStack) this.value);
case COMPOUND_TAG -> buf.writeNbt((CompoundTag) this.value);
}
} else {
buf.writeBoolean(false);
Expand All @@ -56,6 +60,8 @@ public static Triple<String, INBTSynchable.Type, Object> decodeValues(FriendlyBy
case DOUBLE -> value = buf.readDouble();
case BOOLEAN -> value = buf.readBoolean();
case UUID -> value = buf.readUUID();
case ITEM_STACK -> value = buf.readItem();
case COMPOUND_TAG -> value = buf.readNbt();
}
}
return Triple.of(key, type, value);
Expand Down

0 comments on commit 16959d7

Please sign in to comment.