Added Hammer
Added Unbreaking tag Renamed rayloop to loop
This commit is contained in:
22
data/lzstools_hammer/function/break/break.mcfunction
Normal file
22
data/lzstools_hammer/function/break/break.mcfunction
Normal file
@@ -0,0 +1,22 @@
|
||||
execute if block ~ ~ ~ #lzstools:unbreakable run return fail
|
||||
execute if block ~ ~ ~ #minecraft:air run return fail
|
||||
execute if score @s lzt_hammer_damage >= @s lzt_hammer_max_damage run return fail
|
||||
|
||||
|
||||
# Spawn item
|
||||
loot spawn ~ ~ ~ mine ~ ~ ~ mainhand
|
||||
|
||||
|
||||
# Break to update neighbors
|
||||
clone ~ ~ ~ ~ ~ ~ ~ -64 ~ replace
|
||||
setblock ~ ~ ~ minecraft:air replace
|
||||
|
||||
# Break
|
||||
gamerule doTileDrops false
|
||||
clone ~ -64 ~ ~ -64 ~ ~ ~ ~ replace
|
||||
setblock ~ -64 ~ minecraft:bedrock replace
|
||||
setblock ~ ~ ~ minecraft:air destroy
|
||||
gamerule doTileDrops true
|
||||
|
||||
# Durability
|
||||
function lzstools_hammer:durability/handle
|
8
data/lzstools_hammer/function/break/eastwest.mcfunction
Normal file
8
data/lzstools_hammer/function/break/eastwest.mcfunction
Normal file
@@ -0,0 +1,8 @@
|
||||
execute positioned ~ ~1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~1 ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~1 ~-1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~ ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~ ~-1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~-1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~-1 ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~-1 ~-1 run function lzstools_hammer:break/break
|
@@ -0,0 +1,8 @@
|
||||
execute positioned ~ ~1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~1 ~1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~1 ~ ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~ ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~-1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~1 ~-1 ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~-1 ~ run function lzstools_hammer:break/break
|
8
data/lzstools_hammer/function/break/updown.mcfunction
Normal file
8
data/lzstools_hammer/function/break/updown.mcfunction
Normal file
@@ -0,0 +1,8 @@
|
||||
execute positioned ~1 ~ ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~1 ~ ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~1 ~ ~-1 run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~ ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~ ~ run function lzstools_hammer:break/break
|
||||
execute positioned ~-1 ~ ~-1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~ ~1 run function lzstools_hammer:break/break
|
||||
execute positioned ~ ~ ~-1 run function lzstools_hammer:break/break
|
@@ -0,0 +1 @@
|
||||
$item modify entity @s weapon.mainhand {"function":"minecraft:set_components","components":{"minecraft:damage":$(damage)}}
|
@@ -0,0 +1,3 @@
|
||||
execute if entity @s[predicate=lzstools_hammer:hammer] at @s anchored eyes run particle minecraft:item{item:"minecraft:iron_pickaxe"} ^ ^-0.35 ^0.65 0.1 0.1 0.1 0.06 10 force
|
||||
item replace entity @s weapon.mainhand with minecraft:air
|
||||
playsound minecraft:entity.item.break master @a ~ ~ ~ 1 1
|
13
data/lzstools_hammer/function/durability/handle.mcfunction
Normal file
13
data/lzstools_hammer/function/durability/handle.mcfunction
Normal file
@@ -0,0 +1,13 @@
|
||||
scoreboard players reset @s lzt_hammer_unbreaking_check
|
||||
execute if entity @s[predicate=lzstools:unbreaking/all] run function lzstools_hammer:durability/unbreaking
|
||||
execute if score @s lzt_hammer_unbreaking_check matches 1 run return fail
|
||||
|
||||
# Handle Damage
|
||||
data modify storage lzstools:hammer components set from entity @s SelectedItem.components
|
||||
execute store result score @s lzt_hammer_damage run data get storage lzstools:hammer components."minecraft:damage"
|
||||
execute store result score @s lzt_hammer_max_damage run data get storage lzstools:hammer components."minecraft:max_damage"
|
||||
scoreboard players add @s lzt_hammer_damage 1
|
||||
execute store result storage lzstools:hammer damage int 1 run scoreboard players get @s lzt_hammer_damage
|
||||
|
||||
function lzstools_hammer:durability/apply with storage lzstools:hammer
|
||||
execute if score @s lzt_hammer_damage >= @s lzt_hammer_max_damage run function lzstools_hammer:durability/break
|
@@ -0,0 +1,4 @@
|
||||
execute store result score @s lzt_hammer_unbreaking_chance run random value 1..100
|
||||
execute if entity @s[predicate=lzstools:unbreaking/mainhand/3] if score @s lzt_hammer_unbreaking_chance matches ..75 run return run scoreboard players set @s lzt_hammer_unbreaking_check 1
|
||||
execute if entity @s[predicate=lzstools:unbreaking/mainhand/2] if score @s lzt_hammer_unbreaking_chance matches ..66 run return run scoreboard players set @s lzt_hammer_unbreaking_check 1
|
||||
execute if entity @s[predicate=lzstools:unbreaking/mainhand/1] if score @s lzt_hammer_unbreaking_chance matches ..50 run return run scoreboard players set @s lzt_hammer_unbreaking_check 1
|
2
data/lzstools_hammer/function/mainhand.mcfunction
Normal file
2
data/lzstools_hammer/function/mainhand.mcfunction
Normal file
@@ -0,0 +1,2 @@
|
||||
scoreboard players set @s lzt_hammer_check 0
|
||||
function lzstools_hammer:raycast/start
|
15
data/lzstools_hammer/function/raycast/hit.mcfunction
Normal file
15
data/lzstools_hammer/function/raycast/hit.mcfunction
Normal file
@@ -0,0 +1,15 @@
|
||||
## Raycast Hit
|
||||
|
||||
scoreboard players set @s lzt_hammer_raycast_hit 1
|
||||
|
||||
setblock ~ ~ ~ minecraft:barrier replace
|
||||
# Get Raycast Target Coords
|
||||
function lzstools_hammer:raycast_side/start
|
||||
setblock ~ ~ ~ minecraft:air replace
|
||||
|
||||
execute if score px lzt_hammer_side_raycast matches 0 run return run function lzstools_hammer:break/eastwest
|
||||
execute if score px lzt_hammer_side_raycast matches 15 run return run function lzstools_hammer:break/eastwest
|
||||
execute if score pz lzt_hammer_side_raycast matches 0 run return run function lzstools_hammer:break/northsouth
|
||||
execute if score pz lzt_hammer_side_raycast matches 15 run return run function lzstools_hammer:break/northsouth
|
||||
execute if score py lzt_hammer_side_raycast matches 0 run return run function lzstools_hammer:break/updown
|
||||
execute if score py lzt_hammer_side_raycast matches 15 run return run function lzstools_hammer:break/updown
|
7
data/lzstools_hammer/function/raycast/loop.mcfunction
Normal file
7
data/lzstools_hammer/function/raycast/loop.mcfunction
Normal file
@@ -0,0 +1,7 @@
|
||||
## Raycast Loop
|
||||
|
||||
execute as @s at @n[type=item,nbt={Age:0s},distance=..0.8] run function lzstools_hammer:raycast/hit
|
||||
|
||||
# Advance forward and if nothing found
|
||||
scoreboard players add #distance lzt_hammer_raycast 1
|
||||
execute if score @s lzt_hammer_raycast_hit matches 0 if score #distance lzt_hammer_raycast matches ..451 positioned ^ ^ ^0.01 run function lzstools_hammer:raycast/loop
|
12
data/lzstools_hammer/function/raycast/start.mcfunction
Normal file
12
data/lzstools_hammer/function/raycast/start.mcfunction
Normal file
@@ -0,0 +1,12 @@
|
||||
## Raycast Start
|
||||
scoreboard players set #distance lzt_hammer_raycast 0
|
||||
scoreboard players set @s lzt_hammer_raycast_hit 0
|
||||
|
||||
|
||||
# Raycast
|
||||
execute as @s at @s anchored eyes positioned ^ ^ ^ anchored feet run function lzstools_hammer:raycast/loop
|
||||
|
||||
# Clean Data
|
||||
data remove storage lzstools:hammer damage
|
||||
scoreboard players set @s lzt_hammer_damage 0
|
||||
scoreboard players set @s lzt_hammer_max_damage 1
|
@@ -0,0 +1,9 @@
|
||||
## Raycast Loop
|
||||
|
||||
execute if block ~ ~ ~ minecraft:barrier run scoreboard players set @s lzt_hammer_side_raycast_hit 1
|
||||
|
||||
execute if score @s lzt_hammer_side_raycast_hit matches 1 run function lzstools_hammer:raycast_side/target_coords
|
||||
|
||||
# Advance forward and if nothing found
|
||||
scoreboard players add #distance lzt_hammer_side_raycast 1
|
||||
execute if score @s lzt_hammer_side_raycast_hit matches 0 if score #distance lzt_hammer_side_raycast matches ..451 positioned ^ ^ ^0.01 run function lzstools_hammer:raycast_side/loop
|
@@ -0,0 +1,8 @@
|
||||
## Raycast Start
|
||||
scoreboard players set #distance lzt_hammer_side_raycast 0
|
||||
scoreboard players set @s lzt_hammer_side_raycast_hit 0
|
||||
|
||||
# Raycast
|
||||
execute as @s at @s anchored eyes positioned ^ ^ ^ anchored feet run function lzstools_hammer:raycast_side/loop
|
||||
|
||||
# Clean Data
|
@@ -0,0 +1,22 @@
|
||||
## Get Raycast Target Coords
|
||||
|
||||
# Stored Value for Calc
|
||||
scoreboard players set c16 lzt_hammer_side_raycast 16
|
||||
# Summon Invisible Entity
|
||||
summon area_effect_cloud ~ ~ ~ {Radius:0.01,Duration:1,Tags:["RaycastMark"]}
|
||||
|
||||
# Pixel Calculations
|
||||
execute store result score px lzt_hammer_side_raycast run data get entity @e[tag=RaycastMark,sort=nearest,limit=1] Pos[0] 16
|
||||
scoreboard players operation px lzt_hammer_side_raycast %= c16 lzt_hammer_side_raycast
|
||||
execute if score px lzt_hammer_side_raycast matches ..-1 run scoreboard players add px lzt_hammer_side_raycast 16
|
||||
|
||||
execute store result score py lzt_hammer_side_raycast run data get entity @e[tag=RaycastMark,sort=nearest,limit=1] Pos[1] 16
|
||||
scoreboard players operation py lzt_hammer_side_raycast %= c16 lzt_hammer_side_raycast
|
||||
execute if score py lzt_hammer_side_raycast matches ..-1 run scoreboard players add py lzt_hammer_side_raycast 16
|
||||
|
||||
execute store result score pz lzt_hammer_side_raycast run data get entity @e[tag=RaycastMark,sort=nearest,limit=1] Pos[2] 16
|
||||
scoreboard players operation pz lzt_hammer_side_raycast %= c16 lzt_hammer_side_raycast
|
||||
execute if score pz lzt_hammer_side_raycast matches ..-1 run scoreboard players add pz lzt_hammer_side_raycast 16
|
||||
|
||||
# Remove Entity
|
||||
kill @e[tag=RaycastMark,sort=nearest,limit=1]
|
Reference in New Issue
Block a user