Skip to content

Commit a8abe8d

Browse files
Moved datapack out of extra folder
1 parent feb28d3 commit a8abe8d

14 files changed

+189
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Reset Storage
2+
data remove storage custom_blocks:drop_block id
3+
data remove storage custom_blocks:drop_block DisplayName
4+
data remove storage custom_blocks:drop_block Lore
5+
data remove storage custom_blocks:drop_block CustomModelData
6+
data remove storage custom_blocks:drop_block CustomName
7+
data remove storage custom_blocks:drop_block Tags
8+
data remove storage custom_blocks:drop_block SetblockCommand
9+
10+
# Check If Custom Block Has Been Broken Then Store Block Info In Storage
11+
execute as @e[type=armor_stand,tag=customBlock] at @s if block ~ ~ ~ air run tag @s add spawn_drop
12+
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
13+
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
14+
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
15+
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
16+
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
17+
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
18+
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
19+
20+
# Apply Block Info To Item
21+
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
22+
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
23+
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
24+
# Set Model If Normal
25+
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
26+
# Set Model To Normal If Up
27+
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
28+
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
29+
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
30+
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
31+
# Set Model To Normal If Down
32+
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
33+
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
34+
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
35+
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
36+
37+
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"
38+
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
39+
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
40+
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
41+
42+
# Kill Armor Stand
43+
execute as @e[type=armor_stand,tag=customBlock] at @s if block ~ ~ ~ air run kill @s
44+
45+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
execute as @a run function custom_blocks:place/set_storage
2+
function custom_blocks:break/spawn_drop
3+
4+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Detects Custom Block And Places It
2+
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"}
3+
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"}
4+
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"}
5+
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"}
6+
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"}
7+
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"}
8+
9+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Places The Base Block Armor Stand
2+
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"]}
3+
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"]}
4+
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"]}
5+
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"]}
6+
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"]}
7+
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"]}
8+
9+
# Updates The Base Block To Include All The Block Info From Storage
10+
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
11+
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
12+
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
13+
# Set Model If Normal
14+
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
15+
# Set Model If Facing Up
16+
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
17+
execute as @e[type=armor_stand,tag=placing,tag=up,tag=!down] at @s run scoreboard players operation +ModelID SetModel += +Plus1 cbapiConstent
18+
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
19+
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
20+
# Set Model If Facing Down
21+
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
22+
execute as @e[type=armor_stand,tag=placing,tag=!up,tag=down] at @s run scoreboard players operation +ModelID SetModel += +Plus2 cbapiConstent
23+
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
24+
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
25+
26+
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s ArmorItems[3].tag.BlockEntityTag.Lock set value "CustomBlocks:Block"
27+
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
28+
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
29+
execute as @e[type=armor_stand,tag=placing] at @s run data modify entity @s CustomName set from storage custom_blocks:current_block CustomName
30+
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
31+
32+
# Remove Temporary Tag And Set Base Block
33+
setblock ~ ~ ~ stone
34+
setblock ~ ~ ~ command_block{Command:""}
35+
execute as @e[type=armor_stand,tag=placing] at @s run data modify block ~ ~ ~ Command set from storage custom_blocks:current_block SetblockCommand
36+
execute as @e[type=armor_stand,tag=placing] at @s run data merge block ~ ~ ~ {auto:1b}
37+
execute as @e[type=armor_stand,tag=placing] at @s run tag @e[type=armor_stand,tag=placing] remove placing
38+
39+
# Resets Storage After Player Places Custom Block Or Deselects It
40+
execute as @a[gamemode=!creative,predicate=custom_blocks:selected_placer] run function custom_blocks:place/reset_storage
41+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Resets Block Info Storage
2+
data remove storage custom_blocks:current_block id
3+
data remove storage custom_blocks:current_block DisplayName
4+
data remove storage custom_blocks:current_block Lore
5+
data remove storage custom_blocks:current_block CustomModelData
6+
data remove storage custom_blocks:current_block CustomName
7+
data remove storage custom_blocks:current_block Tags
8+
data remove storage custom_blocks:current_block SetblockCommand
9+
scoreboard players set +ModelID SetModel 0
10+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Resets Storage After Player Places Custom Block Or Deselects It
2+
execute as @a[gamemode=creative,predicate=custom_blocks:selected_placer] run function custom_blocks:place/reset_storage
3+
4+
# Saves All Block Info Into A Storage For When Placing
5+
data modify storage custom_blocks:current_block CustomModelData set from entity @s SelectedItem.tag.CustomModelData
6+
execute if entity @s[predicate=custom_blocks:selected_placer] run data modify storage custom_blocks:current_block id set from entity @s SelectedItem.id
7+
data modify storage custom_blocks:current_block DisplayName set from entity @s SelectedItem.tag.display.Name
8+
data modify storage custom_blocks:current_block Lore set from entity @s SelectedItem.tag.display.Lore
9+
data modify storage custom_blocks:current_block CustomName set from entity @s SelectedItem.tag.BlockProperties.CustomName
10+
data modify storage custom_blocks:current_block Tags set from entity @s SelectedItem.tag.BlockProperties.Tags
11+
data modify storage custom_blocks:current_block SetblockCommand set from entity @s SelectedItem.tag.BlockProperties.SetblockCommand
12+
13+
14+
# Runs The Check Block Function
15+
function custom_blocks:place/check_for_block
16+
17+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
gamerule commandBlockOutput false
2+
gamerule logAdminCommands false
3+
4+
scoreboard objectives add SetModel dummy
5+
scoreboard objectives add cbapiConstent dummy
6+
7+
scoreboard players set +ModelID SetModel 0
8+
scoreboard players set +Plus1 cbapiConstent 1
9+
scoreboard players set +Plus2 cbapiConstent 2
10+
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"condition": "entity_properties",
3+
"entity": "this",
4+
"predicate": {
5+
"equipment": {
6+
"head": {
7+
"tag": "custom_blocks:placers"
8+
}
9+
}
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"condition": "entity_properties",
3+
"entity": "this",
4+
"predicate": {
5+
"equipment": {
6+
"mainhand": {
7+
"tag": "custom_blocks:placers"
8+
}
9+
}
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"values": [
3+
"minecraft:furnace",
4+
"minecraft:dropper",
5+
"minecraft:dispenser"
6+
]
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"values": [
3+
"minecraft:furnace",
4+
"minecraft:dropper",
5+
"minecraft:dispenser"
6+
]
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"custom_blocks:setup"
4+
]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"custom_blocks:main"
4+
]
5+
}

pack.mcmeta

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pack": {
3+
"pack_format": 6,
4+
"description": "Allows you to add new blocks easily"
5+
}
6+
}

0 commit comments

Comments
 (0)