BlockDefinition

public final class BlockDefinition extends Object

Definition of a type of block, usually defined in JSON. See the guide on block definitionsfor details.

Public Constructor Summary

BlockDefinition(String jsonStr)
Initializes the definition from a string of JSON.
BlockDefinition(JSONObject json)
Initializes the definition from a JSON object.

Public Method Summary

int
List<String>
String
String
getTypeName()
This is the identifying string used in the "type" attributes within JSON and XML.
boolean
static boolean
isValidType(String typeName)

Protected Method Summary

ArrayList<Input>
Connection
Connection
Connection

Inherited Method Summary

Public Constructors

public BlockDefinition (String jsonStr)

Initializes the definition from a string of JSON.

Parameters
jsonStr The JSON definition as a string.
Throws
JSONException If JSON is malformed or does not include expected attributes.
BlockLoadingException

public BlockDefinition (JSONObject json)

Initializes the definition from a JSON object.

Parameters
json The JSON object with the definition.
Throws
BlockLoadingException If JSON does not include expected attributes.

Public Methods

public int getColor ()

Returns
  • The opaque Color int of block.

public List<String> getExtensionNames ()

Returns
  • A list of extension names to apply to all instances of this BlockDefinition.

public String getMutatorId ()

Returns
  • The name of the BlockExtension (if any) which will add a Mutator to all Block instances of this type. Otherwise, null.

public String getTypeName ()

This is the identifying string used in the "type" attributes within JSON and XML.

Returns
  • The identifying name of the block definition, referenced by XML and BlockTemplates.

public boolean isInputsInlineDefault ()

Returns
  • True if new blocks begin with inputs inlined. Otherwise, false.

public static boolean isValidType (String typeName)

Parameters
typeName

Protected Methods

protected ArrayList<Input> createInputList (BlockFactory factory)

Parameters
factory
Returns
  • A new list of Input objects for a new block of this type, complete with fields.

protected Connection createNextConnection ()

Returns
  • A new next connection for a new block of this type, or null if the block should not have an next connection.

protected Connection createOutputConnection ()

Returns
  • A new output connection for a new block of this type, or null if the block should not have an output connection.

protected Connection createPreviousConnection ()

Returns
  • A new previous connection for a new block of this type, or null if the block should not have an previous connection.