├── .gitignore ├── LICENSE ├── README.md └── delta_datapack ├── data ├── delta │ ├── advancements │ │ ├── player_setup.json │ │ ├── post_explosion_trigger.json │ │ └── pre_explosion_trigger.json │ ├── functions │ │ ├── api │ │ │ ├── launch_looking.mcfunction │ │ │ └── launch_xyz.mcfunction │ │ └── internal │ │ │ ├── launch │ │ │ ├── launch_looking.mcfunction │ │ │ └── main.mcfunction │ │ │ ├── math │ │ │ ├── arcsin.mcfunction │ │ │ ├── arcsin_wrapper.mcfunction │ │ │ ├── get_angle.mcfunction │ │ │ ├── get_power_coefficient.mcfunction │ │ │ ├── polar_to_xyz.mcfunction │ │ │ ├── set_power │ │ │ │ ├── crouching.mcfunction │ │ │ │ ├── gliding_swimming_crawling.mcfunction │ │ │ │ └── standing.mcfunction │ │ │ ├── sqrt.mcfunction │ │ │ ├── sqrt_loop.mcfunction │ │ │ ├── xyz_to_polar.mcfunction │ │ │ └── xyz_to_polar_wrapper.mcfunction │ │ │ ├── subtick │ │ │ ├── aec_setup.mcfunction │ │ │ ├── begin_launch_context.mcfunction │ │ │ ├── end_ignore_player.mcfunction │ │ │ ├── end_launch_context.mcfunction │ │ │ ├── get_player_uuid.mcfunction │ │ │ ├── ignore_player.mcfunction │ │ │ ├── post_explosion_trigger.mcfunction │ │ │ ├── pre_explosion_trigger.mcfunction │ │ │ ├── shift_entity.mcfunction │ │ │ └── unshift_entity.mcfunction │ │ │ ├── summon │ │ │ ├── initialize_creepers.mcfunction │ │ │ ├── summon_creepers.mcfunction │ │ │ └── summon_creepers_recursive.mcfunction │ │ │ └── technical │ │ │ ├── initialize_player.mcfunction │ │ │ ├── load.mcfunction │ │ │ └── tick.mcfunction │ ├── item_modifiers │ │ └── set_frame.json │ ├── predicates │ │ └── riding_entity.json │ └── tags │ │ ├── blocks │ │ └── no_collision.json │ │ └── entity_types │ │ └── technical │ │ └── detect_explosion.json └── minecraft │ └── tags │ └── functions │ └── load.json └── pack.mcmeta /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.zip 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 BigPapi13 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOTE: Delta is no longer being maintained! 2 | Check out **Player Motion** instead: https://modrinth.com/datapack/player_motion 3 | 4 | Some kind folk from the MCC Discord server have been keeping up this project for newer versions as I have not had the time, and I recommend using their version instead! 5 | 6 | ------ 7 | 8 | # Delta 9 | Delta is an explosion-based player motion library that uses subtick timing to ensure that only one player is pushed by the blast. 10 | 11 | ## How to use 12 | 13 | ### Launching a player where in a specific direction 14 | 15 | ```mcfunction 16 | scoreboard players set $strength delta.api.launch 10000 17 | function delta:api/launch_looking 18 | ``` 19 | - `$strength` represents motion in blocks/tick, scaled by 10000. A strength of 10000 will push the player at 1 block/tick 20 | - The facing direction in which the function is called is the direction the player will be launched 21 | - Only the player executing the command will receive a motion update 22 | 23 | ### Launching a player with xyz vector 24 | 25 | ```mcfunction 26 | scoreboard players set $x delta.api.launch 500 27 | scoreboard players set $y delta.api.launch 12000 28 | scoreboard players set $z delta.api.launch -3125 29 | function delta:api/launch_xyz 30 | ``` 31 | - `$x`, `$y`, and `$z` are the strength in blocks/tick to launch the player in the x, y, and z directions 32 | - As before, only the player executing the command will be launched 33 | 34 | *Note: These functions are *additive* and will apply motion in addition to existing motion rather than directly setting it to whatever input you send 35 | 36 | ### Launching player via creeper directly 37 | If you'd like more fine-grain control, you can summon the creepers yourself and simply use delta for the subticking with the following format: 38 | ```mcfunction 39 | function delta:internal/subtick/begin_launch_context 40 | summon creeper {Tags:["delta.launcher","delta.init"],Silent:1b,Invulnerable:1b,ExplosionRadius:-1b,Fuse:0s,PersistenceRequired:1b} 41 | scoreboard players operation $temp delta.internal.id = @s delta.internal.id 42 | execute as @e[type=creeper,tag=delta.init] at @s run function delta:internal/summon/initialize_creepers 43 | function delta:internal/subtick/end_launch_context 44 | ``` 45 | *Note: Creepers with an `ExplosionRadius` of -1 are recommended for more powerful pushes, and 1 for weaker ones. The direction of the push is determined by the angle from the creeper's feet to the player's eyes. You can place as many summon commands as you want, as long as they are between the launch context functions, which **must** be ran from a player. Make sure to summon the creeper 1000 blocks *above* where you want it to spawn. 46 | 47 | ## Replicating explosion effects 48 | If you choose to remove the explosion sounds and particles with the resource pack, you can still use those effects with the following API calls: 49 | ```mcfunction 50 | # Creates a single explosion particle 51 | function delta:api/explosion_particle 52 | 53 | # Creates an explosion emitter, which is what creepers and TNT display when they explode 54 | function delta:api/explosion_emitter_particle 55 | 56 | # Plays an explosion sound 57 | function delta:api/explosion_sound 58 | ``` 59 | ### Advanced particles 60 | If you would like to replicate the arguments of the particle command such as the spread and count, Delta provides a rough approximation like so: 61 | `particle minecraft:explosion ~ ~ ~ 3.5 1.2 0.24 0 10` 62 | will instead be written as: 63 | ```mcfunction 64 | scoreboard players set $dx delta.api.particle 350 65 | scoreboard players set $dy delta.api.particle 120 66 | scoreboard players set $dz delta.api.particle 24 67 | scoreboard players set $count delta.api.particle 10 68 | function delta:api/explosion_particle 69 | ``` 70 | *Note: All of the above parameters must be set every time the function is called, otherwise it will default to a single particle. The parameters work for both `explosion` and `explosion_emitter`* 71 | ## Limitations + Known Issues 72 | 73 | While this library is likely the closest we've gotten to perfect player motion manipulation, there are some limitations worth mentioning: 74 | - **Resource pack**: The included resource pack removes explosion particles and sounds, which are then manually reinserted into the game. Any other packs attempting to use normal explosion particles/sounds without using delta api calls will be unable to do so. 75 | - **MSPT Inconsistency**: Even though the motion applied is constant, the rate at which the server and client update may vary, and calling motion updates per tick may result in inconsistencies when these variations become too large. For consistent results, Delta should only be used for instantaneous bursts of motion, and continuous forces should instead rely on riding-based methods or levitation, depending on the context. 76 | - **Explosion Replication**: Delta has to manually detect every source of explosion particles and sounds in the game. Some of these sources are very difficult to detect both efficiently and consistently, so it is possible that an effect may not play when it is supposed to. However, for most sources this should be incredibly rare. 77 | - **Spigot/Paper**: ~~This pack uses negative explosion radius creepers, which do not affect player motion on spigot or paper servers.~~ To make this pack work on paper, Nico314159 has made a fix here: https://github.com/Nico314159/Paper-Negative-Explosions 78 | 79 | If you know any possible solutions or would like to help fixing these problems, please let me know! 80 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/advancements/player_setup.json: -------------------------------------------------------------------------------- 1 | { 2 | "criteria": { 3 | "requirement": { 4 | "trigger": "minecraft:tick" 5 | } 6 | }, 7 | "rewards": { 8 | "function": "delta:internal/technical/initialize_player" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/advancements/post_explosion_trigger.json: -------------------------------------------------------------------------------- 1 | { 2 | "criteria": { 3 | "requirement": { 4 | "trigger": "minecraft:player_hurt_entity", 5 | "conditions": { 6 | "entity": { 7 | "type": "minecraft:bat", 8 | "nbt": "{Tags:[\"delta.post_explosion\"]}" 9 | } 10 | } 11 | } 12 | }, 13 | "rewards": { 14 | "function": "delta:internal/subtick/post_explosion_trigger" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/advancements/pre_explosion_trigger.json: -------------------------------------------------------------------------------- 1 | { 2 | "criteria": { 3 | "requirement": { 4 | "trigger": "minecraft:player_hurt_entity", 5 | "conditions": { 6 | "entity": { 7 | "type": "minecraft:bat", 8 | "nbt": "{Tags:[\"delta.pre_explosion\"]}" 9 | } 10 | } 11 | } 12 | }, 13 | "rewards": { 14 | "function": "delta:internal/subtick/pre_explosion_trigger" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/api/launch_looking.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:api/launch_looking 2 | # Launches the player in the input direction 3 | # 4 | # Inputs: 5 | # execute rotated 6 | # score $strength delta.api.launch <<< Strength to launch in looking direction (scaled up by 10000) 7 | # 8 | # Outputs 9 | # player is launched in the looking direction of the command with the desired strength 10 | 11 | #Flag indicating that players need to be launched, tag the player to be launched 12 | scoreboard players set $function_called delta.internal.dummy 1 13 | tag @s add delta.launch 14 | 15 | execute as d59ee2c6-58c8-4885-b9db-ecff066e4439 in minecraft:overworld positioned 0.0 0.0 0.0 run function delta:internal/math/polar_to_xyz 16 | 17 | scoreboard players operation @s delta.internal.x += $out delta.internal.x 18 | scoreboard players operation @s delta.internal.y += $out delta.internal.y 19 | scoreboard players operation @s delta.internal.z += $out delta.internal.z -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/api/launch_xyz.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:api/launch_xyz 2 | # Launches the player in the input direction 3 | # 4 | # Inputs: 5 | # executed as player at player's position 6 | # score $x delta.api.launch <<< Strength to launch in x direction 7 | # score $y delta.api.launch <<< Strength to launch in y direction 8 | # score $z delta.api.launch <<< Strength to launch in z direction 9 | # 10 | # Outputs 11 | # player is launched in the specified direction 12 | 13 | #Flag indicating that players need to be launched, tag the player to be launched 14 | scoreboard players set $function_called delta.internal.dummy 1 15 | tag @s add delta.launch 16 | 17 | scoreboard players operation @s delta.internal.x += $x delta.api.launch 18 | scoreboard players operation @s delta.internal.y += $y delta.api.launch 19 | scoreboard players operation @s delta.internal.z += $z delta.api.launch 20 | 21 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/launch/launch_looking.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/launch/launch_looking 2 | # Launches the player in the input direction 3 | # 4 | # Inputs: 5 | # executed as player at player's position 6 | # execute rotated 7 | # score $temp_strength delta.api.launch <<< Strength to launch in looking direction (scaled up by 10000) 8 | # 9 | # Outputs 10 | # player is launched in the looking direction of the command with the desired strength 11 | 12 | #Set up bat + arrow to trigger advancement immediately before explosion 13 | function delta:internal/subtick/begin_launch_context 14 | 15 | #Figure out offset angle to get reduced motion 16 | function delta:internal/math/get_angle 17 | 18 | #Check if peaceful 19 | execute store result score $diff delta.internal.gamemode run difficulty 20 | execute if score $diff delta.internal.gamemode matches 0 run difficulty easy 21 | 22 | #Summon creepers 23 | execute anchored eyes positioned ^ ^ ^ run function delta:internal/summon/summon_creepers with storage delta:macros rotation 24 | 25 | scoreboard players operation $temp delta.internal.id = @s delta.internal.id 26 | execute anchored eyes positioned ^ ^ ^ positioned ~ ~1000 ~ as @e[type=creeper,tag=delta.init,distance=..0.02] at @s run function delta:internal/summon/initialize_creepers 27 | 28 | #Set up bat + arrow to trigger advancement immediately after explosion 29 | function delta:internal/subtick/end_launch_context -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/launch/main.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/launch/main 2 | # Executes the commands to launch the player 3 | # 4 | # Inputs: 5 | # score @s delta.internal.x <<< Strength to launch in x direction 6 | # score @s delta.internal.y <<< Strength to launch in y direction 7 | # score @s delta.internal.z <<< Strength to launch in z direction 8 | 9 | scoreboard players operation $temp delta.internal.x = @s delta.internal.x 10 | scoreboard players operation $temp delta.internal.y = @s delta.internal.y 11 | scoreboard players operation $temp delta.internal.z = @s delta.internal.z 12 | 13 | execute in overworld as d59ee2c6-58c8-4885-b9db-ecff066e4439 run function delta:internal/math/xyz_to_polar_wrapper 14 | execute rotated as d59ee2c6-58c8-4885-b9db-ecff066e4439 run function delta:internal/launch/launch_looking 15 | 16 | #Disables flag indicating that players need to be launched and removes tag 17 | scoreboard players set $function_called delta.internal.dummy 0 18 | tag @s remove delta.launch 19 | 20 | #Reset scoreboards 21 | scoreboard players reset @s delta.internal.x 22 | scoreboard players reset @s delta.internal.y 23 | scoreboard players reset @s delta.internal.z -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/arcsin.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/arcsin 2 | # Calculates arcsin 3 | # 4 | # Callers: 5 | # > delta:api/launch_looking 6 | # 7 | # Inputs: 8 | # executed as and at marker 9 | # score $output delta.internal.math 10 | # score $adjusted_strength delta.internal.math 11 | # 12 | # Outputs: 13 | # $rotation_offset delta.internal.math 14 | 15 | data modify storage delta:storage Pos set value [0d,0d,0d] 16 | execute store result storage delta:storage Pos[0] double 0.0001 run scoreboard players get $output delta.internal.math 17 | execute store result storage delta:storage Pos[1] double 0.0001 run scoreboard players get $adjusted_strength delta.internal.math 18 | data modify entity @s Pos set from storage delta:storage Pos 19 | data remove storage delta:storage Pos 20 | 21 | execute facing entity @s feet run tp @s ~ ~ ~ ~ ~ 22 | 23 | execute store result score $complementary_angle delta.internal.math run data get entity @s Rotation[1] 1000000 24 | scoreboard players set $rotation_offset delta.internal.math 90000000 25 | scoreboard players operation $rotation_offset delta.internal.math += $complementary_angle delta.internal.math 26 | 27 | execute in overworld run tp @s 0.0 0.0 0.0 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/arcsin_wrapper.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/arcsin_wrapper 2 | # Sets up the position context for the arcsin function so it can be ran without forceloading 3 | 4 | #data modify entity @s Pos set value [0.0d,0.0d,0.0d] 5 | tp @s 0.0 0.0 0.0 6 | execute at @s run function delta:internal/math/arcsin -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/get_angle.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/get_angle 2 | # Gets the offset angle to get the proper momentum cancellation and leave the right amount of forceload 3 | # 4 | # Callers: 5 | # > delta:api/launch_looking 6 | 7 | #Determine power coefficient from eye level 8 | function delta:internal/math/get_power_coefficient 9 | 10 | #If strength is large, figure out number of creepers needed 11 | scoreboard players operation $creeper_count delta.internal.math = $temp_strength delta.api.launch 12 | scoreboard players operation $momentum_per_iteration delta.internal.math = $divisor delta.internal.math 13 | scoreboard players operation $momentum_per_iteration delta.internal.math *= #constant.100 delta.internal.math 14 | scoreboard players operation $creeper_count delta.internal.math /= $momentum_per_iteration delta.internal.math 15 | scoreboard players add $creeper_count delta.internal.math 1 16 | 17 | scoreboard players operation $adjusted_strength delta.internal.math = $temp_strength delta.api.launch 18 | scoreboard players operation $adjusted_strength delta.internal.math /= $creeper_count delta.internal.math 19 | 20 | 21 | #X: sqrt (p^2 - (d^2)/4) -- d is desired power, p is max possible power produceable by 1 creeper 22 | #Scale factors: 23 | # adjusted_strength: 10000 24 | # $input: 100000000 25 | # p^2: 100000000 26 | # output: 10000 27 | 28 | scoreboard players operation $input delta.internal.math = $p_squared delta.internal.math 29 | scoreboard players operation $d delta.internal.math = $adjusted_strength delta.internal.math 30 | scoreboard players operation $d delta.internal.math *= $d delta.internal.math 31 | scoreboard players operation $d delta.internal.math /= #constant.4 delta.internal.math 32 | scoreboard players operation $input delta.internal.math -= $d delta.internal.math 33 | 34 | function delta:internal/math/sqrt 35 | 36 | #Get atan2 37 | scoreboard players operation $adjusted_strength delta.internal.math /= #constant.2 delta.internal.math 38 | execute in overworld as d59ee2c6-58c8-4885-b9db-ecff066e4439 positioned 0.0 0.0 0.0 run function delta:internal/math/arcsin 39 | 40 | #Get relative to current angle 41 | execute store result storage delta:macros rotation.positive int 0.000001 run scoreboard players get $rotation_offset delta.internal.math 42 | execute store result storage delta:macros rotation.negative int -0.000001 run scoreboard players get $rotation_offset delta.internal.math -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/get_power_coefficient.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/get_power_coefficient 2 | 3 | #0 = standing 4 | #1 = crouching 5 | #2 = gliding, swimming, or crawling 6 | 7 | scoreboard players set $player_status delta.internal.math 0 8 | execute anchored eyes positioned ^ ^ ^ if entity @s[distance=..1.28] run scoreboard players set $player_status delta.internal.math 1 9 | execute anchored eyes positioned ^ ^ ^ if entity @s[distance=..0.41] run scoreboard players set $player_status delta.internal.math 2 10 | 11 | execute if score $player_status delta.internal.math matches 0 run function delta:internal/math/set_power/standing 12 | execute if score $player_status delta.internal.math matches 1 run function delta:internal/math/set_power/crouching 13 | execute if score $player_status delta.internal.math matches 2 run function delta:internal/math/set_power/gliding_swimming_crawling -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/polar_to_xyz.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/polar_to_xyz 2 | # Converts a looking direction and magnitude into xyz coordinates 3 | 4 | tp @s ^ ^ ^1 5 | data modify storage delta:storage Pos set from entity @s Pos 6 | 7 | execute store result score $out delta.internal.x run data get storage delta:storage Pos[0] 4096 8 | execute store result score $out delta.internal.y run data get storage delta:storage Pos[1] 4096 9 | execute store result score $out delta.internal.z run data get storage delta:storage Pos[2] 4096 10 | 11 | scoreboard players operation $out delta.internal.y *= $strength delta.api.launch 12 | scoreboard players operation $out delta.internal.x *= $strength delta.api.launch 13 | scoreboard players operation $out delta.internal.z *= $strength delta.api.launch 14 | 15 | scoreboard players operation $out delta.internal.x /= #constant.4096 delta.internal.math 16 | scoreboard players operation $out delta.internal.y /= #constant.4096 delta.internal.math 17 | scoreboard players operation $out delta.internal.z /= #constant.4096 delta.internal.math 18 | 19 | tp @s 0.0 0.0 0.0 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/set_power/crouching.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/set_power/crouching 2 | # Sets variables related to power for when the player is standing 3 | # 4 | # Callers: 5 | # > delta:internal/math/get_power_coefficient 6 | 7 | scoreboard players set $divisor delta.internal.math 326 8 | scoreboard players set $p_squared delta.internal.math 265690000 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/set_power/gliding_swimming_crawling.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/set_power/gliding_swimming_crawling 2 | # Sets variables related to power for when the player is standing 3 | # 4 | # Callers: 5 | # > delta:internal/math/get_power_coefficient 6 | 7 | scoreboard players set $divisor delta.internal.math 240 8 | scoreboard players set $p_squared delta.internal.math 144000000 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/set_power/standing.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/set_power/standing 2 | # Sets variables related to power for when the player is standing 3 | # 4 | # Callers: 5 | # > delta:internal/math/get_power_coefficient 6 | 7 | scoreboard players set $divisor delta.internal.math 362 8 | scoreboard players set $p_squared delta.internal.math 327610000 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/sqrt.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/sqrt 2 | # Calculates the square root of an input number 3 | # Credit: Part Toon 4 | # 5 | # Callers: 6 | # > delta:api/launch_looking 7 | # 8 | # Inputs: 9 | # score $input delta.internal.math 10 | # 11 | # Outputs: 12 | # score $output delta.internal.math 13 | 14 | # Initialize values 15 | 16 | scoreboard players set $output delta.internal.math 0 17 | scoreboard players set $increment delta.internal.math 32768 18 | 19 | # Execute recursive function 20 | 21 | function delta:internal/math/sqrt_loop -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/sqrt_loop.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/sqrt_loop 2 | # Iterates through the square root algorithm 3 | # Credit: Part Toon 4 | # 5 | # Callers: 6 | # > delta:internal/math/sqrt_loop 7 | 8 | # Compute test 9 | scoreboard players operation $test delta.internal.math = $output delta.internal.math 10 | scoreboard players operation $test delta.internal.math += $increment delta.internal.math 11 | scoreboard players operation $test delta.internal.math *= $test delta.internal.math 12 | 13 | # Compare 14 | execute if score $test delta.internal.math <= $input delta.internal.math run scoreboard players operation $output delta.internal.math += $increment delta.internal.math 15 | 16 | # Execute recursive function 17 | scoreboard players operation $increment delta.internal.math /= #constant.2 delta.internal.math 18 | execute if score $increment delta.internal.math matches 1.. run function delta:internal/math/sqrt_loop -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/xyz_to_polar.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/xyz_to_polar 2 | # Takes xyz coordinates, returns a looking direction and magnitude 3 | 4 | #Move entity to end of vector 5 | data modify storage delta:storage Pos set value [0d,0d,0d] 6 | execute store result storage delta:storage Pos[0] double 0.0001 run scoreboard players get $temp delta.internal.x 7 | execute store result storage delta:storage Pos[1] double 0.0001 run scoreboard players get $temp delta.internal.y 8 | execute store result storage delta:storage Pos[2] double 0.0001 run scoreboard players get $temp delta.internal.z 9 | data modify entity @s Pos set from storage delta:storage Pos 10 | data remove storage delta:storage Pos 11 | 12 | #Get looking direction 13 | execute facing entity @s feet run tp @s ~ ~ ~ ~ ~ 14 | execute rotated as @s run tp @s ^ ^ ^1 15 | 16 | #Get unit vector 17 | data modify storage delta:storage Pos set from entity @s Pos 18 | execute store result score $unit.x delta.internal.math run data get storage delta:storage Pos[0] 1000 19 | execute store result score $unit.y delta.internal.math run data get storage delta:storage Pos[1] 1000 20 | execute store result score $unit.z delta.internal.math run data get storage delta:storage Pos[2] 1000 21 | data remove storage delta:storage Pos 22 | 23 | #Use absolute value 24 | execute if score $unit.x delta.internal.math matches ..-1 run scoreboard players operation $unit.x delta.internal.math *= #constant.-1 delta.internal.math 25 | execute if score $unit.y delta.internal.math matches ..-1 run scoreboard players operation $unit.y delta.internal.math *= #constant.-1 delta.internal.math 26 | execute if score $unit.z delta.internal.math matches ..-1 run scoreboard players operation $unit.z delta.internal.math *= #constant.-1 delta.internal.math 27 | 28 | scoreboard players operation $abs_x delta.internal.math = $temp delta.internal.x 29 | scoreboard players operation $abs_y delta.internal.math = $temp delta.internal.y 30 | scoreboard players operation $abs_z delta.internal.math = $temp delta.internal.z 31 | 32 | execute if score $abs_x delta.internal.math matches ..-1 run scoreboard players operation $abs_x delta.internal.math *= #constant.-1 delta.internal.math 33 | execute if score $abs_y delta.internal.math matches ..-1 run scoreboard players operation $abs_y delta.internal.math *= #constant.-1 delta.internal.math 34 | execute if score $abs_z delta.internal.math matches ..-1 run scoreboard players operation $abs_z delta.internal.math *= #constant.-1 delta.internal.math 35 | 36 | 37 | #Set strength to the highest component of the vector / the highest component of the unit vector 38 | scoreboard players operation $temp_strength delta.api.launch = $abs_x delta.internal.math 39 | scoreboard players operation $temp_strength delta.api.launch > $abs_y delta.internal.math 40 | scoreboard players operation $temp_strength delta.api.launch > $abs_z delta.internal.math 41 | scoreboard players operation $temp_strength delta.api.launch *= #constant.1000 delta.internal.math 42 | 43 | scoreboard players operation $unit.x delta.internal.math > $unit.y delta.internal.math 44 | scoreboard players operation $unit.x delta.internal.math > $unit.z delta.internal.math 45 | 46 | scoreboard players operation $temp_strength delta.api.launch /= $unit.x delta.internal.math 47 | 48 | tp @s 0.0 0.0 0.0 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/math/xyz_to_polar_wrapper.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/math/xyz_to_polar_wrapper 2 | # Wrapper function to set up the context for converting xyz coordinates to polar coordinates 3 | 4 | #Get looking angle and strength 5 | tp @s 0.0 0.0 0.0 6 | execute at @s run function delta:internal/math/xyz_to_polar 7 | 8 | #Tp back to forceloaded chunks 9 | execute in overworld run tp @s 0.0 0.0 0.0 -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/aec_setup.mcfunction: -------------------------------------------------------------------------------- 1 | data modify entity @s Owner set from storage delta:storage UUID 2 | data remove storage delta:storage UUID 3 | tag @s remove delta.init.aec -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/begin_launch_context.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/begin_launch_context 2 | # Sets up the bat and aec used to trigger the player_hurt_entity advancement right before an explosion 3 | 4 | summon minecraft:area_effect_cloud ~ ~10000 ~ {Duration:1,Radius:0.0f,ReapplicationDelay:-1,Age:-1,WaitTime:0,effects:[{id:"minecraft:instant_damage",amplifier:0b,duration:1}],Tags:["delta.init.aec"]} 5 | summon minecraft:bat ~ ~10000 ~ {DeathLootTable:"",NoAI:1b,Health:1.0f,Tags:["delta.pre_explosion"],PersistenceRequired:1b} 6 | function delta:internal/subtick/get_player_uuid 7 | execute positioned ~ ~10000 ~ as @e[type=area_effect_cloud,tag=delta.init.aec,distance=..0.01] run function delta:internal/subtick/aec_setup -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/end_ignore_player.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/end_ignore_player 2 | # Shifts the player back into their normal game mode 3 | # 4 | # Callers: 5 | # > delta:internal/subtick/post_explosion_trigger 6 | 7 | 8 | 9 | #Revert player to previous gamemode 10 | #gamemode adventure @s[scores={delta.internal.gamemode=0}] 11 | #gamemode creative @s[scores={delta.internal.gamemode=1}] 12 | #gamemode spectator @s[scores={delta.internal.gamemode=2}] 13 | #gamemode survival @s[scores={delta.internal.gamemode=3}] 14 | 15 | tp @s ~ ~-10000 ~ 16 | 17 | tag @s remove delta.ignored_player -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/end_launch_context.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/end_launch_context 2 | # Summons the bat and aec used to trigger the player_hurt_entity advancement immediately after an explosion 3 | 4 | summon minecraft:area_effect_cloud ~ ~12000 ~ {Duration:1,Radius:0.0f,ReapplicationDelay:-1,Age:-1,WaitTime:0,effects:[{id:"minecraft:instant_damage",amplifier:0b,duration:1}],Tags:["delta.init.aec"]} 5 | summon minecraft:bat ~ ~12000 ~ {DeathLootTable:"",NoAI:1b,Health:1.0f,Tags:["delta.post_explosion"],PersistenceRequired:1b} 6 | function delta:internal/subtick/get_player_uuid 7 | execute positioned ~ ~12000 ~ as @e[type=area_effect_cloud,tag=delta.init.aec,distance=..0.01] run function delta:internal/subtick/aec_setup -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/get_player_uuid.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/get_player_uuid 2 | # Retrieve the player's UUID. If the player has been retrieved in the past, it can be retrieved faster than usual. 3 | 4 | execute if score @s delta.internal.uuid.3 matches -2147483648..2147483647 run data modify storage delta:storage UUID set value [I;0,0,0,0] 5 | execute if score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result storage delta:storage UUID[0] int 1 run scoreboard players get @s delta.internal.uuid.0 6 | execute if score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result storage delta:storage UUID[1] int 1 run scoreboard players get @s delta.internal.uuid.1 7 | execute if score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result storage delta:storage UUID[2] int 1 run scoreboard players get @s delta.internal.uuid.2 8 | execute if score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result storage delta:storage UUID[3] int 1 run scoreboard players get @s delta.internal.uuid.3 9 | 10 | execute unless score @s delta.internal.uuid.3 matches -2147483648..2147483647 run data modify storage delta:storage UUID set from entity @s UUID 11 | 12 | execute unless score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result score @s delta.internal.uuid.0 run data get storage delta:storage UUID[0] 13 | execute unless score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result score @s delta.internal.uuid.1 run data get storage delta:storage UUID[1] 14 | execute unless score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result score @s delta.internal.uuid.2 run data get storage delta:storage UUID[2] 15 | execute unless score @s delta.internal.uuid.3 matches -2147483648..2147483647 store result score @s delta.internal.uuid.3 run data get storage delta:storage UUID[3] -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/ignore_player.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/ignore_player 2 | # Puts the player into spectator mode while the explosion is occurring 3 | # 4 | # Callers: 5 | # > delta:internal/subtick/pre_explosion_trigger 6 | 7 | #Store previous gamemode before switching 8 | #scoreboard players set @s[gamemode=adventure] delta.internal.gamemode 0 9 | #scoreboard players set @s[gamemode=creative] delta.internal.gamemode 1 10 | #scoreboard players set @s[gamemode=spectator] delta.internal.gamemode 2 11 | #scoreboard players set @s[gamemode=survival] delta.internal.gamemode 3 12 | 13 | #gamemode spectator 14 | tp @s ~ ~10000 ~ 15 | 16 | tag @s add delta.ignored_player -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/post_explosion_trigger.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/post_explosion_trigger 2 | # Runs commands as the player immediately after the creeper explosion has been processed 3 | # 4 | # Callers: 5 | # > delta:post_explosion_trigger (advancement) 6 | 7 | advancement revoke @s only delta:post_explosion_trigger 8 | 9 | #Revert player to previous gamemode 10 | gamemode adventure @s[scores={delta.internal.gamemode=0}] 11 | gamemode creative @s[scores={delta.internal.gamemode=1}] 12 | gamemode spectator @s[scores={delta.internal.gamemode=2}] 13 | gamemode survival @s[scores={delta.internal.gamemode=3}] 14 | 15 | #Revert difficulty if necessary 16 | execute if score $diff delta.internal.gamemode matches 0 run difficulty peaceful 17 | 18 | #Teleport self down 19 | tp @s ~ ~-1000 ~ -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/pre_explosion_trigger.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/pre_explosion_trigger 2 | # Runs commands as the player after all other entity processing has occurred and before the explosion has occurred 3 | # 4 | # Callers: 5 | # > delta:pre_explosion_trigger (advancement) 6 | 7 | advancement revoke @s only delta:pre_explosion_trigger 8 | 9 | #Store previous gamemode before switching 10 | scoreboard players set @s[gamemode=adventure] delta.internal.gamemode 0 11 | scoreboard players set @s[gamemode=creative] delta.internal.gamemode 1 12 | scoreboard players set @s[gamemode=spectator] delta.internal.gamemode 2 13 | scoreboard players set @s[gamemode=survival] delta.internal.gamemode 3 14 | 15 | #Put self in creative so only knockback is applied, no damage 16 | gamemode creative 17 | 18 | #Teleport self up 19 | tp @s ~ ~1000 ~ 20 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/shift_entity.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/shift_entity 2 | # Temporarily moves an entity out of the way so it isn't affected by the explosion 3 | # 4 | # Callers: 5 | # > delta:internal/pre_explosion_subtick 6 | 7 | #Set Invulnerable to 1b and get whether the original value was 0b. 8 | execute store success score @s delta.internal.invulnerable run data modify entity @s Invulnerable set value 1b 9 | #Invert 0b/1b 10 | execute store success score @s delta.internal.invulnerable if score @s delta.internal.invulnerable matches 0 11 | 12 | data modify storage delta:storage Motion set from entity @s Motion 13 | execute store result score @s delta.internal.motion.x run data get storage delta:storage Motion[0] 10000000 14 | execute store result score @s delta.internal.motion.y run data get storage delta:storage Motion[1] 10000000 15 | execute store result score @s delta.internal.motion.z run data get storage delta:storage Motion[2] 10000000 16 | data remove storage delta:storage Motion 17 | 18 | tag @s add delta.shifted -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/subtick/unshift_entity.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/subtick/unshift_entity 2 | # Returns entities to their normal position 3 | # 4 | # Callers: 5 | # > delta:internal/post_explosion_subtick 6 | 7 | execute store result entity @s Invulnerable byte 1 run scoreboard players get @s delta.internal.invulnerable 8 | 9 | data modify storage delta:storage Motion set value [0d,0d,0d] 10 | execute store result storage delta:storage Motion[0] double 0.0000001 run scoreboard players get @s delta.internal.motion.x 11 | execute store result storage delta:storage Motion[1] double 0.0000001 run scoreboard players get @s delta.internal.motion.y 12 | execute store result storage delta:storage Motion[2] double 0.0000001 run scoreboard players get @s delta.internal.motion.z 13 | data modify entity @s Motion set from storage delta:storage Motion 14 | data remove storage delta:storage Motion 15 | 16 | 17 | tag @s remove delta.shifted -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/summon/initialize_creepers.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/summon/initialize_creepers 2 | # Links creepers to players via a scoreboard 3 | 4 | scoreboard players operation @s delta.internal.id = $temp delta.internal.id 5 | tag @s remove delta.init -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/summon/summon_creepers.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/summon/summon_creepers 2 | # Summons creepers to launch 3 | # 4 | # Callers: 5 | # > delta:api/launch_looking 6 | 7 | scoreboard players operation $creepers_remaining delta.internal.math = $creeper_count delta.internal.math 8 | $execute rotated ~ ~$(positive) positioned ^ ^ ^-0.01 run function delta:internal/summon/summon_creepers_recursive 9 | 10 | scoreboard players operation $creepers_remaining delta.internal.math = $creeper_count delta.internal.math 11 | $execute rotated ~ ~$(negative) positioned ^ ^ ^-0.01 run function delta:internal/summon/summon_creepers_recursive -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/summon/summon_creepers_recursive.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/summon/summon_creepers_recursive 2 | # Recursively spawns creepers 3 | # 4 | # Callers: 5 | # > delta:internal/summon_creepers 6 | # 7 | # Inputs: 8 | # score $creepers_remaining delta.internal.math <<< Number of creepers to spawn 9 | # 10 | # Output: 11 | # spawns creepers 12 | 13 | summon creeper ~ ~1000 ~ {Tags:["delta.launcher","delta.init"],Silent:1b,Invulnerable:1b,Team:"delta.no_collide",ExplosionRadius:-1b,Fuse:0s,PersistenceRequired:1b} 14 | scoreboard players remove $creepers_remaining delta.internal.math 1 15 | execute if score $creepers_remaining delta.internal.math matches 1.. run function delta:internal/summon/summon_creepers_recursive -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/technical/initialize_player.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/technical/initialize_player 2 | # Sets up unique ID for a player 3 | 4 | scoreboard players add $global delta.internal.id 1 5 | scoreboard players operation @s delta.internal.id = $global delta.internal.id -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/technical/load.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/technical/load 2 | # Sets up scores and teams 3 | 4 | #Start schedule loops 5 | schedule function delta:internal/technical/tick 1t replace 6 | 7 | # Definitions for Data-pack Helper Plus 8 | #declare storage delta:storage 9 | 10 | #SCORES 11 | scoreboard objectives add delta.api.launch dummy 12 | scoreboard objectives add delta.api.particle dummy 13 | scoreboard objectives add delta.internal.dummy dummy 14 | scoreboard objectives add delta.internal.gamemode dummy 15 | scoreboard objectives add delta.internal.invulnerable dummy 16 | scoreboard objectives add delta.internal.math dummy 17 | scoreboard players set #constant.-1 delta.internal.math -1 18 | scoreboard players set #constant.2 delta.internal.math 2 19 | scoreboard players set #constant.4 delta.internal.math 4 20 | scoreboard players set #constant.16 delta.internal.math 16 21 | scoreboard players set #constant.100 delta.internal.math 100 22 | scoreboard players set #constant.256 delta.internal.math 256 23 | scoreboard players set #constant.1000 delta.internal.math 1000 24 | scoreboard players set #constant.4096 delta.internal.math 4096 25 | scoreboard players set #constant.65793 delta.internal.math 65793 26 | scoreboard objectives add delta.internal.motion.x dummy 27 | scoreboard objectives add delta.internal.motion.y dummy 28 | scoreboard objectives add delta.internal.motion.z dummy 29 | scoreboard objectives add delta.internal.uuid.0 dummy 30 | scoreboard objectives add delta.internal.uuid.1 dummy 31 | scoreboard objectives add delta.internal.uuid.2 dummy 32 | scoreboard objectives add delta.internal.uuid.3 dummy 33 | scoreboard objectives add delta.internal.id dummy 34 | scoreboard objectives add delta.internal.x dummy 35 | scoreboard objectives add delta.internal.y dummy 36 | scoreboard objectives add delta.internal.z dummy 37 | 38 | #TEAMS 39 | team add delta.no_collide 40 | team modify delta.no_collide collisionRule never 41 | 42 | forceload remove 0 0 43 | forceload add 0 0 44 | 45 | #MARKERS 46 | kill d59ee2c6-58c8-4885-b9db-ecff066e4439 47 | summon marker ~ ~ ~ {UUID: [I;-711007546,1489520773,-1176769281,107889721],Tags:["global.ignore"]} 48 | 49 | #STORAGE 50 | data modify storage delta:macros rotation set value {"positive":0,"negative":0} -------------------------------------------------------------------------------- /delta_datapack/data/delta/functions/internal/technical/tick.mcfunction: -------------------------------------------------------------------------------- 1 | #> delta:internal/technical/tick 2 | # Commands run per tick, within a scheduling loop to ensure they're run after any tick.json functions 3 | 4 | #If any motion functions were called in the past tick, run the function (this is a measure to enforce proper subtick timing) 5 | execute if score $function_called delta.internal.dummy matches 1 as @a[tag=delta.launch] at @s run function delta:internal/launch/main 6 | 7 | schedule function delta:internal/technical/tick 1t replace 8 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/item_modifiers/set_frame.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "function": "minecraft:copy_nbt", 4 | "source": { 5 | "type": "minecraft:storage", 6 | "source": "delta:storage" 7 | }, 8 | "ops": [ 9 | { 10 | "source": "CustomModelData", 11 | "target": "CustomModelData", 12 | "op": "replace" 13 | } 14 | ] 15 | } 16 | ] -------------------------------------------------------------------------------- /delta_datapack/data/delta/predicates/riding_entity.json: -------------------------------------------------------------------------------- 1 | { 2 | "condition": "minecraft:entity_properties", 3 | "entity": "this", 4 | "predicate": { 5 | "vehicle": {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /delta_datapack/data/delta/tags/blocks/no_collision.json: -------------------------------------------------------------------------------- 1 | { 2 | "values" : [ 3 | "minecraft:air", 4 | "minecraft:cave_air", 5 | "minecraft:void_air", 6 | "#minecraft:flowers", 7 | "minecraft:grass", 8 | "minecraft:tall_grass", 9 | "#minecraft:banners", 10 | "minecraft:torch", 11 | "minecraft:wall_torch", 12 | "minecraft:soul_torch", 13 | "minecraft:soul_wall_torch" 14 | ] 15 | } -------------------------------------------------------------------------------- /delta_datapack/data/delta/tags/entity_types/technical/detect_explosion.json: -------------------------------------------------------------------------------- 1 | { 2 | "values": [ 3 | "minecraft:creeper", 4 | "minecraft:fireball", 5 | "minecraft:end_crystal", 6 | "minecraft:tnt_minecart", 7 | "minecraft:wither_skull", 8 | "minecraft:ender_dragon", 9 | "minecraft:shulker_bullet" 10 | ] 11 | } -------------------------------------------------------------------------------- /delta_datapack/data/minecraft/tags/functions/load.json: -------------------------------------------------------------------------------- 1 | { 2 | "values" : [ 3 | "delta:internal/technical/load" 4 | ] 5 | } -------------------------------------------------------------------------------- /delta_datapack/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 15, 4 | "description": "Explosion-based player motion library" 5 | } 6 | } 7 | --------------------------------------------------------------------------------