Skip to content

Commit

Permalink
More factors for applied momentum
Browse files Browse the repository at this point in the history
- **Added more factors for applied motion**
  Body parts will now take the following factors for their motion/momentum into account:
  - Motion from the dead mob [!NEW in this commit]
  - Motion from the killer entity [!NEW in this commit]
  - Motion from the new swing momentum entity [Players only] [!NEW in this commit]
  - Custom motion parameters depending on the situation
- Added different blood particles for parts inside water
- Added turtle to supported mobs
- Fixed broken inherited rotation
- Beautified loot tables
- Renamed y_lag function to troubleshoot
  • Loading branch information
Tschipcraft committed Dec 25, 2022
1 parent 3b1ba9e commit 46bcae1
Show file tree
Hide file tree
Showing 48 changed files with 1,227 additions and 1,056 deletions.
2 changes: 1 addition & 1 deletion data/deathanimations/functions/core.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Get player motion
execute as @a[gamemode=!spectator] at @s run function deathanimations:general/get_player_motion

function deathanimations:general/player_swing/core

### welcome & Menu
# now in /loops
Expand Down
6 changes: 5 additions & 1 deletion data/deathanimations/functions/detection/branch.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@


execute as @s[nbt={Item:{tag:{da_entity:phantom}}}] at @s run function deathanimations:summon_phantom
execute as @s[nbt={Item:{tag:{da_entity:endermite}}}] at @s run function deathanimations:summon_endermite

#execute as @s[nbt={Item:{tag:{da_entity:zombie,da_ragdoll:1b}}}] unless data entity @s {Item:{tag:{da_is_baby:1b}}} at @s positioned ~ ~1 ~ run function deathanimations:ragdoll_create_zombie
#execute as @s[nbt={Item:{tag:{da_entity:zombie}}}] unless entity @s[nbt={Item:{tag:{da_ragdoll:1b}}}] at @s run function deathanimations:summon/summon_zombie
#execute as @s[nbt={Item:{tag:{da_entity:zombie}}}] if entity @s[nbt={Item:{tag:{da_ragdoll:1b}}}] if data entity @s {Item:{tag:{da_is_baby:1b}}} at @s run function deathanimations:summon/summon_zombie

function deathanimations:detection/branch_auto
# Inherit rotation
data modify entity @s Rotation set from entity @s Item.tag.Rotation

execute rotated as @s run function deathanimations:detection/branch_auto


## //TODO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ execute as @s[tag=da_explosion_death] at @s run function deathanimations:general
# Apply motion
execute as @s[tag=!da_no_knockback,tag=!iron_golem,tag=!ravager] at @s run function deathanimations:tick

# Add swing momentum (Integrate into tick?)
execute as @s[tag=da_player_death] at @s if entity @e[type=minecraft:marker,tag=da_player_swing,distance=..7] run function deathanimations:general/source/player_swing

# Finalize entity to given settings
function deathanimations:general/bodypart_finalize
21 changes: 2 additions & 19 deletions data/deathanimations/functions/general/particle.mcfunction
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
##by Tschipcraft
# Displays particles for the given visual entity (~ ~ ~/~ ~/@s = visual entity)

execute as @s[tag=torso,tag=bloody] positioned ^ ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.1 0 0.1 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=bloody] positioned ^ ^0.35 ^ run particle minecraft:block redstone_block ~ ~1.1 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=cutom_bloody] positioned ^ ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.1 0 0.1 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=cutom_bloody] positioned ^ ^0.35 ^ run particle minecraft:item slime_ball ~ ~1.1 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=cutom_bloody] positioned ^0.25 ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=cutom_bloody] positioned ^0.25 ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=sandy] positioned ^ ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=sandy] positioned ^ ^0.35 ^ run particle minecraft:block sand ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=leg,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=arm,tag=visual,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.01 0 0.01 1 1 normal

execute as @s[tag=torso,tag=watery] positioned ^ ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=watery] positioned ^ ^0.35 ^ run particle minecraft:splash ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=leg,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=arm,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute if block ~ ~1.4 ~ water run function deathanimations:general/particle/water
execute unless block ~ ~1.4 ~ water run function deathanimations:general/particle/land

execute as @s[tag=torso,tag=da_magical] positioned ^ ^ ^ run particle minecraft:witch ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=da_magical] positioned ^ ^0.35 ^ run particle minecraft:witch ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
Expand Down
22 changes: 22 additions & 0 deletions data/deathanimations/functions/general/particle/land.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
##by Tschipcraft
# Displays particles for the given visual entity (~ ~ ~/~ ~/@s = visual entity) on land

execute as @s[tag=torso,tag=bloody] positioned ^ ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.1 0 0.1 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=bloody] positioned ^ ^0.35 ^ run particle minecraft:block redstone_block ~ ~1.1 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:block redstone_block ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=custom_bloody] positioned ^ ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.1 0 0.1 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=custom_bloody] positioned ^ ^0.35 ^ run particle minecraft:item slime_ball ~ ~1.1 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=custom_bloody] positioned ^0.25 ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=custom_bloody] positioned ^0.25 ^ ^ run particle minecraft:item slime_ball ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=sandy] positioned ^ ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=sandy] positioned ^ ^0.35 ^ run particle minecraft:block sand ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=leg,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=arm,tag=visual,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:block sand ~ ~1.5 ~ 0.01 0 0.01 1 1 normal

