Class NbtOps

java.lang.Object
net.minecraft.nbt.NbtOps
All Implemented Interfaces:
com.mojang.serialization.DynamicOps<NbtElement>

public class NbtOps extends Object implements com.mojang.serialization.DynamicOps<NbtElement>
Used to handle Minecraft NBTs within dynamics for DataFixerUpper, allowing generalized serialization logic shared across different type of data structures. Use INSTANCE for the ops singleton.

For instance, dimension data may be stored as JSON in data packs, but they will be transported in packets as NBT. DataFixerUpper allows generalizing the dimension serialization logic to prevent duplicate code, where the NBT ops allow the DataFixerUpper dimension serialization logic to interact with Minecraft NBTs.

See Also:
Mappings:
Namespace Name
named net/minecraft/nbt/NbtOps
intermediary net/minecraft/class_2509
official vl
  • Field Details

    • INSTANCE

      public static final NbtOps INSTANCE
      An singleton of the NBT dynamic ops.

      This ops does not compress maps (replace field name to value pairs with an ordered list of values in serialization). In fact, since Minecraft NBT lists can only contain elements of the same type, this op cannot compress maps.

      Mappings:
      Namespace Name Mixin selector
      named INSTANCE Lnet/minecraft/nbt/NbtOps;INSTANCE:Lnet/minecraft/nbt/NbtOps;
      intermediary field_11560 Lnet/minecraft/class_2509;field_11560:Lnet/minecraft/class_2509;
      official a Lvl;a:Lvl;
    • MARKER_KEY

      private static final String MARKER_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named MARKER_KEY Lnet/minecraft/nbt/NbtOps;MARKER_KEY:Ljava/lang/String;
      intermediary field_40667 Lnet/minecraft/class_2509;field_40667:Ljava/lang/String;
      official b Lvl;b:Ljava/lang/String;
  • Constructor Details

    • NbtOps

      protected NbtOps()
  • Method Details

    • empty

      public NbtElement empty()
      Specified by:
      empty in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named empty Lnet/minecraft/nbt/NbtOps;empty()Lnet/minecraft/nbt/NbtElement;
      intermediary method_10668 Lnet/minecraft/class_2509;method_10668()Lnet/minecraft/class_2520;
      official a Lvl;a()Lvu;
    • convertTo

      public <U> U convertTo(com.mojang.serialization.DynamicOps<U> dynamicOps, NbtElement nbtElement)
      Specified by:
      convertTo in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named convertTo Lnet/minecraft/nbt/NbtOps;convertTo(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/nbt/NbtElement;)Ljava/lang/Object;
      intermediary method_29146 Lnet/minecraft/class_2509;method_29146(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/class_2520;)Ljava/lang/Object;
      official a Lvl;a(Lcom/mojang/serialization/DynamicOps;Lvu;)Ljava/lang/Object;
    • getNumberValue

      public com.mojang.serialization.DataResult<Number> getNumberValue(NbtElement nbtElement)
      Specified by:
      getNumberValue in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getNumberValue Lnet/minecraft/nbt/NbtOps;getNumberValue(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10645 Lnet/minecraft/class_2509;method_10645(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;)Lcom/mojang/serialization/DataResult;
    • createNumeric

      public NbtElement createNumeric(Number number)
      Specified by:
      createNumeric in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createNumeric Lnet/minecraft/nbt/NbtOps;createNumeric(Ljava/lang/Number;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10660 Lnet/minecraft/class_2509;method_10660(Ljava/lang/Number;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/lang/Number;)Lvu;
    • createByte

      public NbtElement createByte(byte byte2)
      Specified by:
      createByte in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createByte Lnet/minecraft/nbt/NbtOps;createByte(B)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10640 Lnet/minecraft/class_2509;method_10640(B)Lnet/minecraft/class_2520;
      official a Lvl;a(B)Lvu;
    • createShort

      public NbtElement createShort(short short2)
      Specified by:
      createShort in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createShort Lnet/minecraft/nbt/NbtOps;createShort(S)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10635 Lnet/minecraft/class_2509;method_10635(S)Lnet/minecraft/class_2520;
      official a Lvl;a(S)Lvu;
    • createInt

      public NbtElement createInt(int int2)
      Specified by:
      createInt in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createInt Lnet/minecraft/nbt/NbtOps;createInt(I)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10661 Lnet/minecraft/class_2509;method_10661(I)Lnet/minecraft/class_2520;
      official a Lvl;a(I)Lvu;
    • createLong

      public NbtElement createLong(long long2)
      Specified by:
      createLong in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createLong Lnet/minecraft/nbt/NbtOps;createLong(J)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10654 Lnet/minecraft/class_2509;method_10654(J)Lnet/minecraft/class_2520;
      official a Lvl;a(J)Lvu;
    • createFloat

      public NbtElement createFloat(float float2)
      Specified by:
      createFloat in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createFloat Lnet/minecraft/nbt/NbtOps;createFloat(F)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10662 Lnet/minecraft/class_2509;method_10662(F)Lnet/minecraft/class_2520;
      official a Lvl;a(F)Lvu;
    • createDouble

      public NbtElement createDouble(double double2)
      Specified by:
      createDouble in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createDouble Lnet/minecraft/nbt/NbtOps;createDouble(D)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10652 Lnet/minecraft/class_2509;method_10652(D)Lnet/minecraft/class_2520;
      official a Lvl;a(D)Lvu;
    • createBoolean

      public NbtElement createBoolean(boolean bool)
      Specified by:
      createBoolean in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createBoolean Lnet/minecraft/nbt/NbtOps;createBoolean(Z)Lnet/minecraft/nbt/NbtElement;
      intermediary method_23253 Lnet/minecraft/class_2509;method_23253(Z)Lnet/minecraft/class_2520;
      official a Lvl;a(Z)Lvu;
    • getStringValue

      public com.mojang.serialization.DataResult<String> getStringValue(NbtElement nbtElement)
      Specified by:
      getStringValue in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getStringValue Lnet/minecraft/nbt/NbtOps;getStringValue(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10656 Lnet/minecraft/class_2509;method_10656(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official b Lvl;b(Lvu;)Lcom/mojang/serialization/DataResult;
    • createString

      public NbtElement createString(String string)
      Specified by:
      createString in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createString Lnet/minecraft/nbt/NbtOps;createString(Ljava/lang/String;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10639 Lnet/minecraft/class_2509;method_10639(Ljava/lang/String;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/lang/String;)Lvu;
    • mergeToList

      public com.mojang.serialization.DataResult<NbtElement> mergeToList(NbtElement nbtElement, NbtElement nbtElement2)
      Specified by:
      mergeToList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named mergeToList Lnet/minecraft/nbt/NbtOps;mergeToList(Lnet/minecraft/nbt/NbtElement;Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_29156 Lnet/minecraft/class_2509;method_29156(Lnet/minecraft/class_2520;Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;Lvu;)Lcom/mojang/serialization/DataResult;
    • mergeToList

      public com.mojang.serialization.DataResult<NbtElement> mergeToList(NbtElement nbtElement, List<NbtElement> list)
      Specified by:
      mergeToList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named mergeToList Lnet/minecraft/nbt/NbtOps;mergeToList(Lnet/minecraft/nbt/NbtElement;Ljava/util/List;)Lcom/mojang/serialization/DataResult;
      intermediary method_29155 Lnet/minecraft/class_2509;method_29155(Lnet/minecraft/class_2520;Ljava/util/List;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;Ljava/util/List;)Lcom/mojang/serialization/DataResult;
    • mergeToMap

      public com.mojang.serialization.DataResult<NbtElement> mergeToMap(NbtElement nbtElement, NbtElement nbtElement2, NbtElement nbtElement3)
      Specified by:
      mergeToMap in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named mergeToMap Lnet/minecraft/nbt/NbtOps;mergeToMap(Lnet/minecraft/nbt/NbtElement;Lnet/minecraft/nbt/NbtElement;Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_29157 Lnet/minecraft/class_2509;method_29157(Lnet/minecraft/class_2520;Lnet/minecraft/class_2520;Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;Lvu;Lvu;)Lcom/mojang/serialization/DataResult;
    • mergeToMap

      public com.mojang.serialization.DataResult<NbtElement> mergeToMap(NbtElement nbtElement, com.mojang.serialization.MapLike<NbtElement> mapLike)
      Specified by:
      mergeToMap in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named mergeToMap Lnet/minecraft/nbt/NbtOps;mergeToMap(Lnet/minecraft/nbt/NbtElement;Lcom/mojang/serialization/MapLike;)Lcom/mojang/serialization/DataResult;
      intermediary method_29154 Lnet/minecraft/class_2509;method_29154(Lnet/minecraft/class_2520;Lcom/mojang/serialization/MapLike;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;Lcom/mojang/serialization/MapLike;)Lcom/mojang/serialization/DataResult;
    • mergeToMap

      public com.mojang.serialization.DataResult<NbtElement> mergeToMap(NbtElement nbtElement, Map<NbtElement,NbtElement> map)
      Specified by:
      mergeToMap in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named mergeToMap Lnet/minecraft/nbt/NbtOps;mergeToMap(Lnet/minecraft/nbt/NbtElement;Ljava/util/Map;)Lcom/mojang/serialization/DataResult;
      intermediary method_59877 Lnet/minecraft/class_2509;method_59877(Lnet/minecraft/class_2520;Ljava/util/Map;)Lcom/mojang/serialization/DataResult;
      official a Lvl;a(Lvu;Ljava/util/Map;)Lcom/mojang/serialization/DataResult;
    • getMapValues

      public com.mojang.serialization.DataResult<Stream<com.mojang.datafixers.util.Pair<NbtElement,NbtElement>>> getMapValues(NbtElement nbtElement)
      Specified by:
      getMapValues in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getMapValues Lnet/minecraft/nbt/NbtOps;getMapValues(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10669 Lnet/minecraft/class_2509;method_10669(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official c Lvl;c(Lvu;)Lcom/mojang/serialization/DataResult;
    • getMapEntries

      public com.mojang.serialization.DataResult<Consumer<BiConsumer<NbtElement,NbtElement>>> getMapEntries(NbtElement nbtElement)
      Specified by:
      getMapEntries in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getMapEntries Lnet/minecraft/nbt/NbtOps;getMapEntries(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_29162 Lnet/minecraft/class_2509;method_29162(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official d Lvl;d(Lvu;)Lcom/mojang/serialization/DataResult;
    • getMap

      public com.mojang.serialization.DataResult<com.mojang.serialization.MapLike<NbtElement>> getMap(NbtElement nbtElement)
      Specified by:
      getMap in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getMap Lnet/minecraft/nbt/NbtOps;getMap(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_29163 Lnet/minecraft/class_2509;method_29163(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official e Lvl;e(Lvu;)Lcom/mojang/serialization/DataResult;
    • createMap

      public NbtElement createMap(Stream<com.mojang.datafixers.util.Pair<NbtElement,NbtElement>> stream)
      Specified by:
      createMap in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createMap Lnet/minecraft/nbt/NbtOps;createMap(Ljava/util/stream/Stream;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10655 Lnet/minecraft/class_2509;method_10655(Ljava/util/stream/Stream;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/util/stream/Stream;)Lvu;
    • unpackMarker

      private static NbtElement unpackMarker(NbtCompound nbt)
      Mappings:
      Namespace Name Mixin selector
      named unpackMarker Lnet/minecraft/nbt/NbtOps;unpackMarker(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_46232 Lnet/minecraft/class_2509;method_46232(Lnet/minecraft/class_2487;)Lnet/minecraft/class_2520;
      official a Lvl;a(Lux;)Lvu;
    • getStream

      public com.mojang.serialization.DataResult<Stream<NbtElement>> getStream(NbtElement nbtElement)
      Specified by:
      getStream in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getStream Lnet/minecraft/nbt/NbtOps;getStream(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10664 Lnet/minecraft/class_2509;method_10664(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official f Lvl;f(Lvu;)Lcom/mojang/serialization/DataResult;
    • getList

      public com.mojang.serialization.DataResult<Consumer<Consumer<NbtElement>>> getList(NbtElement nbtElement)
      Specified by:
      getList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getList Lnet/minecraft/nbt/NbtOps;getList(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_29164 Lnet/minecraft/class_2509;method_29164(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official g Lvl;g(Lvu;)Lcom/mojang/serialization/DataResult;
    • getByteBuffer

      public com.mojang.serialization.DataResult<ByteBuffer> getByteBuffer(NbtElement nbtElement)
      Specified by:
      getByteBuffer in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getByteBuffer Lnet/minecraft/nbt/NbtOps;getByteBuffer(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10646 Lnet/minecraft/class_2509;method_10646(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official h Lvl;h(Lvu;)Lcom/mojang/serialization/DataResult;
    • createByteList

      public NbtElement createByteList(ByteBuffer byteBuffer)
      Specified by:
      createByteList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createByteList Lnet/minecraft/nbt/NbtOps;createByteList(Ljava/nio/ByteBuffer;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10657 Lnet/minecraft/class_2509;method_10657(Ljava/nio/ByteBuffer;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/nio/ByteBuffer;)Lvu;
    • getIntStream

      public com.mojang.serialization.DataResult<IntStream> getIntStream(NbtElement nbtElement)
      Specified by:
      getIntStream in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getIntStream Lnet/minecraft/nbt/NbtOps;getIntStream(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10651 Lnet/minecraft/class_2509;method_10651(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official i Lvl;i(Lvu;)Lcom/mojang/serialization/DataResult;
    • createIntList

      public NbtElement createIntList(IntStream intStream)
      Specified by:
      createIntList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createIntList Lnet/minecraft/nbt/NbtOps;createIntList(Ljava/util/stream/IntStream;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10663 Lnet/minecraft/class_2509;method_10663(Ljava/util/stream/IntStream;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/util/stream/IntStream;)Lvu;
    • getLongStream

      public com.mojang.serialization.DataResult<LongStream> getLongStream(NbtElement nbtElement)
      Specified by:
      getLongStream in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named getLongStream Lnet/minecraft/nbt/NbtOps;getLongStream(Lnet/minecraft/nbt/NbtElement;)Lcom/mojang/serialization/DataResult;
      intermediary method_10637 Lnet/minecraft/class_2509;method_10637(Lnet/minecraft/class_2520;)Lcom/mojang/serialization/DataResult;
      official j Lvl;j(Lvu;)Lcom/mojang/serialization/DataResult;
    • createLongList

      public NbtElement createLongList(LongStream longStream)
      Specified by:
      createLongList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createLongList Lnet/minecraft/nbt/NbtOps;createLongList(Ljava/util/stream/LongStream;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10643 Lnet/minecraft/class_2509;method_10643(Ljava/util/stream/LongStream;)Lnet/minecraft/class_2520;
      official a Lvl;a(Ljava/util/stream/LongStream;)Lvu;
    • createList

      public NbtElement createList(Stream<NbtElement> stream)
      Specified by:
      createList in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named createList Lnet/minecraft/nbt/NbtOps;createList(Ljava/util/stream/Stream;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10665 Lnet/minecraft/class_2509;method_10665(Ljava/util/stream/Stream;)Lnet/minecraft/class_2520;
      official b Lvl;b(Ljava/util/stream/Stream;)Lvu;
    • remove

      public NbtElement remove(NbtElement nbtElement, String string)
      Specified by:
      remove in interface com.mojang.serialization.DynamicOps<NbtElement>
      Mappings:
      Namespace Name Mixin selector
      named remove Lnet/minecraft/nbt/NbtOps;remove(Lnet/minecraft/nbt/NbtElement;Ljava/lang/String;)Lnet/minecraft/nbt/NbtElement;
      intermediary method_10648 Lnet/minecraft/class_2509;method_10648(Lnet/minecraft/class_2520;Ljava/lang/String;)Lnet/minecraft/class_2520;
      official a Lvl;a(Lvu;Ljava/lang/String;)Lvu;
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • mapBuilder

      public com.mojang.serialization.RecordBuilder<NbtElement> mapBuilder()
      Specified by:
      mapBuilder in interface com.mojang.serialization.DynamicOps<NbtElement>
    • createMerger

      private static Optional<NbtOps.Merger> createMerger(NbtElement nbt)
      Mappings:
      Namespace Name Mixin selector
      named createMerger Lnet/minecraft/nbt/NbtOps;createMerger(Lnet/minecraft/nbt/NbtElement;)Ljava/util/Optional;
      intermediary method_46235 Lnet/minecraft/class_2509;method_46235(Lnet/minecraft/class_2520;)Ljava/util/Optional;
      official k Lvl;k(Lvu;)Ljava/util/Optional;