MapData

This class was added by a mod with mod-id crafttweaker. So you need to have this mod installed if you want to use this feature.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

import crafttweaker.api.data.MapData;

Implemented Interfaces

MapData implements the following interfaces. That means all methods defined in these interfaces are also available in MapData

Constructors

No Description Provided

new MapData() as MapData
new MapData();

No Description Provided

new MapData(map as IData[string]) as MapData
ParameterTypeDescription
mapIData[string]No Description Provided

Casters

Result typeIs Implicit
IData[string]true

Methods

contains

Checks if the Map contains the given key.

Return Type: boolean

MapData.contains(key as string) as boolean
{Hello : "World", Somewhere: "Over the rainbow"}.contains("Hello");
ParameterTypeDescription
keystringThe key to search for

getAt

Retrieves the value associated with the key

Return Type: IData

MapData.getAt(key as string) as IData
{Hello : "World", Somewhere: "Over the rainbow"}.getAt("Hello");
ParameterTypeDescription
keystringThe key to search for

merge

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.

Return Type: MapData

MapData.merge(other as MapData) as MapData
{Hello : "World", Somewhere: "Over the rainbow"}.merge({Doodle: "Do});
ParameterTypeDescription
otherMapDataThe other map.

put

Adds sets the value for the given key or creates a new entry if it did not exist before.

Return Type: IData

MapData.put(key as string, value as IData) as IData
{Hello : "World", Somewhere: "Over the rainbow"}.put("Hello", "Goodbye");
ParameterTypeDescription
keystringThe key to set the value for.
valueIDataThe value to set.

putAll

Adds all entries from the given map into this one. Can override existing keys.

Return Type: void

MapData.putAll(map as IData[string]) as void
{Hello : "World", Somewhere: "Over the rainbow"}.putAll({Hello: "Goodbye", Item: "Bedrock"});
ParameterTypeDescription
mapIData[string]The other entries to be added to this map

remove

Removes the entry with the given key from the Map

Return Type: void

MapData.remove(key as string) as void
{Hello : "World", Somewhere: "Over the rainbow"}.remove("Somewhere");
ParameterTypeDescription
keystringThe key of the entry to remove

Operators

ADD

Adds all entries from the given IData to this entry

myMapData + data as IData

Properties

NameTypeHas GetterHas Setter
isEmptybooleantruefalse
keySetSet<string>truefalse
sizeinttruefalse