Class MapData

java.lang.Object
com.blamejared.crafttweaker.api.data.MapData
All Implemented Interfaces:
IData

@ZenRegister public class MapData extends Object implements IData
DocParam:
this {Hello : "World", Somewhere: "Over the rainbow"}
  • Constructor Details

    • MapData

      public MapData(net.minecraft.nbt.CompoundTag internal)
    • MapData

      public MapData()
    • MapData

      public MapData(Map<String,IData> map)
    • MapData

      public MapData(net.minecraft.nbt.CompoundTag internal, Set<String> boolDataKeys)
  • Method Details

    • putAll

      public void putAll(Map<String,IData> map)
      Adds all entries from the given map into this one. Can override existing keys.
      Parameters:
      map - The other entries to be added to this map
      DocParam:
      map {Hello: "Goodbye", Item: "Bedrock"}
    • opAdd

      public MapData opAdd(IData data)
      Adds all entries from the given IData to this entry
    • getKeySet

      public Set<String> getKeySet()
    • getSize

      public int getSize()
    • put

      public IData put(String key, IData value)
      Adds sets the value for the given key or creates a new entry if it did not exist before.
      Parameters:
      key - The key to set the value for.
      value - The value to set.
      Returns:
      The previous value if present, null otherwise
      DocParam:
      key "Hello", value "Goodbye"
    • getAt

      public IData getAt(String key)
      Retrieves the value associated with the key
      Parameters:
      key - The key to search for
      Returns:
      The value if present, null otherwise
      DocParam:
      key "Hello"
    • getData

      public <T extends IData> T getData(Class<T> clazz, String key)
      Retrieves the value associated with the key and returns it as the given type.
      Parameters:
      key - The key to search for.
      Returns:
      The value if present, null otherwise.
      DocParam:
      key "Hello"
    • contains

      public boolean contains(String key)
      Checks if the Map contains the given key.
      Parameters:
      key - The key to search for
      Returns:
      True if the Map contains the key
      DocParam:
      key "Hello"
    • remove

      public void remove(String key)
      Removes the entry with the given key from the Map
      Parameters:
      key - The key of the entry to remove
      DocParam:
      key "Somewhere"
    • isEmpty

      public boolean isEmpty()
    • merge

      public MapData merge(MapData other)
      Merges this map and the other map. If entries from this map and the other map share the values are tried to be merged. If that does not work, then the value from the other map is used.
      Parameters:
      other - The other map.
      Returns:
      This map, after the merge
      DocParam:
      other {Doodle: "Do"}
    • copy

      public MapData copy()
      Description copied from interface: IData
      Makes a copy of this IData. IData is immutable by default, use this to create a proper copy of the object.
      Specified by:
      copy in interface IData
      Returns:
      a copy of this IData.
    • copyInternal

      public MapData copyInternal()
      Description copied from interface: IData
      Makes a copy of this IData with a copy of the internal INBT object.
      Specified by:
      copyInternal in interface IData
      Returns:
      a copy of this IData with a copy of the internal INBT object.
    • getInternal

      public net.minecraft.nbt.CompoundTag getInternal()
      Description copied from interface: IData
      Gets the internal INBT stored in this IData.
      Specified by:
      getInternal in interface IData
      Returns:
      the vanilla INBT tag that this IData represents.
    • asMap

      public Map<String,IData> asMap()
      Description copied from interface: IData
      Gets a Map<String, IData> representation of this IData, returns null on anything but MapData.
      Specified by:
      asMap in interface IData
      Returns:
      null if this IData is not a map.
    • contains

      public boolean contains(IData data)
      Description copied from interface: IData
      Checks if this IData contains another IData, mainly used in subclasses of ICollectionData, is the same as an equals check on other IData types
      Specified by:
      contains in interface IData
      Parameters:
      data - data to check if it is contained
      Returns:
      true if the given IData is contained in this IData
    • castToMap

      public Map<String,IData> castToMap()
    • getType

      public IData.Type getType()
      Description copied from interface: IData
      Gets the type of this IData.
      Specified by:
      getType in interface IData
      Returns:
      The type of this IData.
    • accept

      public <T> T accept(DataVisitor<T> visitor)
      Specified by:
      accept in interface IData
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • boolDataKeys

      public Set<String> boolDataKeys()