diff --git a/blocks/BlockPos.js b/blocks/BlockPos.js
new file mode 100644
index 0000000..f09b6ac
--- /dev/null
+++ b/blocks/BlockPos.js
@@ -0,0 +1,65 @@
+const blockpos_getxyz = {
+ init: function () {
+ this.appendDummyInput('TAB')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField(new Blockly.FieldDropdown([
+ ['x', '$x'],
+ ['y', '$y'],
+ ['z', '$z']
+ ]), 'TAB');
+ this.appendValueInput('VALUE')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField('component of BlockPos');
+ this.setInputsInline(true)
+ this.setOutput(true, "Number");
+ this.setTooltip('Get a component of a block pos');
+ this.setHelpUrl('');
+ this.setColour(270);
+ }
+};
+Blockly.common.defineBlocks({ blockpos_getxyz: blockpos_getxyz });
+
+
+
+javascript.javascriptGenerator.forBlock['blockpos_getxyz'] = function () {
+ const dropdown_tab = block.getFieldValue('TAB');
+ const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
+
+ const code = `(${value_value})["${dropdown_tab}"]`;
+ return [code, javascript.Order.NONE];
+}
+
+
+
+const blockpos_fromxyz = {
+ init: function () {
+ this.appendValueInput('X')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('Make BlockPos from x:');
+ this.appendValueInput('Y')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('y:');
+ this.appendValueInput('Z')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('z:');
+ this.setInputsInline(true)
+ this.setOutput(true, null);
+ this.setTooltip('Create a BlockPos from components');
+ this.setHelpUrl('');
+ this.setColour(270);
+ },
+ libs: ["construct_blockpos"]
+};
+Blockly.common.defineBlocks({ blockpos_fromxyz: blockpos_fromxyz });
+
+javascript.javascriptGenerator.forBlock['blockpos_fromxyz'] = function () {
+ const value_x = javascript.javascriptGenerator.valueToCode(this, 'X', javascript.Order.ATOMIC);
+ const value_y = javascript.javascriptGenerator.valueToCode(this, 'Y', javascript.Order.ATOMIC);
+ const value_z = javascript.javascriptGenerator.valueToCode(this, 'Z', javascript.Order.ATOMIC);
+
+ const code = `efb2__makeBlockPos(${value_x},${value_y},${value_z})`;
+ return [code, javascript.Order.NONE];
+}
\ No newline at end of file
diff --git a/blocks/Vec3.js b/blocks/Vec3.js
new file mode 100644
index 0000000..6a948f1
--- /dev/null
+++ b/blocks/Vec3.js
@@ -0,0 +1,65 @@
+const vec3_getxyz = {
+ init: function () {
+ this.appendDummyInput('TAB')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField(new Blockly.FieldDropdown([
+ ['x', '$xCoord'],
+ ['y', '$yCoord'],
+ ['z', '$zCoord']
+ ]), 'TAB');
+ this.appendValueInput('VALUE')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField('component of Vec3');
+ this.setInputsInline(true)
+ this.setOutput(true, "Number");
+ this.setTooltip('Get a component of a Vec3');
+ this.setHelpUrl('');
+ this.setColour(270);
+ }
+};
+Blockly.common.defineBlocks({ vec3_getxyz: vec3_getxyz });
+
+
+
+javascript.javascriptGenerator.forBlock['vec3_getxyz'] = function () {
+ const dropdown_tab = block.getFieldValue('TAB');
+ const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
+
+ const code = `(${value_value})["${dropdown_tab}"]`;
+ return [code, javascript.Order.NONE];
+}
+
+
+
+const vec3_fromxyz = {
+ init: function () {
+ this.appendValueInput('X')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('Make Vec3 from x:');
+ this.appendValueInput('Y')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('y:');
+ this.appendValueInput('Z')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .setCheck('Number')
+ .appendField('z:');
+ this.setInputsInline(true)
+ this.setOutput(true, null);
+ this.setTooltip('Create a Vec3 from components');
+ this.setHelpUrl('');
+ this.setColour(270);
+ },
+ libs: ["construct_vec3"]
+};
+Blockly.common.defineBlocks({ vec3_fromxyz: vec3_fromxyz });
+
+javascript.javascriptGenerator.forBlock['vec3_fromxyz'] = function () {
+ const value_x = javascript.javascriptGenerator.valueToCode(this, 'X', javascript.Order.ATOMIC);
+ const value_y = javascript.javascriptGenerator.valueToCode(this, 'Y', javascript.Order.ATOMIC);
+ const value_z = javascript.javascriptGenerator.valueToCode(this, 'Z', javascript.Order.ATOMIC);
+
+ const code = `efb2__makeVec3(${value_x},${value_y},${value_z})`;
+ return [code, javascript.Order.NONE];
+}
\ No newline at end of file
diff --git a/blocks/World.js b/blocks/World.js
index d195096..6c854ac 100644
--- a/blocks/World.js
+++ b/blocks/World.js
@@ -60,3 +60,68 @@ javascript.javascriptGenerator.forBlock['world_command'] = function () {
const code = `efb2__executeCommand(${value_world}, ${value_pos}, ${value_cmd});`;
return code;
}
+
+
+
+const world_is_not_remote = {
+ init: function () {
+ this.appendValueInput('WORLD')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField('world is on the server');
+ this.setInputsInline(true)
+ this.setOutput(true, 'Boolean');
+ this.setTooltip('Check if the world is running on the server.');
+ this.setHelpUrl('');
+ this.setColour(195);
+ }
+};
+Blockly.common.defineBlocks({ world_is_not_remote: world_is_not_remote });
+
+javascript.javascriptGenerator.forBlock['world_is_not_remote'] = function () {
+ const value_world = javascript.javascriptGenerator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
+ const code = `!(${value_world}).$isRemote`;
+ return [code, javascript.Order.NONE];
+}
+
+
+
+const world_get_loaded_entities = {
+ init: function () {
+ this.appendValueInput('WORLD')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField('get list of entities in world');
+ this.setInputsInline(true)
+ this.setOutput(true, 'Array');
+ this.setTooltip('Returns an array of entities in the world');
+ this.setHelpUrl('');
+ this.setColour(195);
+ }
+};
+Blockly.common.defineBlocks({ world_get_loaded_entities: world_get_loaded_entities });
+
+javascript.javascriptGenerator.forBlock['world_get_loaded_entities'] = function () {
+ const value_world = generator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
+ const code = `(${value_world}).loadedEntityList.toArray1().getRef().data`;
+ return [code, javascript.Order.NONE];
+}
+
+
+
+const world_get_player_entities = {
+ init: function () {
+ this.appendValueInput('WORLD')
+ .setAlign(Blockly.inputs.Align.RIGHT)
+ .appendField('get list of players in world');
+ this.setInputsInline(true)
+ this.setOutput(true, 'Array');
+ this.setTooltip('Returns an array of player entities in the world');
+ this.setHelpUrl('');
+ this.setColour(195);
+ }
+};
+Blockly.common.defineBlocks({ world_get_player_entities: world_get_player_entities });
+javascript.javascriptGenerator.forBlock['world_get_player_entities'] = function () {
+ const value_world = javascript.javascriptGenerator.valueToCode(thiss, 'WORLD', javascript.Order.ATOMIC);
+ const code = `(${value_world}).playerEntities.toArray1().getRef().data`;
+ return [code, javascript.Order.NONE];
+}
\ No newline at end of file
diff --git a/functions.js b/functions.js
index d66ce81..d60c1b5 100644
--- a/functions.js
+++ b/functions.js
@@ -64,6 +64,36 @@ FUNCTIONS["execute_command"] = {
},
};
+FUNCTIONS["construct_vec3"] = {
+ identifier: "construct_vec3",
+ //Very important that there is no name and a whitespace before and after the parantheses
+ code: function () {
+ function EFB2__defineMakeVec3() {
+ var mkVec3 = ModAPI.reflect.getClassById("net.minecraft.util.Vec3").constructors.find(x=>x.length===3);
+ globalThis.efb2__makeVec3 = function efb2__makeVec3(x, y, z) {
+ return mkVec3(x, y, z);
+ }
+ }
+ ModAPI.dedicatedServer.appendCode(EFB2__defineMakeVec3);
+ EFB2__defineMakeVec3();
+ },
+};
+
+FUNCTIONS["construct_blockpos"] = {
+ identifier: "construct_blockpos",
+ //Very important that there is no name and a whitespace before and after the parantheses
+ code: function () {
+ function EFB2__defineMakeBlockPos() {
+ var mkBlockPos = ModAPI.reflect.getClassById("net.minecraft.util.BlockPos").constructors.find(x=>x.length===3);
+ globalThis.efb2__makeBlockPos = function efb2__makeBlockPos(x, y, z) {
+ return mkBlockPos(x, y, z);
+ }
+ }
+ ModAPI.dedicatedServer.appendCode(EFB2__defineMakeBlockPos);
+ EFB2__defineMakeBlockPos();
+ },
+};
+
function getFunctionCode(fn) {
return fn.code.toString().match(codeGrabberRegex)?.[0]
|| (()=>{console.error("Malformed function: ", fn); return "";})();
diff --git a/index.html b/index.html
index 58d2dda..67938c3 100644
--- a/index.html
+++ b/index.html
@@ -366,7 +366,7 @@
-
+
@@ -374,15 +374,38 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -442,7 +465,9 @@ Dirt Block
-
+
+
+