Class BookshelfCodecs

java.lang.Object
net.darkhax.bookshelf.api.data.codecs.BookshelfCodecs

public class BookshelfCodecs extends Object
  • Field Details

    • BOOLEAN

      public static final CodecHelper<Boolean> BOOLEAN
    • BYTE

      public static final CodecHelper<Byte> BYTE
    • SHORT

      public static final CodecHelper<Short> SHORT
    • INT

      public static final CodecHelper<Integer> INT
    • FLOAT

      public static final CodecHelper<Float> FLOAT
    • LONG

      public static final CodecHelper<Long> LONG
    • DOUBLE

      public static final CodecHelper<Double> DOUBLE
    • STRING

      public static final CodecHelper<String> STRING
    • UUID

      public static final CodecHelper<UUID> UUID
    • GAME_EVENT

      public static final RegistryCodecHelper<net.minecraft.world.level.gameevent.GameEvent> GAME_EVENT
    • SOUND_EVENT

      public static final RegistryCodecHelper<net.minecraft.sounds.SoundEvent> SOUND_EVENT
    • FLUID

      public static final RegistryCodecHelper<net.minecraft.world.level.material.Fluid> FLUID
    • MOB_EFFECT

      public static final RegistryCodecHelper<net.minecraft.world.effect.MobEffect> MOB_EFFECT
    • BLOCK

      public static final RegistryCodecHelper<net.minecraft.world.level.block.Block> BLOCK
    • ENCHANTMENT

      public static final RegistryCodecHelper<net.minecraft.world.item.enchantment.Enchantment> ENCHANTMENT
    • ENTITY_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.entity.EntityType<?>> ENTITY_TYPE
    • ITEM

      public static final RegistryCodecHelper<net.minecraft.world.item.Item> ITEM
    • POTION

      public static final RegistryCodecHelper<net.minecraft.world.item.alchemy.Potion> POTION
    • PARTICLE_TYPE

      public static final RegistryCodecHelper<net.minecraft.core.particles.ParticleType<?>> PARTICLE_TYPE
    • BLOCK_ENTITY_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.block.entity.BlockEntityType<?>> BLOCK_ENTITY_TYPE
    • PAINTING_VARIANT

      public static final RegistryCodecHelper<net.minecraft.world.entity.decoration.PaintingVariant> PAINTING_VARIANT
    • CUSTOM_STAT

      public static final RegistryCodecHelper<net.minecraft.resources.ResourceLocation> CUSTOM_STAT
    • CHUNK_STATUS

      public static final RegistryCodecHelper<net.minecraft.world.level.chunk.ChunkStatus> CHUNK_STATUS
    • RULE_TEST

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTestType<?>> RULE_TEST
    • RULE_BLOCK_ENTITY_MODIFIER

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.templatesystem.rule.blockentity.RuleBlockEntityModifierType<?>> RULE_BLOCK_ENTITY_MODIFIER
    • POS_RULE_TEST

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestType<?>> POS_RULE_TEST
    • RECIPE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.item.crafting.RecipeType<?>> RECIPE_TYPE
    • RECIPE_SERIALIZER

      public static final RegistryCodecHelper<net.minecraft.world.item.crafting.RecipeSerializer<?>> RECIPE_SERIALIZER
    • ATTRIBUTE

      public static final RegistryCodecHelper<net.minecraft.world.entity.ai.attributes.Attribute> ATTRIBUTE
    • POSITION_SOURCE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.gameevent.PositionSourceType<?>> POSITION_SOURCE_TYPE
    • ARGUMENT_TYPE_INFO_CODEC_HELPER

      public static final RegistryCodecHelper<net.minecraft.commands.synchronization.ArgumentTypeInfo<?,?>> ARGUMENT_TYPE_INFO_CODEC_HELPER
    • STAT_TYPE

      public static final RegistryCodecHelper<net.minecraft.stats.StatType<?>> STAT_TYPE
    • VILLAGER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.entity.npc.VillagerType> VILLAGER_TYPE
    • VILLAGER_PROFESSION

      public static final RegistryCodecHelper<net.minecraft.world.entity.npc.VillagerProfession> VILLAGER_PROFESSION
    • POINT_OF_INTEREST_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.entity.ai.village.poi.PoiType> POINT_OF_INTEREST_TYPE
    • MEMORY_MODULE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.entity.ai.memory.MemoryModuleType<?>> MEMORY_MODULE_TYPE
    • SENSOR_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.entity.ai.sensing.SensorType<?>> SENSOR_TYPE
    • SCHEDULE

      public static final RegistryCodecHelper<net.minecraft.world.entity.schedule.Schedule> SCHEDULE
    • ACTIVITY

      public static final RegistryCodecHelper<net.minecraft.world.entity.schedule.Activity> ACTIVITY
    • LOOT_POOL_ENTRY_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.entries.LootPoolEntryType> LOOT_POOL_ENTRY_TYPE
    • LOOT_FUNCTION_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.functions.LootItemFunctionType> LOOT_FUNCTION_TYPE
    • LOOT_CONDITION_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.predicates.LootItemConditionType> LOOT_CONDITION_TYPE
    • LOOT_NUMBER_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.providers.number.LootNumberProviderType> LOOT_NUMBER_PROVIDER_TYPE
    • LOOT_NBT_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.providers.nbt.LootNbtProviderType> LOOT_NBT_PROVIDER_TYPE
    • LOOT_SCORE_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.storage.loot.providers.score.LootScoreProviderType> LOOT_SCORE_PROVIDER_TYPE
    • FLOAT_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.util.valueproviders.FloatProviderType<?>> FLOAT_PROVIDER_TYPE
    • INT_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.util.valueproviders.IntProviderType<?>> INT_PROVIDER_TYPE
    • HEIGHT_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.heightproviders.HeightProviderType<?>> HEIGHT_PROVIDER_TYPE
    • BLOCK_PREDICATE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.blockpredicates.BlockPredicateType<?>> BLOCK_PREDICATE_TYPE
    • CARVER

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.carver.WorldCarver<?>> CARVER
    • FEATURE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.Feature<?>> FEATURE
    • STRUCTURE_PLACEMENT

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.placement.StructurePlacementType<?>> STRUCTURE_PLACEMENT
    • STRUCTURE_PIECE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType> STRUCTURE_PIECE
    • STRUCTURE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.StructureType<?>> STRUCTURE_TYPE
    • PLACEMENT_MODIFIER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.placement.PlacementModifierType<?>> PLACEMENT_MODIFIER_TYPE
    • BLOCKSTATE_PROVIDER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType<?>> BLOCKSTATE_PROVIDER_TYPE
    • FOLIAGE_PLACER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType<?>> FOLIAGE_PLACER_TYPE
    • TRUNK_PLACER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType<?>> TRUNK_PLACER_TYPE
    • ROOT_PLACER_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.rootplacers.RootPlacerType<?>> ROOT_PLACER_TYPE
    • TREE_DECORATOR_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType<?>> TREE_DECORATOR_TYPE
    • FEATURE_SIZE_TYPE

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.feature.featuresize.FeatureSizeType<?>> FEATURE_SIZE_TYPE
    • STRUCTURE_PROCESSOR

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType<?>> STRUCTURE_PROCESSOR
    • STRUCTURE_POOL_ELEMENT

      public static final RegistryCodecHelper<net.minecraft.world.level.levelgen.structure.pools.StructurePoolElementType<?>> STRUCTURE_POOL_ELEMENT
    • CAT_VARIANT

      public static final RegistryCodecHelper<net.minecraft.world.entity.animal.CatVariant> CAT_VARIANT
    • FROG_VARIANT

      public static final RegistryCodecHelper<net.minecraft.world.entity.animal.FrogVariant> FROG_VARIANT
    • INSTRUMENT

      public static final RegistryCodecHelper<net.minecraft.world.item.Instrument> INSTRUMENT
    • DECORATED_POT_PATTERNS

      public static final RegistryCodecHelper<String> DECORATED_POT_PATTERNS
    • CREATIVE_MODE_TAB

      public static final RegistryCodecHelper<net.minecraft.world.item.CreativeModeTab> CREATIVE_MODE_TAB
    • ITEM_RARITY

      public static final CodecHelper<net.minecraft.world.item.Rarity> ITEM_RARITY
    • ENCHANTMENT_RARITY

      public static final CodecHelper<net.minecraft.world.item.enchantment.Enchantment.Rarity> ENCHANTMENT_RARITY
    • ATTRIBUTE_OPERATION

      public static final CodecHelper<net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation> ATTRIBUTE_OPERATION
    • DIRECTION

      public static final CodecHelper<net.minecraft.core.Direction> DIRECTION
    • AXIS

      public static final CodecHelper<net.minecraft.core.Direction.Axis> AXIS
    • PLANE

      public static final CodecHelper<net.minecraft.core.Direction.Plane> PLANE
    • MOB_CATEGORY

      public static final CodecHelper<net.minecraft.world.entity.MobCategory> MOB_CATEGORY
    • ENCHANTMENT_CATEGORY

      public static final CodecHelper<net.minecraft.world.item.enchantment.EnchantmentCategory> ENCHANTMENT_CATEGORY
    • DYE_COLOR

      public static final CodecHelper<net.minecraft.world.item.DyeColor> DYE_COLOR
    • SOUND_SOURCE

      public static final CodecHelper<net.minecraft.sounds.SoundSource> SOUND_SOURCE
    • ARMOR_MATERIAL

      public static final CodecHelper<net.minecraft.world.item.ArmorMaterials> ARMOR_MATERIAL
    • DIFFICULTY

      public static final CodecHelper<net.minecraft.world.Difficulty> DIFFICULTY
    • EQUIPMENT_SLOT

      public static final CodecHelper<net.minecraft.world.entity.EquipmentSlot> EQUIPMENT_SLOT
    • MIRROR

      public static final CodecHelper<net.minecraft.world.level.block.Mirror> MIRROR
    • ROTATION

      public static final CodecHelper<net.minecraft.world.level.block.Rotation> ROTATION
    • RESOURCE_LOCATION

      public static final CodecHelper<net.minecraft.resources.ResourceLocation> RESOURCE_LOCATION
    • COMPOUND_TAG

      public static final CodecHelper<net.minecraft.nbt.CompoundTag> COMPOUND_TAG
    • ITEM_STACK

      public static final CodecHelper<net.minecraft.world.item.ItemStack> ITEM_STACK
    • ITEM_STACK_FLEXIBLE

      public static final CodecHelper<net.minecraft.world.item.ItemStack> ITEM_STACK_FLEXIBLE
    • TEXT

      public static final CodecHelper<net.minecraft.network.chat.Component> TEXT
    • BLOCK_POS

      public static final CodecHelper<net.minecraft.core.BlockPos> BLOCK_POS
    • INGREDIENT

      public static final CodecHelper<net.minecraft.world.item.crafting.Ingredient> INGREDIENT
    • INGREDIENT_NONEMPTY

      public static final CodecHelper<net.minecraft.world.item.crafting.Ingredient> INGREDIENT_NONEMPTY
    • BLOCK_STATE_MAP_CODEC

      public static final com.mojang.serialization.MapCodec<net.minecraft.world.level.block.state.BlockState> BLOCK_STATE_MAP_CODEC
    • BLOCK_STATE

      public static final CodecHelper<net.minecraft.world.level.block.state.BlockState> BLOCK_STATE
    • ATTRIBUTE_MODIFIER

      public static final CodecHelper<net.minecraft.world.entity.ai.attributes.AttributeModifier> ATTRIBUTE_MODIFIER
    • EFFECT_INSTANCE

      public static final CodecHelper<net.minecraft.world.effect.MobEffectInstance> EFFECT_INSTANCE
    • EFFECT_INSTANCE_WITH_HIDDEN

      public static final CodecHelper<net.minecraft.world.effect.MobEffectInstance> EFFECT_INSTANCE_WITH_HIDDEN
    • ENCHANTMENT_INSTANCE

      public static final CodecHelper<net.minecraft.world.item.enchantment.EnchantmentInstance> ENCHANTMENT_INSTANCE
    • VECTOR_3F

      public static CodecHelper<org.joml.Vector3f> VECTOR_3F
    • LOAD_CONDITION

      public static CodecHelper<ILoadCondition> LOAD_CONDITION
    • SOUND

      public static CodecHelper<Sound> SOUND
  • Constructor Details

    • BookshelfCodecs

      public BookshelfCodecs()
  • Method Details

    • registry

      public static <T> com.mojang.serialization.Codec<T> registry(net.minecraft.core.Registry<T> registry)
      Creates a codec for a registry that will error when no value can be found rather than passing a default value like air.
      Type Parameters:
      T - The registry type.
      Parameters:
      registry - The registry to read values from.
      Returns:
      A Codec for finding registry values by name.
    • flexibleList

      public static <T> com.mojang.serialization.Codec<List<T>> flexibleList(com.mojang.serialization.Codec<T> codec)
      Creates a Codec that can flexibly read individual values as a list in addition to traditional lists.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The codec for reading an individual value.
      Returns:
      A Codec that can flexibly read individual values as a list in addition to traditional lists.
    • flexibleSet

      public static <T> com.mojang.serialization.Codec<Set<T>> flexibleSet(com.mojang.serialization.Codec<T> codec)
      Creates a Codec that can flexibly read both individual values and arrays of values as a set.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The Codec for reading an individual value.
      Returns:
      A Codec that can flexibly read both individual values and arrays of values as a set.
    • flexibleArray

      public static <T> com.mojang.serialization.Codec<T[]> flexibleArray(com.mojang.serialization.Codec<T> codec, IntFunction<T[]> arrayBuilder)
      Creates a Codec that can flexibly read both individual values and arrays of values as an array.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The Codec for reading an individual value.
      arrayBuilder - A function that creates new arrays of the required type. The function is given the size of the list.
      Returns:
      A Codec that can flexibly read both individual values and arrays of values as an array.
    • fallback

      public static <T> com.mojang.serialization.MapCodec<T> fallback(com.mojang.serialization.Codec<T> codec, String name, Supplier<T> fallbackSupplier)
      Creates a Codec that will use a fallback value if no other value is specified. This is different from Codec.optionalFieldOf(String, Object) in that the fallback value is provided by a supplier.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The base Codec to use.
      name - The name of the field to read from.
      fallbackSupplier - A supplier that produces the default value. You should probably memoize this.
      Returns:
      A Codec that will use a fallback value if the field is not specified.
    • optional

      public static <T> com.mojang.serialization.MapCodec<Optional<T>> optional(com.mojang.serialization.Codec<T> codec, String name, Optional<T> fallback, boolean writesDefault)
      Creates a Codec that handles optional values. This is different from Codec.optionalFieldOf(String, Object) in that it keeps the type as an Optional.
      Type Parameters:
      T - The type of the optional value handled by the coded.
      Parameters:
      codec - The base Codec to use.
      name - The name of the field to read from.
      fallback - The fallback optional value.
      writesDefault - Should the default value be written or left blank?
      Returns:
      A Codec that handles optional values.
    • nullable

      public static <T> com.mojang.serialization.MapCodec<T> nullable(com.mojang.serialization.Codec<T> codec, String fieldName)
      Creates a Codec that can handle nullable values.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The base Codec to use.
      fieldName - The name of the field to read from.
      Returns:
      A Codec that handles nullable values.
    • fallback

      public static <T> com.mojang.serialization.MapCodec<T> fallback(com.mojang.serialization.Codec<T> codec, String name, Supplier<T> fallbackSupplier, boolean writesDefault)
      Creates a Codec that will use a fallback value if no other value is specified. This is different from Codec.optionalFieldOf(String, Object) in that the fallback value is provided by a supplier. It also allows you to control if the default value should be written when or left blank.
      Type Parameters:
      T - The type of value handled by the codec.
      Parameters:
      codec - The base Codec to use.
      name - The name of the field to read from.
      fallbackSupplier - A supplier that produces the default value. You should probably memoize this.
      writesDefault - Should the default value be written or left blank?
      Returns:
      A Codec that will use a fallback value if the field is not specified.
    • enumerable

      public static <T extends Enum<T>> com.mojang.serialization.Codec<T> enumerable(Class<T> enumClass)
      Creates a Codec that handles enum values by using their enum constant names.
      If the codec can not read an enum value from the provided name it will try again using an all uppercase version of the input. This allows users to write values in all lowercase which may feel more natural for some users and adds extra flexibility.
      If the codec can not read any enum value from the provided name it will create an error. The error message will try to help the user by recommending a nearby match and including all possible values.
      Type Parameters:
      T - The type of the enum.
      Parameters:
      enumClass - The class of the enum to get values for.
      Returns:
      A codec that can read and write enum values using their enum constant name.
    • dispatchFallback

      public static <T, V> com.mojang.serialization.Codec<V> dispatchFallback(com.mojang.serialization.Codec<T> typeCodec, Function<V,T> getSerializer, Function<T,com.mojang.serialization.Codec<V>> getCodec, Supplier<com.mojang.serialization.Codec<V>> fallbackCodec)
      Creates a dispatch codec that will deserialize a value based on the serializer type defined by an optional property. If the type property is not provided the fallbackCodec will be used instead. This is similar to the recipe codec that can read crafting, smelting, stone cutting, and smithing table recipes.
      Type Parameters:
      T - The type of the type serializer.
      V - The type of value that is ultimately serialized using this dispatch codec.
      Parameters:
      typeCodec - A codec that can read the serializer type. Typically, this is a Codec that uses a map to go from ResourceLocation to the serializer type and back.
      getSerializer - A function that gets the serializer type from a value. This is used to allow the Codec to encode the type ID when writing the value.
      getCodec - A function that gets the codec responsible for a type. This is used to decode the resulting value.
      fallbackCodec - A fallback codec that is used when the type property is not specified.
      Returns:
      A dispatch codec that has a fallback for when the type is not specified.
    • alternatives

      public static <T> com.mojang.serialization.Codec<T> alternatives(com.mojang.serialization.Codec<T> first, com.mojang.serialization.Codec<T> second, Function<T,com.mojang.datafixers.util.Either<T,T>> encodeLogic)