Skip to content

Commit

Permalink
Merge pull request #5 from K-bai/2.6.2
Browse files Browse the repository at this point in the history
2.6.2 remaining fixes
  • Loading branch information
mattcarter11 authored Jan 31, 2023
2 parents b510b3e + 18dceb9 commit 9f6d94f
Show file tree
Hide file tree
Showing 39 changed files with 424 additions and 303 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you want a ray that can **pass those blocks** that a player can pass, you sho

If you want a ray that can **touch entities** (stops after one found), you should tag the ray `mrcd_entity` and **rotate the AEC as the speed direction**. If it touched an entity, it will have a tag named `mrcd_touch_entity`, and the target entity will be tagged `mrcd_target_entity`. Note that some entities like player and projectiles are ignored by default. You can remove them in entity types tag (`#mrcd:ignore`) to change it.

If you want a ray that can **touch a specific entity or group of entities** (stops after one found), you should tag it/them with `mrcd_target`, the ray `mrcd_entity_targeted` and **rotate the AEC as the speed direction**. If it touched a tagged entity, it will have a tag named `mrcd_touch_entity`, and the target entity will be tagged `mrcd_target_entity`. Any other non tagged entity that hits, will be ignored and the ray will pass through. This method can target any entity, even those that are in the `#mrcd:ignore` tag list.
If you want a ray that can **touch a specific entity or group of entities** (stops after one found), you should tag it/them with `mrcd_target`, the ray `mrcd_entity_targeted` and **rotate the AEC as the speed direction**. If it touched a tagged entity, it will have a tag named `mrcd_touch_entity`, and the target entity will be tagged `mrcd_target_entity`. Any other non tagged entity that hits, will be ignored and the ray will pass through. This method can target any entity, even those that are in the `#mrcd:ignore` tag list. Also, you can tag an entity with `mrcd_ignore` to also be ignored.

If you want a ray that can **touch multiple entities** (doesn't stops after one found), you should tag the ray `mrcd_entity` and `mrcd_entity_bullet` and **rotate the AEC as the speed direction** (this is also works with `mrcd_entity_targeted`). If it touched an entity, it will have a tag named `mrcd_touch_entity`, and the target entity will be tagged `mrcd_target_entity`.

Expand Down Expand Up @@ -251,9 +251,16 @@ These blocks listed below are supported in is datapack. Please post an issue if
* Fixes
* Made ray entity detection hitbox precise
* v2.6.2
* Updates
* Added the possibility to use the `mrcd_ignore` tag to force ignore entities
* Improved example to show how to properly cast instant rays
* Changes
* Renamed some internal tags to be more descriptive
* Optimized mrcd_entity and mrcd_entity_targeted (if you hit entity, you don't need to calculate block stuff)
* Entity hit detection redone, so it's even preciser (the check is done in steps of 0.33 blocks)
* Optimitzations
* If no entit hitbox in block, don't do entity calculations
* If you hit entity, you don't need to calculate block stuff (`mrcd_entity` and `mrcd_entity_targeted`)
* Fixes
* Ray can't target itself
* Ray sometimes getting inside complex block (collision not working)
* Ray should not target itself
* Ray sometimes getting inside complex block when the ray was comming from -xyz (collision not working)
* mrcd_entity and mrcd_entity_targeted could tag more than one entity when not being a mrcd_entity_bullet
21 changes: 11 additions & 10 deletions data/mrcd/functions/example/bullet.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_bullet"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init","mrcd_bullet"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~

# Clear tag
tag @e[tag=init] remove init
22 changes: 11 additions & 11 deletions data/mrcd/functions/example/bullet_and_entity.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_bullet","mrcd_entity"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init","mrcd_bullet","mrcd_entity"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system
# Clear tag
tag @e[tag=init] remove init
24 changes: 13 additions & 11 deletions data/mrcd/functions/example/bullet_and_entity_instant.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 10 b/t).
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 5 b/t).
# Since we what it instant, we wont set a Duration
execute at @s positioned ^ ^ ^10 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_bullet","mrcd_entity","instnat"]}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^5 {Tags:["test_mark","init","mrcd_bullet","mrcd_entity","instnat"]}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~

# Clear tag
tag @e[tag=init] remove init
tag @e[tag=init] remove init
21 changes: 11 additions & 10 deletions data/mrcd/functions/example/bullet_entity.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_entity","mrcd_entity_bullet"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init","mrcd_entity","mrcd_entity_bullet"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~

# Clear tag
tag @e[tag=init] remove init
22 changes: 11 additions & 11 deletions data/mrcd/functions/example/entity.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_entity"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init","mrcd_entity"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system
# Clear tag
tag @e[tag=init] remove init
21 changes: 11 additions & 10 deletions data/mrcd/functions/example/entity_targeted.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init","mrcd_entity_targeted"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init","mrcd_entity_targeted"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~

# Clear tag
tag @e[tag=init] remove init
21 changes: 11 additions & 10 deletions data/mrcd/functions/example/raycast.mcfunction
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Create marker
# We use oriented relative coordinates and some math to eassily assing the speed (this case, 0.5 b/t).
# Since it lasts for 10 ticks (Duration), it will travel at max 5 blocks
execute at @s positioned ^ ^ ^.5 run summon area_effect_cloud ~ ~ ~ {Tags:["test_mark","init"],Duration:10}
execute at @s anchored eyes run summon area_effect_cloud ^ ^ ^.5 {Tags:["test_mark","init"],Duration:10}

# Save speed and direction
execute as @e[tag=init] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000
execute store result score #var0 mrcd_system run data get entity @s Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @s Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @s Pos[2] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_x0 run data get entity @s Pos[0] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_y0 run data get entity @s Pos[1] 1000
execute as @e[tag=init,limit=1] store result score @s mrcd_z0 run data get entity @s Pos[2] 1000

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes run tp @e[tag=init,limit=1] ^ ^ ^ ~ ~

execute store result score #var0 mrcd_system run data get entity @e[tag=init,limit=1] Pos[0] 1000
execute store result score #var1 mrcd_system run data get entity @e[tag=init,limit=1] Pos[1] 1000
execute store result score #var2 mrcd_system run data get entity @e[tag=init,limit=1] Pos[2] 1000
scoreboard players operation @e[tag=init,limit=1] mrcd_x0 -= #var0 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_y0 -= #var1 mrcd_system
scoreboard players operation @e[tag=init,limit=1] mrcd_z0 -= #var2 mrcd_system

# Rotate to the moving direction and placed it to player eyes
execute at @s anchored eyes positioned ^ ^ ^ run tp @e[tag=init,limit=1] ~ ~ ~ ~ ~

# Clear tag
tag @e[tag=init] remove init
Loading

0 comments on commit 9f6d94f

Please sign in to comment.