execute as @s[tag=torso,tag=watery] positioned ^ ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=watery] positioned ^ ^0.35 ^ run particle minecraft:splash ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=leg,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=arm,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:splash ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
22 changes: 22 additions & 0 deletions data/deathanimations/functions/general/particle/water.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
##by Tschipcraft
# Displays particles for the given visual entity (~ ~ ~/~ ~/@s = visual entity) inside water

execute as @s[tag=torso,tag=bloody] positioned ^ ^ ^ run particle minecraft:dust 1 0.1 0 3 ~ ~1.5 ~ 0.1 0 0.1 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=bloody] positioned ^ ^0.35 ^ run particle minecraft:dust 1 0.1 0 3 ~ ~1.1 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:dust 1 0.1 0 3 ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=bloody] positioned ^0.25 ^ ^ run particle minecraft:dust 1 0.1 0 3 ~ ~1.5 ~ 0.01 0 0.01 1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=custom_bloody] positioned ^ ^ ^ run particle minecraft:dust 0.082 0.706 0 2 ~ ~1.5 ~ 0.1 0 0.1 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=head,tag=custom_bloody] positioned ^ ^0.35 ^ run particle minecraft:dust 0.082 0.706 0 2 ~ ~1.1 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=leg,tag=custom_bloody] positioned ^0.25 ^ ^ run particle minecraft:dust 0.082 0.706 0 2 ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]
execute as @s[tag=arm,tag=custom_bloody] positioned ^0.25 ^ ^ run particle minecraft:dust 0.082 0.706 0 2 ~ ~1.5 ~ 0.01 0 0.01 0.1 1 normal @a[scores={blood_local=1}]

execute as @s[tag=torso,tag=sandy] positioned ^ ^ ^ run particle minecraft:dust 0.8 0.75 0.58 2 ~ ~1.5 ~ 0.1 0 0.1 1 1 normal
execute as @s[tag=head,tag=sandy] positioned ^ ^0.35 ^ run particle minecraft:dust 0.8 0.75 0.58 2 ~ ~1.1 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=leg,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:dust 0.8 0.75 0.58 2 ~ ~1.5 ~ 0.01 0 0.01 1 1 normal
execute as @s[tag=arm,tag=visual,tag=sandy] positioned ^0.25 ^ ^ run particle minecraft:dust 0.8 0.75 0.58 2 ~ ~1.5 ~ 0.01 0 0.01 1 1 normal

