Package org.geysermc.geyser.item.hashing
Interface MapBuilder<Type>
- Type Parameters:
Type- the type to encode.
- All Superinterfaces:
Function<MapHasher<Type>,,MapHasher<Type>> UnaryOperator<MapHasher<Type>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <Casted> MapBuilder<Casted>cast()Casts this map builder to aMapBuilder.static <Type,Dispatched>
MapBuilder<Dispatched>dispatch(String typeKey, MinecraftHasher<Type> typeHasher, Function<Dispatched, Type> typeExtractor, Function<Type, MapBuilder<Dispatched>> mapDispatch) Creates a map builder that dispatches aMapBuilderfrom aMapBuilderusingtypeExtractor, puts this as thetypeKeykey in the map using the giventypeHasher, and uses aMapBuilderprovided bymapDispatchto build the rest of the map.static <Type,Dispatched>
MapBuilder<Dispatched>dispatch(MinecraftHasher<Type> typeHasher, Function<Dispatched, Type> typeExtractor, Function<Type, MapBuilder<Dispatched>> hashDispatch) static <Type> Function<org.cloudburstmc.nbt.NbtMap,MapBuilder<Type>> Returns a function that creates a map builder from an NBT map.static <Type> MapBuilder<Type>unit()Returns a map builder that doesn't contain anything.
-
Method Details
-
cast
Casts this map builder to aMapBuilder. This cast is done unsafely, only use this if you are sure the object being encoded is of the type being cast to!- Type Parameters:
Casted- the type to cast to.
-
unit
Returns a map builder that doesn't contain anything.- Type Parameters:
Type- the type to encode.
-
dispatch
static <Type,Dispatched> MapBuilder<Dispatched> dispatch(MinecraftHasher<Type> typeHasher, Function<Dispatched, Type> typeExtractor, Function<Type, MapBuilder<Dispatched>> hashDispatch) -
dispatch
static <Type,Dispatched> MapBuilder<Dispatched> dispatch(String typeKey, MinecraftHasher<Type> typeHasher, Function<Dispatched, Type> typeExtractor, Function<Type, MapBuilder<Dispatched>> mapDispatch) Creates a map builder that dispatches aMapBuilderfrom aMapBuilderusingtypeExtractor, puts this as thetypeKeykey in the map using the giventypeHasher, and uses aMapBuilderprovided bymapDispatchto build the rest of the map.This can be used to create map builders that build an abstract type or interface into a map with different keys depending on the type.
- Type Parameters:
Type- the type of thetypeKey.Dispatched- the type of the new map builder.- Parameters:
typeKey- the key to store theMapBuilderin.typeHasher- the hasher used to encode theMapBuilder.typeExtractor- the function that extracts aMapBuilderfrom aMapBuilder.mapDispatch- the function that provides aMapBuilderbased on aMapBuilder.
-
inlineNbtMap
Returns a function that creates a map builder from an NBT map. The builder simply adds all keys from the NBT map.Can be used with
MapHasher.accept(Function, Function)to inline an NBT map into a map builder, together with other keys.- Type Parameters:
Type- the type to encode.
-