Class FingerprintCodec<T>

java.lang.Object
net.darkhax.bookshelf.common.impl.data.loot.modifiers.FingerprintCodec<T>
Type Parameters:
T - The type for the codec to serialize.
All Implemented Interfaces:
com.mojang.serialization.Codec<T>, com.mojang.serialization.Decoder<T>, com.mojang.serialization.Encoder<T>

public class FingerprintCodec<T> extends Object implements com.mojang.serialization.Codec<T>
A codec wrapper that adds functionality to compute and set a fingerprint hash for certain objects during decoding. This is achieved by hashing the JSON representation of the input.

This implementation is only intended for the LootPool codec. Loot pools do not have their own identity, so we use this hash to keep track of their position within a LootTable and to detect if a user has overwritten the input.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.mojang.serialization.Codec

    com.mojang.serialization.Codec.RecursiveCodec<T>, com.mojang.serialization.Codec.ResultFunction<A>

    Nested classes/interfaces inherited from interface com.mojang.serialization.Decoder

    com.mojang.serialization.Decoder.Boxed<A>, com.mojang.serialization.Decoder.Simple<A>, com.mojang.serialization.Decoder.Terminal<A>
  • Field Summary

    Fields inherited from interface com.mojang.serialization.Codec

    BOOL, BYTE, BYTE_BUFFER, DOUBLE, EMPTY, FLOAT, INT, INT_STREAM, LONG, LONG_STREAM, PASSTHROUGH, SHORT, STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
    FingerprintCodec(com.mojang.serialization.Codec<T> delegate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T1> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<T,T1>>
    decode(com.mojang.serialization.DynamicOps<T1> ops, T1 input)
     
    <T1> com.mojang.serialization.DataResult<T1>
    encode(T input, com.mojang.serialization.DynamicOps<T1> ops, T1 prefix)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.mojang.serialization.Codec

    comapFlatMap, deprecated, dispatch, dispatch, dispatchMap, dispatchMap, dispatchStable, fieldOf, flatComapMap, flatXmap, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, lenientOptionalFieldOf, listOf, listOf, mapResult, optionalFieldOf, optionalFieldOf, optionalFieldOf, optionalFieldOf, orElse, orElse, orElse, orElseGet, orElseGet, orElseGet, partialDispatch, promotePartial, sizeLimitedListOf, stable, validate, withLifecycle, xmap

    Methods inherited from interface com.mojang.serialization.Decoder

    boxed, decode, flatMap, map, parse, parse, simple, terminal

    Methods inherited from interface com.mojang.serialization.Encoder

    comap, encodeStart, flatComap
  • Constructor Details

    • FingerprintCodec

      public FingerprintCodec(com.mojang.serialization.Codec<T> delegate)
  • Method Details

    • decode

      public <T1> com.mojang.serialization.DataResult<com.mojang.datafixers.util.Pair<T,T1>> decode(com.mojang.serialization.DynamicOps<T1> ops, T1 input)
      Specified by:
      decode in interface com.mojang.serialization.Decoder<T>
    • encode

      public <T1> com.mojang.serialization.DataResult<T1> encode(T input, com.mojang.serialization.DynamicOps<T1> ops, T1 prefix)
      Specified by:
      encode in interface com.mojang.serialization.Encoder<T>