Archive eaglerforge-builder (tool, 1.8.8, clean)

This commit is contained in:
2026-11-27 22:15:01 -06:00
parent 7f05345f49
commit 5f406cdc02
53 changed files with 11985 additions and 0 deletions
@@ -0,0 +1,51 @@
const enumaction = {
init: function () {
this.appendDummyInput('VAR')
.appendField('[1.12] EnumAction')
.appendField(new Blockly.FieldDropdown([
['PASS', 'PASS'],
['SUCCESS', 'SUCCESS'],
['FAIL', 'FAIL']
]), 'NAME');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Creates an EnumAction for 1.12 handlers.');
this.setHelpUrl('');
this.setColour(120);
}
};
Blockly.common.defineBlocks({ enumaction: enumaction });
javascript.javascriptGenerator.forBlock['enumaction'] = function () {
const enumaction = this.getFieldValue('NAME');
return [`(ModAPI.reflect.getClassByName("EnumActionResult").staticVariables.${enumaction})`, javascript.Order.NONE]
}
const actionresult = {
init: function () {
this.appendValueInput('OBJ')
.appendField('[1.12] ActionResult of');
this.appendDummyInput('VAR')
.appendField('mode:')
.appendField(new Blockly.FieldDropdown([
['PASS', 'PASS'],
['SUCCESS', 'SUCCESS'],
['FAIL', 'FAIL']
]), 'NAME');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Checks if a global is defined.');
this.setHelpUrl('');
this.setColour(120);
}
};
Blockly.common.defineBlocks({ actionresult: actionresult });
javascript.javascriptGenerator.forBlock['actionresult'] = function () {
const object = generator.valueToCode(block, 'OBJ', javascript.Order.ATOMIC);
const mode = block.getFieldValue('NAME');
return [`(ModAPI.reflect.getClassByName("ActionResult").constructors[0](ModAPI.reflect.getClassByName("EnumActionResult").staticVariables.${mode}, ${object}))`, javascript.Order.NONE];
}
@@ -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('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/util/BlockPos.html');
this.setColour(270);
}
};
Blockly.common.defineBlocks({ blockpos_getxyz: blockpos_getxyz });
javascript.javascriptGenerator.forBlock['blockpos_getxyz'] = function () {
const dropdown_tab = this.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('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/util/BlockPos.html');
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(Math.floor(${value_x}),Math.floor(${value_y}),Math.floor(${value_z}))`;
return [code, javascript.Order.NONE];
}
+312
View File
@@ -0,0 +1,312 @@
registerHandler("BlockConstructor", "block constructor", {}, function () {
this.setTooltip('Runs when the block type is initialised.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
const blocks_blockproperty = {
init: function () {
this.appendDummyInput('PROPERTY')
.appendField('set block')
.appendField(new Blockly.FieldDropdown([
['slipperiness', 'slipperiness'],
['light opacity', 'lightOpacity'],
['light value', 'lightValue'],
['blast resistance', 'blockResistance'],
['hardness', 'blockHardness']
]), 'PROPERTY');
this.appendValueInput('VALUE')
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_blockproperty: blocks_blockproperty });
javascript.javascriptGenerator.forBlock['blocks_blockproperty'] = function () {
const dropdown_property = this.getFieldValue('PROPERTY');
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `this["$${dropdown_property}"] = ${value_value};`;
return code;
}
const blocks_blockswitch = {
init: function () {
this.appendDummyInput('PROPERTY')
.appendField('set block')
.appendField(new Blockly.FieldDropdown([
['full block', 'fullBlock'],
['translucent', 'translucent'],
['use neighbor brightness', 'useNeighborBrightness'],
['needs random tick', 'needsRandomTick']
]), 'PROPERTY');
this.appendDummyInput('VALUE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('to')
.appendField(new Blockly.FieldCheckbox('TRUE'), 'VALUE');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_blockswitch: blocks_blockswitch });
javascript.javascriptGenerator.forBlock['blocks_blockswitch'] = function () {
const dropdown_property = this.getFieldValue('PROPERTY');
const checkbox_value = this.getFieldValue('VALUE') ? 1 : 0;
const code = `this["$${dropdown_property}"] = ${checkbox_value};`;
return code;
}
registerHandler("BlockBreak", "block break", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"$$blockstate": null
}, function () {
this.setTooltip('Runs when the block is removed from the world.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockAdded", "block added", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"$$blockstate": null
}, function () {
this.setTooltip('Runs when the block is added to the world.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockNeighbourChange", "block neighbor update", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"$$blockstate": null
}, function () {
this.setTooltip('Runs when a block\'s neighbor is changed.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockBrokenByPlayer", "block broken by player", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"$$blockstate": null
}, function () {
this.setTooltip('Runs when a block is broken by a player.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockRandomTick", "block random tick", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"$$blockstate": null,
"$$random": null
}, function () {
this.setTooltip('Runs when a block is ticked.\nNo return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
const blocks_block = {
init: function () {
this.appendDummyInput('BLOCK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('block')
.appendField(new Blockly.FieldMinecraftItemInput(true, true), 'BLOCK');
this.setInputsInline(true);
this.setOutput(true, null);
this.setTooltip('Returns an Block instance (for comparisons)');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_block: blocks_block });
javascript.javascriptGenerator.forBlock['blocks_block'] = function () {
const block_primitive = this.getFieldValue('BLOCK');
const object = {
id: block_primitive.split("/")[1].split("@")[0]
}
return [`(ModAPI.blocks["${object.id}"]?.getRef() || null)`, javascript.Order.NONE];
}
const blocks_currentblock = {
init: function () {
this.appendDummyInput('BLOCK')
.setAlign(Blockly.inputs.Align.LEFT)
.appendField('current block')
this.setInputsInline(true);
this.setOutput(true, null);
this.setTooltip('The current Block that the handler is executing on.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_currentblock: blocks_currentblock });
javascript.javascriptGenerator.forBlock['blocks_currentblock'] = function () {
return [`$$nmb_AdvancedBlock`, javascript.Order.NONE];
}
const blocks_boundingbox = {
init: function () {
this.appendDummyInput('MIN')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Set block bounds to min:')
.appendField(new Blockly.FieldNumber(0), 'MINX')
.appendField(new Blockly.FieldNumber(0), 'MINY')
.appendField(new Blockly.FieldNumber(0), 'MINZ');
this.appendDummyInput('MAX')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('max:')
.appendField(new Blockly.FieldNumber(1), 'MAXX')
.appendField(new Blockly.FieldNumber(1), 'MAXY')
.appendField(new Blockly.FieldNumber(1), 'MAXZ');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the block\'s bounding box');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_boundingbox: blocks_boundingbox });
javascript.javascriptGenerator.forBlock['blocks_boundingbox'] = function () {
const number_minx = this.getFieldValue('MINX');
const number_miny = this.getFieldValue('MINY');
const number_minz = this.getFieldValue('MINZ');
const number_maxx = this.getFieldValue('MAXX');
const number_maxy = this.getFieldValue('MAXY');
const number_maxz = this.getFieldValue('MAXZ');
const code = `this.$setBlockBounds(${number_minx}, ${number_miny}, ${number_minz}, ${number_maxx}, ${number_maxy}, ${number_maxz});`;
return code;
}
const blocks_creativetab = {
init: function () {
this.appendDummyInput('TAB')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Set block creative tab to')
.appendField(new Blockly.FieldDropdown([
["tabBlock", "tabBlock"],
["tabDecorations", "tabDecorations"],
["tabRedstone", "tabRedstone"],
["tabTransport", "tabTransport"],
["tabMisc", "tabMisc"],
["tabAllSearch", "tabAllSearch"],
["tabFood", "tabFood"],
["tabTools", "tabTools"],
["tabCombat", "tabCombat"],
["tabBrewing", "tabBrewing"],
["tabMaterials", "tabMaterials"],
["tabInventory", "tabInventory"]
]), 'TAB');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Set the creative tab of the block');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_creativetab: blocks_creativetab });
javascript.javascriptGenerator.forBlock['blocks_creativetab'] = function () {
let dropdown_tab = this.getFieldValue('TAB');
if (flags.target === "1_12") {
dropdown_tab = dropdown_tab.replace("tab", "").toUpperCase();
}
const code = `this.$setCreativeTab(ModAPI.reflect.getClassById("net.minecraft.creativetab.CreativeTabs").staticVariables.${dropdown_tab});`;
return code;
}
registerHandler("BlockEntityCollision", "block entity collision", {
"WORLD": "world",
"BLOCKPOS": "blockpos",
"ENTITY": "entity",
}, function () {
this.setTooltip('Runs when an entity collides with the block.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockGetDroppedItem", "block get dropped item", {
"$$blockstate": null,
"$$random": null,
"FORTURE": "forture",
}, function () {
this.setTooltip('Runs when a block is broken to get the dropped item.\nItem return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("BlockQuantityDropped", "block get dropped quantity", {
"FORTURE": "forture",
"$$random": null,
}, function () {
this.setTooltip('Runs when a block is broken to get the dropped quantity.\nInteger return value expected.');
this.setHelpUrl('');
this.setColour(0);
});
const blocks_setsoundtype = {
init: function () {
this.appendDummyInput('S')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Set block sound type to')
.appendField(new Blockly.FieldDropdown([
["wood", "wood"],
["ground", "ground"],
["plant", "plant"],
["stone", "stone"],
["metal", "metal"],
["glass", "glass"],
["cloth", "cloth"],
["sand", "sand"],
["snow", "snow"],
["ladder", "ladder"],
["anvil", "anvil"],
["slime", "slime"]
]), 'S');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Set the sound type of the block');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ blocks_setsoundtype: blocks_setsoundtype });
javascript.javascriptGenerator.forBlock['blocks_setsoundtype'] = function () {
let dropdown_tab = this.getFieldValue('S');
if (flags.target !== "1_12") {
dropdown_tab = dropdown_tab.replaceAll("ground", "gravel");
if (dropdown_tab === "slime") {
dropdown_tab = "SLIME_SOUND";
} else {
dropdown_tab = dropdown_tab[0].toUpperCase() + dropdown_tab.slice(1);
dropdown_tab = "soundType" + dropdown_tab;
}
} else {
dropdown_tab = dropdown_tab.toUpperCase();
}
const code = flags.target === "1_12"
? `this.$setSoundType(ModAPI.blockSounds.${dropdown_tab}.getRef());`
: `this.$setStepSound($$blockClass.staticVariables.${dropdown_tab});`;
return code;
}
@@ -0,0 +1,141 @@
registerHandler("CommandCalled", "command called by other", {
"ARGS": "argument list",
"COMMAND_SENDER": "command sender",
}, function () {
this.setTooltip('Runs when the command is called by a non-player.');
this.setHelpUrl('');
this.setColour(0);
});
registerHandler("CommandCalledByPlayer", "command called by player", {
"ARGS": "argument list",
"player": "player",
"COMMAND_SENDER": "command sender",
}, function () {
this.setTooltip('Runs when the command is called by a player.');
this.setHelpUrl('');
this.setColour(0);
});
const command_sendmessage = {
libs: ["message_command_sender"],
init: function () {
this.appendValueInput('MESSAGE')
.setCheck('String')
.appendField('send message');
this.appendValueInput('SENDER')
.appendField('to command sender');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sends a message to the specified command sender.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ command_sendmessage: command_sendmessage });
javascript.javascriptGenerator.forBlock['command_sendmessage'] = function () {
const value_message = javascript.javascriptGenerator.valueToCode(this, 'MESSAGE', javascript.Order.ATOMIC);
const value_sender = javascript.javascriptGenerator.valueToCode(this, 'SENDER', javascript.Order.ATOMIC);
const code = `efb2__messageCommandSender(${value_sender}, ${value_message});`;
return code;
}
const command_get_position = {
init: function () {
this.appendValueInput('CMDSENDER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get position of command sender');
this.appendDummyInput('AS')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('as')
.appendField(new Blockly.FieldDropdown([
['BlockPos', '$getPosition'],
['Vec3', '$getPositionVector']
]), 'AS');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the command sender\'s position object.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ command_get_position: command_get_position });
javascript.javascriptGenerator.forBlock['command_get_position'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'CMDSENDER', javascript.Order.ATOMIC);
const dropdown_as = this.getFieldValue('AS');
const code = `(${value_entity})["${dropdown_as}"]()`;
return [code, javascript.Order.NONE];
}
const command_get_world = {
init: function () {
this.appendValueInput('CMDSENDER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get world of command sender');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the command sender\'s world object.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ command_get_world: command_get_world });
javascript.javascriptGenerator.forBlock['command_get_world'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'CMDSENDER', javascript.Order.ATOMIC);
const code = `(${value_entity}).$getEntityWorld()`;
return [code, javascript.Order.NONE];
}
const command_get_entity = {
init: function () {
this.appendValueInput('CMDSENDER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get command sender as entity');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the command sender as an entity. May be null.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ command_get_entity: command_get_entity });
javascript.javascriptGenerator.forBlock['command_get_entity'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'CMDSENDER', javascript.Order.ATOMIC);
const code = `(${value_entity}).$getCommandSenderEntity()`;
return [code, javascript.Order.NONE];
}
const command_get_name = {
init: function () {
this.appendValueInput('CMDSENDER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get name of command sender');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the command sender\'s name.');
this.setHelpUrl('');
this.setColour(0);
}
};
Blockly.common.defineBlocks({ command_get_name: command_get_name });
javascript.javascriptGenerator.forBlock['command_get_name'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'CMDSENDER', javascript.Order.ATOMIC);
const code = `ModAPI.util.ustr((${value_entity}).$getName())`;
return [code, javascript.Order.NONE];
}
@@ -0,0 +1,7 @@
registerHandler("CraftingRecipeModifyResult", "crafting recipe modify item", {
"ITEMSTACK": "itemstack",
}, function () {
this.setTooltip('Runs when registering the command to modify the output item. Does not expect a return value.');
this.setHelpUrl('');
this.setColour(15);
});
+77
View File
@@ -0,0 +1,77 @@
const debug_log = {
init: function () {
this.appendValueInput('NAME')
.appendField('log to console');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Logs the string/object provided to the console. ');
this.setHelpUrl('');
this.setColour(270);
},
libs: ["java_logger"]
};
Blockly.common.defineBlocks({ debug_log: debug_log });
javascript.javascriptGenerator.forBlock['debug_log'] = function () {
const log = javascript.javascriptGenerator.valueToCode(this, 'NAME', javascript.Order.ATOMIC);
const code = `efb2__jlog(${log});`;
return code;
}
const debug_warn = {
init: function () {
this.appendValueInput('NAME')
.appendField('warn to console');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Logs the string/object provided to the console as a warning. ');
this.setHelpUrl('');
this.setColour(270);
},
libs: ["java_logger"]
};
Blockly.common.defineBlocks({ debug_warn: debug_warn });
javascript.javascriptGenerator.forBlock['debug_warn'] = function () {
const log = javascript.javascriptGenerator.valueToCode(this, 'NAME', javascript.Order.ATOMIC);
const code = `efb2__jwarn(${log});`;
return code;
}
const debug_err = {
init: function () {
this.appendValueInput('NAME')
.appendField('error to console');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Logs the string/object provided to the console as an error. ');
this.setHelpUrl('');
this.setColour(270);
},
libs: ["java_logger"]
};
Blockly.common.defineBlocks({ debug_err: debug_err });
javascript.javascriptGenerator.forBlock['debug_err'] = function () {
const log = javascript.javascriptGenerator.valueToCode(this, 'NAME', javascript.Order.ATOMIC);
const code = `efb2__jerr(${log});`;
return code;
}
const debug_debugger = {
init: function () {
this.appendDummyInput('NAME')
.appendField('debugger');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('If devtools is open, pauses code execution at this position.');
this.setHelpUrl('');
this.setColour(270);
}
};
Blockly.common.defineBlocks({ debug_debugger: debug_debugger });
javascript.javascriptGenerator.forBlock['debug_debugger'] = function () {
const code = `debugger;`;
return code;
}
+407
View File
@@ -0,0 +1,407 @@
const ENTITY_NUMERICAL_PROPS = [
['x', '$posX'],
['y', '$posY'],
['z', '$posZ'],
['x velocity', '$motionX'],
['y velocity', '$motionY'],
['z velocity', '$motionZ'],
['yaw', '$rotationYaw'],
['pitch', '$rotationPitch'],
['fallDistance', '$fallDistance'],
['stepHeight', '$stepHeight'],
['age (ticks)', '$ticksExisted'],
['fire time (ticks)', '$fire'],
['chunk x', '$chunkCoordX'],
['chunk y', '$chunkCoordY'],
['chunk z', '$chunkCoordZ'],
['dimension', '$dimension'],
['collision reduction', "$entityCollisionReduction"]
];
const ENTITY_BOOLEAN_PROPS = [
['on ground', '$onGround'],
['collided horizontally', '$isCollidedHorizontally'],
['collided vertically', '$isCollidedVertically'],
['collided', '$isCollided'],
['is in web', '$isInWeb'],
['is outside border', '$isOutsideBorder'],
['is dead', '$isDead'],
['no clip', '$noClip'],
['in water', '$inWater'],
['is immune to fire', '$isImmuneToFire'],
['in portal', '$inPortal'],
['invulnerable', '$invulnerable']
];
const entity_set_position = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set position of entity');
this.appendValueInput('POS')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('to Vec3');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the position of the entity to a vector, and sends a packet.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_set_position: entity_set_position });
javascript.javascriptGenerator.forBlock['entity_set_position'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const value_pos = javascript.javascriptGenerator.valueToCode(this, 'POS', javascript.Order.ATOMIC);
const code = `var $$efb_vec3pos = ${value_pos};(${value_entity}).$setPositionAndUpdate($$efb_vec3pos.$xCoord,$$efb_vec3pos.$yCoord,$$efb_vec3pos.$zCoord)`;
return code;
}
const entity_set_position_xyz = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set position of entity');
this.appendValueInput('X')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('to X:');
this.appendValueInput('Y')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Y:');
this.appendValueInput('Z')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Z:');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the position of the entity to a vector, and sends a packet.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_set_position_xyz: entity_set_position_xyz });
javascript.javascriptGenerator.forBlock['entity_set_position_xyz'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
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 = `(${value_entity}).$setPositionAndUpdate(${value_X},${value_Y},${value_Z})`;
return code;
}
const entity_get_prop = {
init: function () {
this.appendDummyInput('PROP')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(ENTITY_NUMERICAL_PROPS), 'PROP');
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of entity');
this.setInputsInline(true)
this.setOutput(true, "Number");
this.setTooltip('Gets a property of the entity. yaw and pitch are in radians, not degrees.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_prop: entity_get_prop });
javascript.javascriptGenerator.forBlock['entity_get_prop'] = function () {
const dropdown_prop = this.getFieldValue('PROP');
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `(${value_entity})["${dropdown_prop}"]`;
return [code, javascript.Order.NONE];
}
const entity_set_prop = {
init: function () {
this.appendDummyInput('PROP')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set')
.appendField(new Blockly.FieldDropdown(ENTITY_NUMERICAL_PROPS), 'PROP');
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of entity');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets a property of the entity. yaw and pitch are in radians, not degrees.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_set_prop: entity_set_prop });
javascript.javascriptGenerator.forBlock['entity_set_prop'] = function () {
const dropdown_prop = this.getFieldValue('PROP');
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_entity})["${dropdown_prop}"] = ${value_value};`;
return code;
}
const entity_set_switch = {
init: function () {
this.appendDummyInput('PROP')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set boolean')
.appendField(new Blockly.FieldDropdown(ENTITY_BOOLEAN_PROPS), 'PROP');
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of entity');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Boolean')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets a boolean property of the entity.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_set_switch: entity_set_switch });
javascript.javascriptGenerator.forBlock['entity_set_switch'] = function () {
const dropdown_prop = this.getFieldValue('PROP');
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_entity})["${dropdown_prop}"] = ((${value_value}) ? 1 : 0);`;
return code;
}
const entity_get_switch = {
init: function () {
this.appendDummyInput('PROP')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(ENTITY_BOOLEAN_PROPS), 'PROP');
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of entity');
this.setInputsInline(true)
this.setOutput(true, 'Boolean');
this.setTooltip('Sets a boolean property of the entity.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_switch: entity_get_switch });
javascript.javascriptGenerator.forBlock['entity_get_switch'] = function () {
const dropdown_prop = this.getFieldValue('PROP');
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `((${value_entity})["${dropdown_prop}"] ? true : false)`;
return [code, javascript.Order.NONE];
}
const entity_get_world = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get world of entity');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the entity\'s world object.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_world: entity_get_world });
javascript.javascriptGenerator.forBlock['entity_get_world'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `(${value_entity}).$worldObj`;
return [code, javascript.Order.NONE];
}
const entity_get_position = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get position of entity');
this.appendDummyInput('AS')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('as')
.appendField(new Blockly.FieldDropdown([
['BlockPos', '$getPosition'],
['Vec3', '$getPositionVector']
]), 'AS');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the entity\'s position object.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_position: entity_get_position });
javascript.javascriptGenerator.forBlock['entity_get_position'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const dropdown_as = this.getFieldValue('AS');
const code = `(${value_entity})["${dropdown_as}"]()`;
return [code, javascript.Order.NONE];
}
const entity_distance = {
init: function () {
this.appendValueInput('A')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('distance from entity');
this.appendValueInput('B')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('to entity');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Get the distance between two entities');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_distance: entity_distance });
javascript.javascriptGenerator.forBlock['entity_distance'] = function () {
const value_a = javascript.javascriptGenerator.valueToCode(this, 'A', javascript.Order.ATOMIC);
const value_b = javascript.javascriptGenerator.valueToCode(this, 'B', javascript.Order.ATOMIC);
const code = `(${value_a}).$getDistanceToEntity(${value_b})`;
return [code, javascript.Order.NONE];
}
const entity_distance_vec3 = {
init: function () {
this.appendValueInput('A')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('distance from entity');
this.appendValueInput('B')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('to Vec3');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Get the distance from an entity to a Vec3 position');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_distance_vec3: entity_distance_vec3 });
javascript.javascriptGenerator.forBlock['entity_distance_vec3'] = function () {
const value_a = javascript.javascriptGenerator.valueToCode(this, 'A', javascript.Order.ATOMIC);
const value_b = javascript.javascriptGenerator.valueToCode(this, 'B', javascript.Order.ATOMIC);
const code = `(($$efb2_arg_a, $$efb2_arg_b)=>$$efb2_arg_a.$getDistance($$efb2_arg_b.$x,$$efb2_arg_b.$y,$$efb2_arg_b.$z))(${value_a}, ${value_b})`;
return [code, javascript.Order.NONE];
}
const entity_get_lookvec = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get look vector of entity');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Gets an entity\'s look vector (Vec3)');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_lookvec: entity_get_lookvec });
javascript.javascriptGenerator.forBlock['entity_get_lookvec'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `(${value_entity}).$getLook(1)`;
return [code, javascript.Order.NONE];
}
const entity_get_eye_pos = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get eye position vector of entity');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Gets an entity\'s eye position (Vec3)');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_get_eye_pos: entity_get_eye_pos });
javascript.javascriptGenerator.forBlock['entity_get_eye_pos'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `(${value_entity}).$getPositionEyes(1)`;
return [code, javascript.Order.NONE];
}
const entity_raytrace = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('hit position from ray cast with entity');
this.appendValueInput('DIST')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('with max distance');
this.setInputsInline(false)
this.setOutput(true, 'Number');
this.setTooltip('Cast a ray from an entity and return the hit position as a Vec3.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_raytrace: entity_raytrace });
javascript.javascriptGenerator.forBlock['entity_raytrace'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const value_dist = javascript.javascriptGenerator.valueToCode(this, 'DIST', javascript.Order.ATOMIC);
const code = `(${value_entity}).$rayTrace((${value_dist}), 1).$hitVec`;
return [code, javascript.Order.NONE];
}
const entity_setdead = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set entity to dead');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets an entity\'s state to \'dead\'');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/Entity.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ entity_setdead: entity_setdead });
javascript.javascriptGenerator.forBlock['entity_setdead'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `(${value_entity}).$setDead();`;
return code;
}
+277
View File
@@ -0,0 +1,277 @@
const keyCodes = [
["ANY", ""],
["SPACE", "32"],
["UP ARROW", "38"],
["DOWN ARROW", "40"],
["LEFT ARROW", "37"],
["RIGHT ARROW", "39"],
["A", "65"],
["B", "66"],
["C", "67"],
["D", "68"],
["E", "69"],
["F", "70"],
["G", "71"],
["H", "72"],
["I", "73"],
["J", "74"],
["K", "75"],
["L", "76"],
["M", "77"],
["N", "78"],
["O", "79"],
["P", "80"],
["Q", "81"],
["R", "82"],
["S", "83"],
["T", "84"],
["U", "85"],
["V", "86"],
["W", "87"],
["X", "88"],
["Y", "89"],
["Z", "90"],
["0", "48"],
["1", "49"],
["2", "50"],
["3", "51"],
["4", "52"],
["5", "53"],
["6", "54"],
["7", "55"],
["8", "56"],
["9", "57"],
["F1", "112"],
["F2", "113"],
["F3", "114"],
["F4", "115"],
["F5", "116"],
["F6", "117"],
["F7", "118"],
["F8", "119"],
["F9", "120"],
["F10", "121"],
["F11", "122"],
["F12", "123"],
];
const events_onModLoads = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('when all mods finished loading'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed when all mods finished loading.');
this.setHelpUrl('');
}
};
const events_onClientTick = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('each client tick'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed on each client tick.');
this.setHelpUrl('');
}
};
const events_onClientFrame = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('each client frame'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed on each client frame.');
this.setHelpUrl('');
}
};
/*
const events_onKeyPressed = {
init: function() {
this.appendDummyInput()
.appendField('when')
.appendField(new Blockly.FieldDropdown(keyCodes), 'KEYCODE')
.appendField('key pressed');
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed when a key is pressed.');
this.setHelpUrl('');
}
};
const events_onKeyReleased = {
init: function() {
this.appendDummyInput()
.appendField('when')
.appendField(new Blockly.FieldDropdown(keyCodes), 'KEYCODE')
.appendField('key released');
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed when a key is released.');
this.setHelpUrl('');
}
};
*/
const events_onscreenRender = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('On Screen Render'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Called each time the screen is rendering, both in the game screen and in the interface.');
this.setHelpUrl('');
}
};
const events_onGUIScreenRender = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('On Gui Screen Render'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Called each time the screen is rendering, but only in the interface (not in game)');
this.setHelpUrl('');
}
};
const events_onJoinWorld = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabel('when HOST joins world'));
this.appendStatementInput('CODE')
.setAlign(Blockly.inputs.Align.CENTRE)
.appendField('do');
this.setColour(55);
this.setTooltip('Is executed when player joins a world, runs once.');
this.setHelpUrl('');
}
};
// Now define all blocks after the block definitions
Blockly.common.defineBlocks({
events_onModLoads: events_onModLoads,
events_onClientTick: events_onClientTick,
events_onClientFrame: events_onClientFrame,
//events_onKeyPressed: events_onKeyPressed,
//events_onKeyReleased: events_onKeyReleased,
events_onJoinWorld: events_onJoinWorld
});
// JavaScript generators for each event block
javascript.javascriptGenerator.forBlock['events_onJoinWorld'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("serverstart", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onscreenRender'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("screenRender", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onGUIScreenRender'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("GUIScreenRender", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_oninGameScreenRender'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("inGameScreenRender", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onscreenChange'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("screenChange", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onopenModManager'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("openModManager", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onopenLANSharing'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("openLANSharing", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onModLoads'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("load", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onClientTick'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("update", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onClientFrame'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const code = `
ModAPI.addEventListener("frame", () => {
${statement} })`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onKeyPressed'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const keyCode = block.getFieldValue('KEYCODE');
const code = `
window.addEventListener("keydown", event => {
${keyCode !== ""?"if (event.keyCode === '"+keyCode+"') {":""}
${statement}
${keyCode !== ""?"}":""}`;
return code;
}
javascript.javascriptGenerator.forBlock['events_onKeyReleased'] = function(block, generator) {
const statement = generator.statementToCode(block, 'CODE');
const keyCode = block.getFieldValue('KEYCODE');
const code = `
window.addEventListener("keyup", event => {
${keyCode !== ""?"if (event.keyCode === '"+keyCode+"') {":""}
${statement}
${keyCode !== ""?"}":""}`;
return code;
}
@@ -0,0 +1,274 @@
const itemstack_getitem = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get itemstack item');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets the Item of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_getitem: itemstack_getitem });
javascript.javascriptGenerator.forBlock['itemstack_getitem'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$item`;
return [code, javascript.Order.NONE];
}
const itemstack_stacksize = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get itemstack stack size');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Gets the stacksize of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_stacksize: itemstack_stacksize });
javascript.javascriptGenerator.forBlock['itemstack_stacksize'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$stackSize`;
return [code, javascript.Order.NONE];
}
const itemstack_setstacksize = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set itemstack stack size');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the stacksize of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_setstacksize: itemstack_setstacksize });
javascript.javascriptGenerator.forBlock['itemstack_setstacksize'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const value_num = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$stackSize = (${value_num});`;
return code;
}
const itemstack_meta = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get itemstack metadata');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Gets the metadata integer of an ItemStack (itemDamage)');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_meta: itemstack_meta });
javascript.javascriptGenerator.forBlock['itemstack_meta'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$itemDamage`;
return [code, javascript.Order.NONE];
}
const itemstack_setmeta = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set itemstack metadata');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the metadata of an ItemStack (itemDamage)');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_setmeta: itemstack_setmeta });
javascript.javascriptGenerator.forBlock['itemstack_setmeta'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$itemDamage = (${value_value});`;
return code;
}
const itemstack_displayname = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get itemstack display name');
this.setInputsInline(true)
this.setOutput(true, 'String');
this.setTooltip('Gets the display name of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_displayname: itemstack_displayname });
javascript.javascriptGenerator.forBlock['itemstack_displayname'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const code = `ModAPI.util.ustr((${value_itemstack}).$getDisplayName())`;
return [code, javascript.Order.NONE];
}
const itemstack_setdisplayname = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set itemstack display name');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('String')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the display name of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_setdisplayname: itemstack_setdisplayname });
javascript.javascriptGenerator.forBlock['itemstack_setdisplayname'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$setStackDisplayName(ModAPI.util.str(${value_value}));`;
return code;
}
const itemstack_enchant = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('enchant itemstack');
this.appendDummyInput('ENCHANTMENT')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('with enchantment')
.appendField(new Blockly.FieldDropdown([
["protection", "protection"],
["fireProtection", "fireProtection"],
["featherFalling", "featherFalling"],
["blastProtection", "blastProtection"],
["projectileProtection", "projectileProtection"],
["respiration", "respiration"],
["aquaAffinity", "aquaAffinity"],
["thorns", "thorns"],
["depthStrider", "depthStrider"],
["sharpness", "sharpness"],
["smite", "smite"],
["baneOfArthropods", "baneOfArthropods"],
["knockback", "knockback"],
["fireAspect", "fireAspect"],
["looting", "looting"],
["efficiency", "efficiency"],
["silkTouch", "silkTouch"],
["unbreaking", "unbreaking"],
["fortune", "fortune"],
["power", "power"],
["punch", "punch"],
["flame", "flame"],
["infinity", "infinity"],
["luckOfTheSea", "luckOfTheSea"],
["lure", "lure"]
]), 'ENCHANTMENT');
this.appendValueInput('LEVEL')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('at level');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Adds an enchantment to an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_enchant: itemstack_enchant });
javascript.javascriptGenerator.forBlock['itemstack_enchant'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const dropdown_enchantment = this.getFieldValue('ENCHANTMENT');
const value_level = javascript.javascriptGenerator.valueToCode(this, 'LEVEL', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$addEnchantment(ModAPI.enchantments["${dropdown_enchantment}"].getRef(), (${value_level}));`;
return code;
}
const itemstack_repaircost = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get itemstack repair cost');
this.setInputsInline(true)
this.setOutput(true, 'Number');
this.setTooltip('Gets the repair cost of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_repaircost: itemstack_repaircost });
javascript.javascriptGenerator.forBlock['itemstack_repaircost'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$getRepairCost()`;
return [code, javascript.Order.NONE];
}
const itemstack_setrepaircost = {
init: function () {
this.appendValueInput('ITEMSTACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('set itemstack repair cost');
this.appendValueInput('VALUE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets the repair cost of an ItemStack');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/ItemStack.html');
this.setColour(165);
}
};
Blockly.common.defineBlocks({ itemstack_setrepaircost: itemstack_setrepaircost });
javascript.javascriptGenerator.forBlock['itemstack_setrepaircost'] = function () {
const value_itemstack = javascript.javascriptGenerator.valueToCode(this, 'ITEMSTACK', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `(${value_itemstack}).$setRepairCost(${value_value});`;
return code;
}
+211
View File
@@ -0,0 +1,211 @@
const items_creativetab = {
init: function () {
this.appendDummyInput('TAB')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('Set item creative tab to')
.appendField(new Blockly.FieldDropdown([
["tabBlock", "tabBlock"],
["tabDecorations", "tabDecorations"],
["tabRedstone", "tabRedstone"],
["tabTransport", "tabTransport"],
["tabMisc", "tabMisc"],
["tabAllSearch", "tabAllSearch"],
["tabFood", "tabFood"],
["tabTools", "tabTools"],
["tabCombat", "tabCombat"],
["tabBrewing", "tabBrewing"],
["tabMaterials", "tabMaterials"],
["tabInventory", "tabInventory"]
]), 'TAB');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Set the creative tab of the item');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ items_creativetab: items_creativetab });
javascript.javascriptGenerator.forBlock['items_creativetab'] = function () {
let dropdown_tab = this.getFieldValue('TAB');
if (flags.target === "1_12") {
dropdown_tab = dropdown_tab.replace("tab", "").toUpperCase();
}
const code = `this.$setCreativeTab(ModAPI.reflect.getClassById("net.minecraft.creativetab.CreativeTabs").staticVariables.${dropdown_tab});`;
return code;
}
const items_item = {
init: function () {
this.appendDummyInput('ITEM')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('item')
.appendField(new Blockly.FieldMinecraftItemInput(false, true), 'ITEM');
this.setInputsInline(true);
this.setOutput(true, null);
this.setTooltip('Returns an Item instance (for comparisons)');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ items_item: items_item });
javascript.javascriptGenerator.forBlock['items_item'] = function () {
const item_primitive = this.getFieldValue('ITEM');
const object = {
type: item_primitive.split("/")[0],
id: item_primitive.split("/")[1].split("@")[0]
}
if (object.type === "item") {
return [`(ModAPI.items["${object.id}"]?.getRef() || null)`, javascript.Order.NONE]
} else {
return [`ModAPI.util.getItemFromBlock(ModAPI.blocks["${object.id}"]?.getRef() || null)`, javascript.Order.NONE]
}
}
const items_setmaxstacksize = {
init: function () {
this.appendValueInput('SIZE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Number')
.appendField('set max stack size to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets an items max stack size.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ items_setmaxstacksize: items_setmaxstacksize });
javascript.javascriptGenerator.forBlock['items_setmaxstacksize'] = function () {
const value_size = javascript.javascriptGenerator.valueToCode(this, 'SIZE', javascript.Order.ATOMIC);
const code = `this.$maxStackSize = (${value_size});`;
return code;
}
registerHandler("ItemConstructor", "item constructor", {}, function () {
this.setTooltip('Runs when the item type is initialised.\nNo return value expected.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemRightClick", "item right click", {
"ITEM_STACK": "itemstack",
"WORLD": "world",
"PLAYER": "player"
}, function () {
this.setTooltip('1.8: Runs when the item is right-clicked.\nThe itemstack argument is expected as a return value.\n\n1.12: Expects ActionResult containing the ItemStack. If \'SUCCESS\' is the mode selected, the stack size is automatically decreased. If no return value, UseItemOnRightClick determines wether or not SUCCESS or PASS is the enabled mode.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemUsed", "item used", {
"ITEM_STACK": "itemstack",
"WORLD": "world",
"PLAYER": "player"
}, function () {
this.setTooltip('Runs when the item is used. Not called when the player stops using the item early.\nThe itemstack argument is expected as a return value.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemTicked", "item ticked", {
"ITEM_STACK": "itemstack",
"WORLD": "world",
"PLAYER": "player",
"SLOT_INDEX": "slot index",
"IS_ITEM_HELD": "item held?"
}, function () {
this.setTooltip('Runs every tick when the item is in a player\'s inventory.\nThe itemstack argument is expected as a return value.\n`slot index` is a number representing inventory location, `is held` is a boolean.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemBlockUse", "item block use", {
"ITEM_STACK": "itemstack",
"PLAYER": "player",
"WORLD": "world",
"BLOCKPOS": "blockpos",
}, function () {
this.setTooltip('1.8: Runs when the item is used on a block.\nA boolean is expected as a return value.\n\n1.12: EnumActionResult Expected as return value.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemCrafted", "item crafted", {
"ITEM_STACK": "itemstack",
"WORLD": "world",
"PLAYER": "player",
}, function () {
this.setTooltip('Runs when the item is crafted or smelted.\nNo return value is expected.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemBlockBroken", "item block broken", {
"ITEM_STACK": "itemstack",
"WORLD": "world",
"BLOCK": "block",
"BLOCKPOS": "blockpos",
"ENTITY": "entity",
}, function () {
this.setTooltip('Runs when a block is broken with this item.\nA boolean is expected as a return value.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemGetAttributes", "item get attributes", { "ATTRIBUTEMAP": "attribute map" }, function () {
this.setTooltip('Runs when an item\'s attributes are calculated.\nAn AttributeMap is expected as a return value, but is automatically returned.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
registerHandler("ItemGetEfficiency", "item get efficiency vs block", { "ITEMSTACK": "itemstack", "BLOCK": "block" }, function () {
this.setTooltip('Runs to get the item\'s strength when breaking a block.\nA number is expected as an output. Default response is 1.0');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/item/Item.html');
this.setColour(225);
});
const items_get_applicable_blocks = {
init: function () {
this.appendDummyInput('GROUP')
.appendField('get applicable blocks of')
.appendField(new Blockly.FieldDropdown([
['ItemAxe', 'ItemAxe'],
['ItemPickaxe', 'ItemPickaxe'],
['ItemSpade', 'ItemSpade']
]), 'GROUP');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Returns an array of blocks that the item group is effective on.');
this.setHelpUrl('');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ items_get_applicable_blocks: items_get_applicable_blocks });
javascript.javascriptGenerator.forBlock['items_get_applicable_blocks'] = function () {
const dropdown_group = this.getFieldValue('GROUP');
const code = `(ModAPI.reflect.getClassByName("${dropdown_group}").staticVariables.EFFECTIVE_ON?.$backingMap?.$elementData?.data?.filter(x => !!x)?.map(x => x.$key) || [])`;
return [code, javascript.Order.NONE];
}
const items_currentitem = {
init: function () {
this.appendDummyInput('ITEM')
.setAlign(Blockly.inputs.Align.LEFT)
.appendField('current item')
this.setInputsInline(true);
this.setOutput(true, null);
this.setTooltip('The current Item that the handler is executing on.');
this.setHelpUrl('');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ items_currentitem: items_currentitem });
javascript.javascriptGenerator.forBlock['items_currentitem'] = function () {
return [`$$CustomItem`, javascript.Order.NONE];
}
+277
View File
@@ -0,0 +1,277 @@
const PLAYER_CAPABILITIES_BOOLEAN = [
["can fly", "allowFlying"],
["is flying", "isFlying"],
["disable damage", "disableDamage"],
["is in creative", "isCreativeMode"],
["is in spectator", "isSpectatorMode"],
["allow edit", "allowEdit"],
["is invulnerable", "invulnerable"],
];
const player_get_capability_boolean = {
init: function () {
this.appendDummyInput('CAPABILITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(PLAYER_CAPABILITIES_BOOLEAN), 'CAPABILITY');
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('capability of player');
this.setInputsInline(true)
this.setOutput(true, "Boolean");
this.setTooltip('Gets a capability of a player.');
this.setHelpUrl('https://eaglerforge.github.io/apidocs/globals/PlayerCapabilities.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_capability_boolean: player_get_capability_boolean });
javascript.javascriptGenerator.forBlock['player_get_capability_boolean'] = function () {
const dropdown_capability = this.getFieldValue('CAPABILITY');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
let code;
if (dropdown_capability === invulnerable) {
code = `Boolean((${value_player}).$invulnerable)`;
} else if (dropdown_capability === isSpectatorMode) {
code = `Boolean((${value_player}).$isSpectator()`;
} else {
code = `Boolean((${value_player}).$capabilities["${dropdown_capability}"])`;
}
return [code, javascript.Order.NONE];
}
const PLAYER_CAPABILITIES_NUMBER = [
["walk speed", "walkSpeed0"],
["fly speed ", "flySpeed0"],
];
const player_get_capability_number = {
init: function () {
this.appendDummyInput('CAPABILITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(PLAYER_CAPABILITIES_NUMBER), 'CAPABILITY');
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('capability of player');
this.setInputsInline(true)
this.setOutput(true, "Number");
this.setTooltip('Gets a capability of a player.');
this.setHelpUrl('https://eaglerforge.github.io/apidocs/globals/PlayerCapabilities.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_capability_number: player_get_capability_number });
javascript.javascriptGenerator.forBlock['player_get_capability_number'] = function () {
const dropdown_capability = this.getFieldValue('CAPABILITY');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
const code = `(${value_player}).$capabilities["$${dropdown_capability}"]`;
return [code, javascript.Order.NONE];
}
const PLAYER_FOOD_STATS = [
["food exhaustion level", "foodExhaustionLevel"],
["food level ", "foodLevel0"],
["food saturation level", "foodSaturationLevel"],
];
const player_get_food_stats = {
init: function () {
this.appendDummyInput('STAT')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField( new Blockly.FieldDropdown(PLAYER_FOOD_STATS), 'STAT');
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of player');
this.setInputsInline(true)
this.setOutput(true, "Number");
this.setTooltip('Gets the food stats of a player.');
this.setHelpUrl('https://eaglerforge.github.io/apidocs/globals/FoodStatsData.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_food_stats: player_get_food_stats });
javascript.javascriptGenerator.forBlock['player_get_food_stats'] = function () {
const dropdown_stat = this.getFieldValue('STAT');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
const code = `(${value_player}).$foodStats["$${dropdown_stat}"]`;
return [code, javascript.Order.NONE];
}
const PLAYER_XP_STATS = [
["experience", "experience"],
["experience level", "experienceLevel"],
["total experience", "experienceTotal"],
["experience points", "experiencePoints"]
];
const player_get_xp_stats = {
init: function () {
this.appendDummyInput('STAT')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField( new Blockly.FieldDropdown(PLAYER_XP_STATS), 'STAT');
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of player');
this.setInputsInline(true)
this.setOutput(true, "Number");
this.setTooltip('Gets the experience stats of a player.');
this.setHelpUrl('https://eaglerforge.github.io/apidocs/globals/FoodStatsData.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_xp_stats: player_get_xp_stats });
javascript.javascriptGenerator.forBlock['player_get_xp_stats'] = function () {
const dropdown_stat = this.getFieldValue('STAT');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
let code;
if (dropdown_stat === "experiencePoints") {
code = `${value_player}.$getExperiencePoints()`;
} else {
code = `${value_player}.` + "$" + `${dropdown_stat}`;
}
return [code, javascript.Order.NONE];
}
const PLAYER_ITEM_TYPE = [
["ItemStack", "ItemStack"],
["Item", "Item"],
];
const player_get_item_hand = {
init: function () {
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get held item of player');
this.appendDummyInput()
.appendField('as');
this.appendDummyInput('TYPE')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(PLAYER_ITEM_TYPE), 'TYPE');
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip('Gets the item in the hand of a player.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_item_hand: player_get_item_hand });
javascript.javascriptGenerator.forBlock['player_get_item_hand'] = function () {
const dropdown_item_type = this.getFieldValue('TYPE');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
let code;
if (dropdown_item_type === "Item") {
code = `(${value_player}).$getHeldItem()?(${value_player}).$getHeldItem().$item:null`;
} else {
code = `(${value_player}).$getHeldItem()`;
}
return [code, javascript.Order.NONE];
}
const player_get_current_item_pos = {
init: function () {
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get held item index of player');
this.setInputsInline(true);
this.setOutput(true, "Number");
this.setTooltip('Gets the selected item index of a player.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_current_item_pos: player_get_current_item_pos });
javascript.javascriptGenerator.forBlock['player_get_current_item_pos'] = function () {
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
const code = `(${value_player}.$inventory.$currentItem+1)`;
return [code, javascript.Order.NONE];
}
const PLAYER_INVENTORY = [
["get main inventory", "main"],
["get armor inventory", "armor"],
["get enderchest inventory", "enderchest"],
];
const player_get_player_inventory = {
init: function () {
this.appendDummyInput('TYPE')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField(new Blockly.FieldDropdown(PLAYER_INVENTORY), 'TYPE');
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('of player');
this.appendDummyInput()
.appendField('as list');
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip('Gets the inventory of a player as list.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_player_inventory: player_get_player_inventory });
javascript.javascriptGenerator.forBlock['player_get_player_inventory'] = function () {
const dropdown_inventory = this.getFieldValue('TYPE');
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
let code;
if (dropdown_inventory === "main") {
code = `(${value_player}).$inventory.$mainInventory.data`;
} else if (dropdown_inventory === "armor") {
code = `(${value_player}).$inventory.$armorInventory.data`;
} else {
code = `(${value_player}).$getInventoryEnderChest().$inventoryContents.data`
}
return [code, javascript.Order.NONE];
}
const player_is_entity_player = {
init: function () {
this.appendValueInput('ENTITY')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('is entity');
this.appendDummyInput()
.appendField('a player');
this.setInputsInline(true);
this.setOutput(true, "Boolean");
this.setTooltip('Checks if an entity is a player or not');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_is_entity_player: player_is_entity_player });
javascript.javascriptGenerator.forBlock['player_is_entity_player'] = function () {
const value_entity = javascript.javascriptGenerator.valueToCode(this, 'ENTITY', javascript.Order.ATOMIC);
const code = `Boolean(Minecraft.$thePlayer.$isPlayer())`;
return [code, javascript.Order.NONE];
}
const player_get_player_name = {
init: function () {
this.appendValueInput('PLAYER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get the name of player');
this.setInputsInline(true);
this.setOutput(true, "String");
this.setTooltip('Gets the name a player.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(30);
}
};
Blockly.common.defineBlocks({ player_get_player_name: player_get_player_name });
javascript.javascriptGenerator.forBlock['player_get_player_name'] = function () {
const value_player = javascript.javascriptGenerator.valueToCode(this, 'PLAYER', javascript.Order.ATOMIC);
const code = `ModAPI.util.ustr((${value_player}).$getName())`;
return [code, javascript.Order.NONE];
}
@@ -0,0 +1,73 @@
const local_this = {
init: function () {
this.appendDummyInput('NAME')
.appendField('this');
this.setInputsInline(false)
this.setOutput(true, null);
this.setTooltip('The object the handler is running on.');
this.setHelpUrl('');
this.setColour(330);
}
};
Blockly.common.defineBlocks({ local_this: local_this });
javascript.javascriptGenerator.forBlock['local_this'] = function () {
return 'this';
}
const proc_return = {
init: function () {
this.appendDummyInput('NAME')
.appendField('return');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(false, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ proc_return: proc_return });
javascript.javascriptGenerator.forBlock['proc_return'] = function () {
return 'return;';
}
const proc_returnvalue = {
init: function () {
this.appendValueInput('VALUE')
.appendField('return value');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(false, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ proc_returnvalue: proc_returnvalue });
javascript.javascriptGenerator.forBlock['proc_returnvalue'] = function () {
const value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = 'return ' + value + ';';
return code;
}
const proc_returnbool = {
init: function () {
this.appendValueInput('VALUE').setCheck('Boolean')
.appendField('return boolean');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(false, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ proc_returnbool: proc_returnbool });
javascript.javascriptGenerator.forBlock['proc_returnbool'] = function () {
const value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `return (${value}) ? 1 : 0;`;
return code;
}
@@ -0,0 +1,34 @@
const attributes_set = {
libs: ["attribute_map_set"],
init: function () {
this.appendValueInput('MAP')
.appendField('set attribute map');
this.appendDummyInput('KEY')
.appendField('value')
.appendField(new Blockly.FieldDropdown([
['max health', "generic.maxHealth"],
['knockback resistance', "generic.knockbackResistance"],
['movement speed', "generic.movementSpeed"],
['attack damage', "generic.attackDamage"]
]), 'KEY');
this.appendValueInput('VALUE')
.setCheck('Number')
.appendField('to');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Set an attribute\'s value on the specified map.');
this.setHelpUrl('');
this.setColour(225);
}
};
Blockly.common.defineBlocks({ attributes_set: attributes_set });
javascript.javascriptGenerator.forBlock['attributes_set'] = function () {
const value_map = javascript.javascriptGenerator.valueToCode(this, 'MAP', javascript.Order.ATOMIC);
const dropdown_key = this.getFieldValue('KEY');
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `efb2__attrMapSet(${value_map}, "${dropdown_key}", ${value_value});`;
return code;
}
+211
View File
@@ -0,0 +1,211 @@
const logic_a_or_b = {
init: function () {
this.appendValueInput('A')
.setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput('B')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('otherwise');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Uses the first value if it exists, otherwise uses the second value. (JavaScript ?? operator)');
this.setHelpUrl('');
this.setColour(210);
}
};
Blockly.common.defineBlocks({ logic_a_or_b: logic_a_or_b });
javascript.javascriptGenerator.forBlock['logic_a_or_b'] = function () {
const value_a = javascript.javascriptGenerator.valueToCode(this, 'A', javascript.Order.ATOMIC);
const value_b = javascript.javascriptGenerator.valueToCode(this, 'B', javascript.Order.ATOMIC);
const code = `((${value_a})??(${value_b}))`;
return [code, javascript.Order.NONE];
}
const proc_wait = {
init: function () {
this.appendValueInput('VALUE')
.appendField('synchronous wait');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Waits set amount of time. Synchronous: (no frames or otehr code can be run while this is waiting)');
this.setHelpUrl('');
this.setColour(255);
}
};
Blockly.common.defineBlocks({ proc_wait: proc_wait });
javascript.javascriptGenerator.forBlock['proc_wait'] = function () {
const value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `
var start = Date.now();
var current = start;
while (current - start < (${value} * 1000)) {
current = Date.now();
};
`;
return code;
}
const comment = {
init: function () {
this.appendDummyInput('VALUE')
.appendField('comment ')
.appendField(new Blockly.FieldTextInput('x'), 'VALUE');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Adds a comment');
this.setHelpUrl('');
this.setColour(255);
}
};
Blockly.common.defineBlocks({ comment: comment });
javascript.javascriptGenerator.forBlock['comment'] = function () {
const value = this.getFieldValue('VALUE');
const code = `
// ${value}
`;
return code;
}
const proc_asyncrun = {
init: function () {
this.appendValueInput('DELAY')
.setCheck('Number')
.appendField('in');
this.appendDummyInput('NIL')
.appendField('seconds, run:');
this.appendStatementInput('CODE');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Asynchronous wait. Runs code in a set amount of time. Other code can still run.');
this.setHelpUrl('');
this.setColour(255);
}
};
Blockly.common.defineBlocks({ proc_asyncrun: proc_asyncrun });
javascript.javascriptGenerator.forBlock['proc_asyncrun'] = function () {
// TODO: change Order.ATOMIC to the correct operator precedence strength
const value_delay = javascript.javascriptGenerator.valueToCode(this, 'DELAY', javascript.Order.ATOMIC);
const statement_code = javascript.javascriptGenerator.statementToCode(this, 'CODE');
const code = `setTimeout(()=>{
ModAPI.promisify(()=>{
${statement_code};
})();
}, ${parseFloat(value_delay) * 1000});`;
return code;
}
const list_includes = {
init: function () {
this.appendValueInput('LIST')
.setCheck('Array')
.appendField('list');
this.appendValueInput('VALUE')
.appendField('includes');
this.setInputsInline(true)
this.setOutput(true, 'Boolean');
this.setTooltip('Checks if a list contains an item.');
this.setHelpUrl('');
this.setColour(255);
}
};
Blockly.common.defineBlocks({ list_includes: list_includes });
javascript.javascriptGenerator.forBlock['list_includes'] = function () {
const value_list = javascript.javascriptGenerator.valueToCode(this, 'LIST', javascript.Order.ATOMIC);
const value_value = javascript.javascriptGenerator.valueToCode(this, 'VALUE', javascript.Order.ATOMIC);
const code = `${value_list}.includes(${value_value})`;
return [code, javascript.Order.NONE];
}
const globals_set = {
init: function () {
this.appendDummyInput('VAR')
.appendField('global ')
.appendField(new Blockly.FieldTextInput('x'), 'VAR');
this.appendValueInput('VAL')
.appendField('=');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Sets a global variable.');
this.setHelpUrl('');
this.setColour(150);
}
};
Blockly.common.defineBlocks({ globals_set: globals_set });
javascript.javascriptGenerator.forBlock['globals_set'] = function () {
const text_var = this.getFieldValue('VAR');
const value_val = javascript.javascriptGenerator.valueToCode(this, 'VAL', javascript.Order.ATOMIC);
const code = `$$scoped_efb_globals["${text_var}"] = ${value_val};`;
return code;
}
const globals_get = {
init: function () {
this.appendDummyInput('VAR')
.appendField('global ')
.appendField(new Blockly.FieldTextInput('x'), 'VAR');
this.setInputsInline(true)
this.setOutput(true, null);
this.setTooltip('Gets a global variable.');
this.setHelpUrl('');
this.setColour(150);
}
};
Blockly.common.defineBlocks({ globals_get: globals_get });
javascript.javascriptGenerator.forBlock['globals_get'] = function () {
const text_var = this.getFieldValue('VAR');
const code = `$$scoped_efb_globals["${text_var}"]`;
return [code, javascript.Order.NONE];
}
const globals_delete = {
init: function () {
this.appendDummyInput('VAR')
.appendField('delete global')
.appendField(new Blockly.FieldTextInput('x'), 'VAR');
this.setInputsInline(true)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Deletes a global variable.');
this.setHelpUrl('');
this.setColour(150);
}
};
Blockly.common.defineBlocks({ globals_delete: globals_delete });
javascript.javascriptGenerator.forBlock['globals_delete'] = function () {
const text_var = this.getFieldValue('VAR');
const code = `delete $$scoped_efb_globals["${text_var}"];`;
return code;
}
const globals_exists = {
init: function () {
this.appendDummyInput('VAR')
.appendField('global exists')
.appendField(new Blockly.FieldTextInput('x'), 'VAR');
this.setInputsInline(true)
this.setOutput(true, 'Boolean');
this.setTooltip('Checks if a global is defined.');
this.setHelpUrl('');
this.setColour(150);
}
};
Blockly.common.defineBlocks({ globals_exists: globals_exists });
javascript.javascriptGenerator.forBlock['globals_exists'] = function () {
const text_var = this.getFieldValue('VAR');
const code = `("${text_var}" in $$scoped_efb_globals)`;
return [code, javascript.Order.NONE];
}
+91
View File
@@ -0,0 +1,91 @@
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('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/util/Vec3.html');
this.setColour(270);
}
};
Blockly.common.defineBlocks({ vec3_getxyz: vec3_getxyz });
javascript.javascriptGenerator.forBlock['vec3_getxyz'] = function () {
const dropdown_tab = this.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('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/util/Vec3.html');
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];
}
const vec3_dist = {
init: function () {
this.appendValueInput('X')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('distance from Vec3');
this.appendValueInput('Y')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('to Vec3');
this.setInputsInline(true)
this.setOutput(true, "Number");
this.setTooltip('Calculates the distance between two Vec3\'s.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/util/Vec3.html');
this.setColour(270);
},
};
Blockly.common.defineBlocks({ vec3_dist: vec3_dist });
javascript.javascriptGenerator.forBlock['vec3_dist'] = function () {
const value_x = javascript.javascriptGenerator.valueToCode(this, 'X', javascript.Order.ATOMIC);
const value_y = javascript.javascriptGenerator.valueToCode(this, 'Y', javascript.Order.ATOMIC);
const code = `(${value_x}).$distanceTo(${value_y})`;
return [code, javascript.Order.NONE];
}
+194
View File
@@ -0,0 +1,194 @@
const world_explosion = {
init: function () {
this.appendValueInput('WORLD')
.appendField('Spawn explosion in world:');
this.appendValueInput('POS')
.appendField('BlockPos:');
this.appendValueInput('STRENGTH')
.setCheck('Number')
.appendField('Strength:');
this.appendValueInput('FIRE')
.setCheck('Boolean')
.appendField('Fire:');
this.appendValueInput('SMOKE')
.setCheck('Boolean')
.appendField('Break Blocks:');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('');
this.setHelpUrl('');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ world_explosion: world_explosion });
javascript.javascriptGenerator.forBlock['world_explosion'] = function () {
const value_world = javascript.javascriptGenerator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
const value_pos = javascript.javascriptGenerator.valueToCode(this, 'POS', javascript.Order.ATOMIC);
const value_strength = javascript.javascriptGenerator.valueToCode(this, 'STRENGTH', javascript.Order.ATOMIC);
const value_fire = javascript.javascriptGenerator.valueToCode(this, 'FIRE', javascript.Order.ATOMIC);
const value_smoke = javascript.javascriptGenerator.valueToCode(this, 'SMOKE', javascript.Order.ATOMIC);
const code = `${value_world}.$newExplosion(null, ${value_pos}.$x, ${value_pos}.$y, ${value_pos}.$z, ${value_strength}, (${value_fire} ? 1 : 0), (${value_smoke} ? 1 : 0));`;
return code;
}
const world_command = {
init: function () {
this.appendValueInput('WORLD')
.appendField('Execute command in world');
this.appendValueInput('POS')
.appendField('BlockPos:');
this.appendValueInput('CMD')
.setCheck('String')
.appendField('Command:');
this.appendValueInput('FEEDBACK')
.setCheck('Boolean')
.appendField('Feedback:');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('NOTICE: @selectors (probably) do NOT work');
this.setHelpUrl('https://legacy.mcstacker.net/mcstacker1.10.php');
this.setColour(195);
},
libs: ["execute_command"]
};
Blockly.common.defineBlocks({ world_command: world_command });
javascript.javascriptGenerator.forBlock['world_command'] = function () {
const value_world = javascript.javascriptGenerator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
const value_pos = javascript.javascriptGenerator.valueToCode(this, 'POS', javascript.Order.ATOMIC);
const value_cmd = javascript.javascriptGenerator.valueToCode(this, 'CMD', javascript.Order.ATOMIC);
const value_feedback = javascript.javascriptGenerator.valueToCode(this, 'FEEDBACK', javascript.Order.ATOMIC);
const code = `efb2__executeCommand(${value_world}, ${value_pos}, ${value_cmd}, ${value_feedback});`;
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 = javascript.javascriptGenerator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
const code = `(${value_world}).$loadedEntityList.$toArray1().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(this, 'WORLD', javascript.Order.ATOMIC);
const code = `(${value_world}).$playerEntities.$toArray1().data`;
return [code, javascript.Order.NONE];
}
const world_execute_command_as_entity = {
libs: ["execute_command_as"],
init: function () {
this.appendValueInput('MESSAGE')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('String')
.appendField('execute command');
this.appendValueInput('SENDER')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('as')
.appendField(new Blockly.FieldDropdown([
['command sender', 'command_sender'],
['entity', 'entity']
]), 'TYPE');
this.appendValueInput('FEEDBACK')
.setAlign(Blockly.inputs.Align.RIGHT)
.setCheck('Boolean')
.appendField('feedback');
this.setInputsInline(false)
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setTooltip('Executes a command as a command sender or entity.');
this.setHelpUrl('https://legacy.mcstacker.net/mcstacker1.10.php');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ world_execute_command_as_entity: world_execute_command_as_entity });
javascript.javascriptGenerator.forBlock['world_execute_command_as_entity'] = function () {
const value_message = javascript.javascriptGenerator.valueToCode(this, 'MESSAGE', javascript.Order.ATOMIC);
const value_sender = javascript.javascriptGenerator.valueToCode(this, 'SENDER', javascript.Order.ATOMIC);
const value_feedback = javascript.javascriptGenerator.valueToCode(this, 'FEEDBACK', javascript.Order.ATOMIC);
const code = `efb2__executeCommandAs(${value_sender}, ${value_message}, ${value_feedback});`;
return code;
}
const world_get_player_by_name = {
init: function () {
this.appendValueInput('NAME')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('get player by name')
.setCheck('String');
this.appendValueInput('WORLD')
.setAlign(Blockly.inputs.Align.RIGHT)
.appendField('in world');
this.setInputsInline(true);
this.setOutput(true);
this.setTooltip('Gets a player by his name. Can be null.');
this.setHelpUrl('https://nurmarvin.github.io/Minecraft-1.8-JavaDocs/net/minecraft/entity/player/EntityPlayer.html');
this.setColour(195);
}
};
Blockly.common.defineBlocks({ world_get_player_by_name: world_get_player_by_name });
javascript.javascriptGenerator.forBlock['world_get_player_by_name'] = function () {
const value_name = javascript.javascriptGenerator.valueToCode(this, 'NAME', javascript.Order.ATOMIC);
const world = javascript.javascriptGenerator.valueToCode(this, 'WORLD', javascript.Order.ATOMIC);
const code = `(${world}).$playerEntities.$array1.data.find((player) => player && player.$getName() && ModAPI.util.ustr(player.$getName()) === ${value_name})`;
return [code, javascript.Order.NONE];
}