-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feb28d3
commit a8abe8d
Showing
14 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Reset Storage | ||
data remove storage custom_blocks:drop_block id | ||
data remove storage custom_blocks:drop_block DisplayName | ||
data remove storage custom_blocks:drop_block Lore | ||
data remove storage custom_blocks:drop_block CustomModelData | ||
data remove storage custom_blocks:drop_block CustomName | ||
data remove storage custom_blocks:drop_block Tags | ||
data remove storage custom_blocks:drop_block SetblockCommand | ||
|
||
# Check If Custom Block Has Been Broken Then Store Block Info In Storage | ||
execute as @e[type=armor_stand,tag=customBlock] at @s if block ~ ~ ~ air run tag @s add spawn_drop | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block id set from entity @s ArmorItems[3].id | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block DisplayName set from entity @s ArmorItems[3].tag.display.Name | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block Lore set from entity @s ArmorItems[3].tag.display.Lore | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block CustomModelData set from entity @s ArmorItems[3].tag.CustomModelData | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block CustomName set from entity @s CustomName | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block Tags set from entity @s ArmorItems[3].tag.BlockProperties.Tags | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,predicate=custom_blocks:is_placer] at @s run data modify storage custom_blocks:drop_block SetblockCommand set from entity @s ArmorItems[3].tag.BlockProperties.SetblockCommand | ||
|
||
# Apply Block Info To Item | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.id set from storage custom_blocks:drop_block id | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.display.Name set from storage custom_blocks:drop_block DisplayName | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.display.Lore set from storage custom_blocks:drop_block Lore | ||
# Set Model If Normal | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=!up,tag=!down] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.CustomModelData set from storage custom_blocks:drop_block CustomModelData | ||
# Set Model To Normal If Up | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=up,tag=!down] at @s store result score +ModelID SetModel run data get storage custom_blocks:drop_block CustomModelData | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=up,tag=!down] at @s run scoreboard players operation +ModelID SetModel -= +Plus1 cbapiConstent | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=up,tag=!down] at @s store result storage custom_blocks:drop_block CustomModelData int 1 run scoreboard players get +ModelID SetModel | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=up,tag=!down] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.CustomModelData set from storage custom_blocks:drop_block CustomModelData | ||
# Set Model To Normal If Down | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=!up,tag=down] at @s store result score +ModelID SetModel run data get storage custom_blocks:drop_block CustomModelData | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=!up,tag=down] at @s run scoreboard players operation +ModelID SetModel -= +Plus2 cbapiConstent | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=!up,tag=down] at @s store result storage custom_blocks:drop_block CustomModelData int 1 run scoreboard players get +ModelID SetModel | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop,tag=!up,tag=down] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.CustomModelData set from storage custom_blocks:drop_block CustomModelData | ||
|
||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockEntityTag.Lock set value "CustomBlocks:Block" | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockProperties.CustomName set from storage custom_blocks:drop_block CustomName | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockProperties.Tags set from storage custom_blocks:drop_block Tags | ||
execute as @e[type=armor_stand,tag=customBlock,tag=spawn_drop] at @s run data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockProperties.SetblockCommand set from storage custom_blocks:drop_block SetblockCommand | ||
|
||
# Kill Armor Stand | ||
execute as @e[type=armor_stand,tag=customBlock] at @s if block ~ ~ ~ air run kill @s | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
execute as @a run function custom_blocks:place/set_storage | ||
function custom_blocks:break/spawn_drop | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
data/custom_blocks/functions/place/check_for_block.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Detects Custom Block And Places It | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=north]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=north]{Lock:"CustomBlocks:Block"} | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=south]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=south]{Lock:"CustomBlocks:Block"} | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=east]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=east]{Lock:"CustomBlocks:Block"} | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=west]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=west]{Lock:"CustomBlocks:Block"} | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=up]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=up]{Lock:"CustomBlocks:Block"} | ||
execute at @a run fill ~5 ~6 ~5 ~-5 ~-4 ~-5 command_block[facing=down]{auto:1b,Command:"function custom_blocks:place/place_block"} replace #custom_blocks:placers[facing=down]{Lock:"CustomBlocks:Block"} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Places The Base Block Armor Stand | ||
execute if block ~ ~ ~ command_block[facing=north] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[0.0f,0.0f],Tags:["customBlock","placing"]} | ||
execute if block ~ ~ ~ command_block[facing=south] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[180.0f,0.0f],Tags:["customBlock","placing"]} | ||
execute if block ~ ~ ~ command_block[facing=east] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[90.0f,0.0f],Tags:["customBlock","placing"]} | ||
execute if block ~ ~ ~ command_block[facing=west] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[-90.0f,0.0f],Tags:["customBlock","placing"]} | ||
execute if block ~ ~ ~ command_block[facing=up] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[0.0f,0.0f],Tags:["customBlock","placing","up"]} | ||
execute if block ~ ~ ~ command_block[facing=down] align xyz positioned ~0.5 ~ ~0.5 run summon armor_stand ~ ~ ~ {Invisible:1b,NoGravity:1b,Marker:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}],Rotation:[0.0f,0.0f],Tags:["customBlock","placing","down"]} | ||
|
||
# Updates The Base Block To Include All The Block Info From Storage | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].id set from storage custom_blocks:current_block id | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.display.Name set from storage custom_blocks:current_block DisplayName | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.display.Lore set from storage custom_blocks:current_block Lore | ||
# Set Model If Normal | ||
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=!down] at @s run data modify entity @s ArmorItems[3].tag.CustomModelData set from storage custom_blocks:current_block CustomModelData | ||
# Set Model If Facing Up | ||
execute as @e[type=armor_stand,tag=placing,tag=up,tag=!down] at @s store result score +ModelID SetModel run data get storage custom_blocks:current_block CustomModelData | ||
execute as @e[type=armor_stand,tag=placing,tag=up,tag=!down] at @s run scoreboard players operation +ModelID SetModel += +Plus1 cbapiConstent | ||
execute as @e[type=armor_stand,tag=placing,tag=up,tag=!down] at @s store result storage custom_blocks:current_block CustomModelData int 1 run scoreboard players get +ModelID SetModel | ||
execute as @e[type=armor_stand,tag=placing,tag=up,tag=!down] at @s run data modify entity @s ArmorItems[3].tag.CustomModelData set from storage custom_blocks:current_block CustomModelData | ||
# Set Model If Facing Down | ||
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=down] at @s store result score +ModelID SetModel run data get storage custom_blocks:current_block CustomModelData | ||
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=down] at @s run scoreboard players operation +ModelID SetModel += +Plus2 cbapiConstent | ||
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=down] at @s store result storage custom_blocks:current_block CustomModelData int 1 run scoreboard players get +ModelID SetModel | ||
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=down] at @s run data modify entity @s ArmorItems[3].tag.CustomModelData set from storage custom_blocks:current_block CustomModelData | ||
|
||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.BlockEntityTag.Lock set value "CustomBlocks:Block" | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.BlockProperties.CustomName set from storage custom_blocks:current_block CustomName | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.BlockProperties.Tags set from storage custom_blocks:current_block Tags | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s CustomName set from storage custom_blocks:current_block CustomName | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.BlockProperties.SetblockCommand set from storage custom_blocks:current_block SetblockCommand | ||
|
||
# Remove Temporary Tag And Set Base Block | ||
setblock ~ ~ ~ stone | ||
setblock ~ ~ ~ command_block{Command:""} | ||
execute as @e[type=armor_stand,tag=placing] at @s run data modify block ~ ~ ~ Command set from storage custom_blocks:current_block SetblockCommand | ||
execute as @e[type=armor_stand,tag=placing] at @s run data merge block ~ ~ ~ {auto:1b} | ||
execute as @e[type=armor_stand,tag=placing] at @s run tag @e[type=armor_stand,tag=placing] remove placing | ||
|
||
# Resets Storage After Player Places Custom Block Or Deselects It | ||
execute as @a[gamemode=!creative,predicate=custom_blocks:selected_placer] run function custom_blocks:place/reset_storage | ||
|
10 changes: 10 additions & 0 deletions
10
data/custom_blocks/functions/place/reset_storage.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Resets Block Info Storage | ||
data remove storage custom_blocks:current_block id | ||
data remove storage custom_blocks:current_block DisplayName | ||
data remove storage custom_blocks:current_block Lore | ||
data remove storage custom_blocks:current_block CustomModelData | ||
data remove storage custom_blocks:current_block CustomName | ||
data remove storage custom_blocks:current_block Tags | ||
data remove storage custom_blocks:current_block SetblockCommand | ||
scoreboard players set +ModelID SetModel 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Resets Storage After Player Places Custom Block Or Deselects It | ||
execute as @a[gamemode=creative,predicate=custom_blocks:selected_placer] run function custom_blocks:place/reset_storage | ||
|
||
# Saves All Block Info Into A Storage For When Placing | ||
data modify storage custom_blocks:current_block CustomModelData set from entity @s SelectedItem.tag.CustomModelData | ||
execute if entity @s[predicate=custom_blocks:selected_placer] run data modify storage custom_blocks:current_block id set from entity @s SelectedItem.id | ||
data modify storage custom_blocks:current_block DisplayName set from entity @s SelectedItem.tag.display.Name | ||
data modify storage custom_blocks:current_block Lore set from entity @s SelectedItem.tag.display.Lore | ||
data modify storage custom_blocks:current_block CustomName set from entity @s SelectedItem.tag.BlockProperties.CustomName | ||
data modify storage custom_blocks:current_block Tags set from entity @s SelectedItem.tag.BlockProperties.Tags | ||
data modify storage custom_blocks:current_block SetblockCommand set from entity @s SelectedItem.tag.BlockProperties.SetblockCommand | ||
|
||
|
||
# Runs The Check Block Function | ||
function custom_blocks:place/check_for_block | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
gamerule commandBlockOutput false | ||
gamerule logAdminCommands false | ||
|
||
scoreboard objectives add SetModel dummy | ||
scoreboard objectives add cbapiConstent dummy | ||
|
||
scoreboard players set +ModelID SetModel 0 | ||
scoreboard players set +Plus1 cbapiConstent 1 | ||
scoreboard players set +Plus2 cbapiConstent 2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"condition": "entity_properties", | ||
"entity": "this", | ||
"predicate": { | ||
"equipment": { | ||
"head": { | ||
"tag": "custom_blocks:placers" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"condition": "entity_properties", | ||
"entity": "this", | ||
"predicate": { | ||
"equipment": { | ||
"mainhand": { | ||
"tag": "custom_blocks:placers" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"values": [ | ||
"minecraft:furnace", | ||
"minecraft:dropper", | ||
"minecraft:dispenser" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"values": [ | ||
"minecraft:furnace", | ||
"minecraft:dropper", | ||
"minecraft:dispenser" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"custom_blocks:setup" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"custom_blocks:main" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pack": { | ||
"pack_format": 6, | ||
"description": "Allows you to add new blocks easily" | ||
} | ||
} |