fix: implement IDSet (registryEntryHolderSet) decoder/encoder
- Replace old broken RegistryEntryHolderSetDecoder with correct varint discriminator: id != 0 returns raw ID, id == 0 decodes string base - Add RegistryEntryHolderSetEncoder using type switch (string/int32) - Add NonErroringIndex to proto_base (zero-fallback index lookup) - DeclareRecipes now fails with index not found (mapper) instead of to do
This commit is contained in:
@@ -262,6 +262,12 @@ func ErroringIndex[K comparable, V any, M map[K]V](m M, i K) (v V, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// NonErroringIndex looks up key k in map m and returns the zero value without error if not found.
|
||||
func NonErroringIndex[K comparable, V any, M map[K]V](m M, i K) (v V, err error) {
|
||||
v, _ = m[i]
|
||||
return
|
||||
}
|
||||
|
||||
// EncodeDecodeAble is implemented by types that can be encoded and decoded for
|
||||
// Minecraft protocol packets.
|
||||
type EncodeDecodeAble interface {
|
||||
|
||||
Reference in New Issue
Block a user