7 lines
No EOL
10 KiB
JSON
7 lines
No EOL
10 KiB
JSON
{
|
|
"_fv": 57,
|
|
"_type": "procedure",
|
|
"definition": {
|
|
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable type=\"Number\" id=\"rx\">rx</variable><variable type=\"Number\" id=\"ry\">ry</variable></variables><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">player_ticks</field><next><block type=\"java_code\"><field name=\"CODE\">float recoilx = ((float)(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble(\"recoilx\"));&#10;float recoily = ((float)(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble(\"recoily\"));</field><next><block type=\"controls_if\"><mutation elseif=\"1\" else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_binary_ops\"><field name=\"OP\">AND</field><value name=\"A\"><block type=\"logic_binary_ops\"><field name=\"OP\">AND</field><value name=\"A\"><block type=\"entity_issneaking\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_binary_ops\"><field name=\"OP\">GTE</field><value name=\"A\"><block type=\"entity_size_height\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></value></block></value><value name=\"B\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"entity_haspotioneffect\"><field name=\"potion\">CUSTOM:Prone</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:rx</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">1.2</field></block></value><next><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:ry</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">0.8</field></block></value></block></next></block></statement><value name=\"IF1\"><block type=\"entity_haspotioneffect\"><field name=\"potion\">CUSTOM:Prone</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><statement name=\"DO1\"><block type=\"controls_if\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"item_nbt_num_get\"><value name=\"item\"><block type=\"entity_iteminhand\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">bipod</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:rx</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">5</field></block></value><next><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:ry</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">0.1</field></block></value></block></next></block></statement><statement name=\"ELSE\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:rx</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">1.4</field></block></value><next><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:ry</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">0.7</field></block></value></block></next></block></statement></block></statement><statement name=\"ELSE\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:rx</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value><next><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"false\" has_entity=\"false\"></mutation><field name=\"VAR\">local:ry</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></next></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"variables_get_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"VAL\"><block type=\"math_dual_ops\"><field name=\"OP\">ADD</field><value name=\"A\"><block type=\"variables_get_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0.01</field></block></value></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GTE</field><value name=\"A\"><block type=\"variables_get_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></value><statement name=\"DO0\"><block type=\"variables_set_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"VAL\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></statement><next><block type=\"entity_set_rotation\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"yaw\"><block type=\"entity_direction\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"pitch\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"entity_pitch\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_dual_ops\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><block type=\"math_number\"><field name=\"NUM\">0.1</field></block></value><value name=\"B\"><block type=\"math_dual_ops\" collapsed=\"true\"><field name=\"OP\">ADD</field><value name=\"A\"><block type=\"math_singular_ops\"><field name=\"OP\">SIN</field><value name=\"NUM\"><block type=\"math_dual_ops\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><block type=\"math_dual_ops\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><block type=\"math_number\"><field name=\"NUM\">2</field></block></value><value name=\"B\"><block type=\"math_java_constants\"><field name=\"CONSTANT\">PI</field></block></value></block></value><value name=\"B\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"variables_get_number\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:recoil</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0.0833333333333</field></block></value></block></value></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0.5</field></block></value></block></value></block></value></block></value><next><block type=\"java_code\"><field name=\"CODE\">double[] recoilTimer = {0};&#10;double totalTime = 100;&#10;int sleepTime = 2;&#10;double recoilDuration = totalTime / sleepTime;&#10;float speed = (float) ((Math.random() * 2) - 1) / recoilx;&#10;Runnable recoilRunnable = () -> {&#10;&#10;while (recoilTimer[0] < recoilDuration) {&#10;&#10;float newPitch = entity.getXRot() - recoily;&#10;float newYaw = entity.getYRot() - speed;&#10;entity.setYRot(newYaw);&#10;entity.setXRot(newPitch);&#10;entity.yRotO = entity.getYRot();&#10;entity.xRotO = entity.getXRot();&#10;recoilTimer[0]++;&#10;try {&#10;Thread.sleep(sleepTime);&#10;} catch (InterruptedException e) {&#10;e.printStackTrace();&#10;}&#10;}&#10;&#10;while (recoilTimer[0] > 0) {&#10;float newPitch = entity.getXRot() + recoily;&#10;float newYaw = entity.getYRot() + speed;&#10;entity.setXRot(newPitch);&#10;entity.setYRot(newYaw);&#10;entity.xRotO = entity.getXRot();&#10;entity.yRotO = entity.getYRot();&#10;recoilTimer[0]--; &#10;try {&#10;Thread.sleep(sleepTime);&#10;} catch (InterruptedException e) {&#10;e.printStackTrace();&#10;}&#10;}&#10;};&#10;Thread recoilThread = new Thread(recoilRunnable);&#10;recoilThread.start();</field></block></next></block></next></block></next></block></next></block></next></block></next></block></xml>"
|
|
}
|
|
} |