Optional itemstack stream codecs, for some reason

This commit is contained in:
DBotThePony 2024-08-27 23:46:38 +07:00
parent dc3484d69a
commit 8abd17b670
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 5 additions and 5 deletions

View File

@ -212,7 +212,7 @@ fun FriendlyByteBuf.writeItemType(value: Item) {
}
fun RegistryFriendlyByteBuf.writeItem(value: ItemStack) {
ItemStack.STREAM_CODEC.encode(this, value)
ItemStack.OPTIONAL_STREAM_CODEC.encode(this, value)
}
fun RegistryFriendlyByteBuf.writeComponent(value: Component) {
@ -228,7 +228,7 @@ fun FriendlyByteBuf.readItemType(): Item {
}
fun RegistryFriendlyByteBuf.readItem(): ItemStack {
return ItemStack.STREAM_CODEC.decode(this)
return ItemStack.OPTIONAL_STREAM_CODEC.decode(this)
}
fun RegistryFriendlyByteBuf.readComponent(): Component {

View File

@ -626,15 +626,15 @@ class DelegateSyncher : Observer {
}
fun item(value: ItemStack = ItemStack.EMPTY, setter: DelegateSetter<ItemStack> = DelegateSetter.passthrough(), getter: DelegateGetter<ItemStack> = DelegateGetter.passthrough()): DelegateSyncher.Slot<ItemStack> {
return add(ListenableDelegate.maskSmart(value, getter, setter), ItemStack.STREAM_CODEC.wrap())
return add(ListenableDelegate.maskSmart(value, getter, setter), ItemStack.OPTIONAL_STREAM_CODEC.wrap())
}
fun computedItem(delegate: Supplier<ItemStack>): DelegateSyncher.Slot<ItemStack> {
return computed(delegate, ItemStack.STREAM_CODEC.wrap())
return computed(delegate, ItemStack.OPTIONAL_STREAM_CODEC.wrap())
}
fun observedItem(value: ItemStack = ItemStack.EMPTY, setter: DelegateSetter<ItemStack> = DelegateSetter.passthrough(), getter: DelegateGetter<ItemStack> = DelegateGetter.passthrough()): DelegateSyncher.ObservedSlot<ItemStack> {
return add(Delegate.maskSmart(value, getter, setter), ItemStack.STREAM_CODEC.wrap())
return add(Delegate.maskSmart(value, getter, setter), ItemStack.OPTIONAL_STREAM_CODEC.wrap())
}
/**