execute as @s[tag=torso,tag=watery] positioned ^ ^ ^ run particle minecraft:bubble ~ ~1.5 ~ 0.1 0 0.1 1 0 normal
execute as @s[tag=head,tag=watery] positioned ^ ^0.35 ^ run particle minecraft:bubble ~ ~1.1 ~ 0.01 0 0.01 1 0 normal
execute as @s[tag=leg,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:bubble ~ ~1.5 ~ 0.01 0 0.01 1 0 normal
execute as @s[tag=arm,tag=watery] positioned ^0.25 ^ ^ run particle minecraft:bubble ~ ~1.5 ~ 0.01 0 0.01 1 0 normal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##by Tschipcraft
# Calculates player swing motion

execute at @a[tag=this] rotated as @a[tag=this] positioned ~ ~1.6 ~ run tp @s ^ ^ ^1

# Calculates player swing motion
scoreboard players set -1 x -1

scoreboard players operation @s dx = @s x
execute store result score @s x run data get entity @s Pos[0] 71
scoreboard players operation @s dx -= @s x
scoreboard players operation @s dx *= -1 x

scoreboard players operation @s dy = @s y
execute store result score @s y run data get entity @s Pos[1] 71
scoreboard players operation @s dy -= @s y
scoreboard players operation @s dy *= -1 x

scoreboard players operation @s dz = @s z
execute store result score @s z run data get entity @s Pos[2] 71
scoreboard players operation @s dz -= @s z
scoreboard players operation @s dz *= -1 x

# Remove tag (operation successful)
tag @a[tag=this] remove this

# Debug
#tellraw @a [{"text":"X: "},{"score":{"name":"@s","objective":"dx"}},{"text":", Y: "},{"score":{"name":"@s","objective":"dy"}},{"text":", Z: "},{"score":{"name":"@s","objective":"dz"}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##by Tschipcraft

# New player
scoreboard players add @a[gamemode=!spectator] da_sid 0
execute as @a[scores={da_sid=0},limit=1] at @s run function deathanimations:general/player_swing/new_player

execute as @a[gamemode=!spectator,scores={da_sid=1..}] at @s run function deathanimations:general/player_swing/search

# Reset (put in loop)
execute as @e[type=minecraft:marker,tag=da_player_swing] at @s positioned ~ ~-1.6 ~ unless entity @a[distance=..10] run kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##by Tschipcraft
# Adds a new swing motion detector for a new player

summon marker ~ ~ ~ {Silent:1b,Invulnerable:1b,Tags:[da_player_swing],CustomName:'{"text":"Player Swing Detector"}'}

scoreboard players add .player da_sid 1
scoreboard players operation @e[type=minecraft:marker,tag=da_player_swing,limit=1,sort=arbitrary] da_sid = .player da_sid
scoreboard players operation @s da_sid = .player da_sid
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
##by Tschipcraft
# Searches up player swing counterpart entity from player

scoreboard players operation .search da_sid = @s da_sid
tag @s add this
execute as @e[type=minecraft:marker,tag=da_player_swing,predicate=deathanimations:search] at @s rotated as @s run function deathanimations:general/player_swing/adjust_pos

# Counterpart not found
execute if entity @s[tag=this] run scoreboard players reset @s da_sid
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
##by Tschipcraft
# Add swing momentum

# Get current motion
execute as @s store result score @s xm run data get entity @s Motion[0] 100
execute as @s store result score @s ym run data get entity @s Motion[1] 100
execute as @s store result score @s zm run data get entity @s Motion[2] 100

# Apply new motion
execute store result entity @s Motion[0] double 0.02 run scoreboard players get @e[type=minecraft:marker,tag=da_player_swing,limit=1,sort=nearest] dx
execute store result entity @s Motion[1] double 0.02 run scoreboard players get @e[type=minecraft:marker,tag=da_player_swing,limit=1,sort=nearest] dy
execute store result entity @s Motion[2] double 0.02 run scoreboard players get @e[type=minecraft:marker,tag=da_player_swing,limit=1,sort=nearest] dz

# Add together
execute as @s store result score @s x run data get entity @s Motion[0] 100
execute as @s store result score @s y run data get entity @s Motion[1] 100
execute as @s store result score @s z run data get entity @s Motion[2] 100

scoreboard players operation @s xm += @s x
scoreboard players operation @s ym += @s y
scoreboard players operation @s zm += @s z

execute store result entity @s Motion[0] double 0.01 run scoreboard players get @s xm
execute store result entity @s Motion[1] double 0.01 run scoreboard players get @s ym
execute store result entity @s Motion[2] double 0.01 run scoreboard players get @s zm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ execute as @a[scores={menu=61..}] run scoreboard players set @s da_welcome 1
scoreboard players reset @a[scores={menu=122..}] menu
scoreboard players add @a[scores={menu=1..}] menu 1

execute as @a[scores={troubleshoot=1}] run function deathanimations:compatibility/y_lag
execute as @a[scores={troubleshoot=1}] run function deathanimations:compatibility/troubleshoot
scoreboard players reset @a[scores={troubleshoot=1..}] troubleshoot

## settings
Expand Down
33 changes: 31 additions & 2 deletions data/deathanimations/functions/summon/special_nbt.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,40 @@ execute if entity @s[nbt={Item:{tag:{da_is_baby:1b}}}] as @e[type=minecraft:armo


data modify storage d_a:detection Fire set from entity @s Item.tag.Fire
execute as @e[type=minecraft:armor_stand,tag=visual,scores={da_id=1}] run data modify entity @s Fire set from storage d_a:detection Fire
execute as @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1}] run data modify entity @s Fire set from storage d_a:detection Fire

data modify storage d_a:detection Rotation set from entity @s Item.tag.Rotation
execute as @e[type=minecraft:armor_stand,tag=visual,scores={da_id=1}] run data modify entity @s Rotation set from storage d_a:detection Rotation

# Apply killer momentum
data modify entity @s Motion set from entity @s Item.tag.K_Motion

# Get current motion
execute as @s store result score @s xm run data get entity @s Motion[0] 100
execute as @s store result score @s ym run data get entity @s Motion[1] 100
execute as @s store result score @s zm run data get entity @s Motion[2] 100

# Apply victim momentum
data modify storage d_a:detection Motion set from entity @s Item.tag.Motion
execute as @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1}] run data modify entity @s Motion set from storage d_a:detection Motion

# Add motions together
execute as @s store result score @s x run data get entity @s Motion[0] 100
execute as @s store result score @s y run data get entity @s Motion[1] 100
execute as @s store result score @s z run data get entity @s Motion[2] 100

scoreboard players operation @s xm += @s x
scoreboard players operation @s ym += @s y
scoreboard players operation @s zm += @s z

execute store result entity @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1},limit=1] Motion[0] double 0.01 run scoreboard players get @s xm
execute store result entity @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1},limit=1] Motion[1] double 0.01 run scoreboard players get @s ym
execute store result entity @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1},limit=1] Motion[2] double 0.01 run scoreboard players get @s zm



#data modify storage d_a:detection ActiveEffects set from entity @s Item.tag.ActiveEffects
#execute as @e[type=minecraft:armor_stand,tag=visual,scores={da_id=1}] run data modify entity @s ActiveEffects set from storage d_a:detection ActiveEffects
#execute as @e[type=minecraft:armor_stand,tag=bodypart,scores={da_id=1}] run data modify entity @s ActiveEffects set from storage d_a:detection ActiveEffects


kill @s[type=minecraft:item]
Loading

0 comments on commit 46bcae1

Please sign in to comment.