Looking for How to create extensions blocks


(Gameing live) #1

Dear all Extension developers, can you please tell me how to add block in java code (sorry for my bad English ) look i am new to this any extension developer can provide there whats app number so that the form will not be flood with my questions

Thank you so much for the support friends. Keep up the good work @yusufcihan, @Abhijith_Dominic, @MeteorCoder, @Ken

(Yusuf Cihan) #2

If you write a function, then it will be a purple block (method).


@SimpleFunction(description = "Block description")
     public void BlockName(parameters) {
     /* Your code here. */


@SimpleFunction(description = "Join two text.")
     public String Join(String t1, String t2) {
     return t1 + t2;

And this is for the property, green block.


@SimpleProperty(category = PropertyCategory.BEHAVIOR,
      description = "Block description.")
  public String Source() {
    return fileName;


@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING,
      defaultValue = "")
  public void Source(String fileName) {
    this.fileName = fileName;

This is only example, you need to do research to learn more about AI2 Extensions.

(Abhijith) #3

Great Work! If someone explained like this to me when i started i could’ve made a lot more extensions and gain experience. Great Work!!

(Abhijith) #4

For Yellow ie. Events

public void GotFile(String path){
EventDispatcher.dispatchEvent(this, “GotFile”, path);

(Nathan) #5

To create the Purple (function) block use:

@SimpleFunction(description = "") // Notice @SimpleFunction
public boolean Statement() { 
** boolean can switch to int, String, void, or boolean. Statement can be named
** to the name of your function, do NOT create duplicates. Public can also
** switch to private or public

Example function for boolean:

@SimpleFunction(description = "")
public boolean HasThoughtsAboutMe() {
 return false;

Example function for int:

@SimpleFunction(description = "")
public int HasThoughtsAboutMe() {
 return -1;

Example function for String:

@SimpleFunction(description = "")
public String HasThoughtsAboutMe() {
 return "Nope, we don't care about you.";

Example function for void:

@SimpleFunction(description = "")
public void HasThoughtsAboutMe() {

To create the Amber (event) block use:

@SimpleEvent(description = "") // Notice @SimpleEvent
public void Statement() { 
** This stays a void! Statement can be named
** to the name of your function, do NOT create duplicates. Public can
** also switch to private or public.
** The variables "statement, count", and "crashed" must be thrown when
** this block, so in your block which would throw to this one, you'd use
** Statement("Who knows why your phone died?", 8000, true); Below is
** required to register the block.

Example event with one variable:

@SimpleEvent(description = "")
public void GotAppleCount(int count) {
EventDispatcher.dispatchEvent(this, "GotAppleCount", count);

Example event with multiple variables:

@SimpleEvent(description = "")
public void GotAppleCount(int count, String statement, boolean areApples) {
EventDispatcher.dispatchEvent(this, "GotAppleCount", count, statement, areApples);

Example event with no variable:

@SimpleEvent(description = "")
public void GotAppleCount() {
EventDispatcher.dispatchEvent(this, "GotAppleCount");

Follow @yusufcihan’s example for properties, I no longer use them.

(Ken) #6

These are excellent examples @yusufcihan, @Abhijith_Dominic & @MeteorCoder!

@clashwithasif, the above examples are excellent. If you are looking to do something that isn’t listed above, what I do is, look at the .java file for a Component that implements something similar to what I need.
You can find the AI Component Sources here: