Skip to content

Commit 08b93a0

Browse files
committed
Updated to 1.20.5/6
1 parent 51e4d2a commit 08b93a0

17 files changed

+63
-85
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To use the Custom Blocks API simply include it alongside your datapack and ensur
88
### Give Command
99
If your pack includes a custom give command this is what the function should look like with this API:
1010
```mcfunction
11-
give @s dropper{display:{Name:'{"text":"A Name","italic":false}',Lore:['{"text":"A Lore","italic":false,"color":"red"}']},CustomModelData:0000001,BlockEntityTag:{Lock:"CustomBlocks:Block"},BlockProperties:{Tags:["some_tag_for_this_block"],BaseBlock:{"value":"stone"}}}
11+
give @s dropper[item_name='{"text":"A Name"}',lore=['{"text":"A Lore","italic":false,"color":"red"}'],custom_model_data="0000001",lock="custom_blocks:block",custom_data={block_properties:{Tags:["some_tag_for_this_block"],base_block:{value:"stone"}}}]
1212
```
1313

1414
To set up your custom blocks with this API simple add the custom models to one of the following blocks with "custom_model_data":
@@ -19,18 +19,18 @@ To set up your custom blocks with this API simple add the custom models to one o
1919

2020
<hr>
2121

22-
<b>Make Sure To Include</b> the Lock in the BlockEntityTag and set its value to <b>"CustomBlocks:Block"</b><br>
22+
<b>Make Sure To Include</b> the lock component and set its value to <b>"custom_blocks:block"</b><br>
2323
This tells the API that your block uses this Custom Blocks API system.
2424

25-
Then add your custom block name and an optional lore for the block. Outside the display tag add your custom blocks CustomModelData value.
25+
Then add your custom block name, an optional lore for the block, and add your custom blocks custom_model_data value.
2626

27-
Finally, add any extra information about the block for when it's placed in the "BlockProperties" tag. All the information in this tag will be copied to the Item Display, the "BaseBlock" in BlockProperties says what you want your base block to be, the value must be a valid block id.
27+
Finally, add any extra information about the block for when it's placed in the "block_properties" tag. All the information in this tag will be copied to the Item Display, the "base_block" in block_properties says what you want your base block to be, the value must be a valid block id.
2828

2929
For help on how to set these up see the above give command for an example.
3030

3131
## Minimum Minecraft Version
3232

33-
* 1.20.3
33+
* 1.20.5
3434

3535
## About This Project
3636

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.id set from storage custom_blocks:drop_block id
2-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.display.Name set from storage custom_blocks:drop_block DisplayName
3-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.display.Lore set from storage custom_blocks:drop_block Lore
4-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.CustomModelData set from storage custom_blocks:drop_block CustomModelData
5-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockEntityTag.Lock set value "CustomBlocks:Block"
6-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockProperties.Tags set from storage custom_blocks:drop_block Tags
7-
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.tag.BlockProperties.BaseBlock set from storage custom_blocks:drop_block BaseBlock
2+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:item_name set from storage custom_blocks:drop_block item_name
3+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:lore set from storage custom_blocks:drop_block lore
4+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:custom_model_data set from storage custom_blocks:drop_block custom_model_data
5+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:lock set value "custom_blocks:block"
6+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:custom_data.block_properties.Tags set from storage custom_blocks:drop_block Tags
7+
data modify entity @e[type=item,distance=..1,sort=nearest,limit=1] Item.components.minecraft:custom_data.block_properties.base_block set from storage custom_blocks:drop_block base_block
88

99
execute if block ~ ~ ~ air run kill @s
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
data modify storage custom_blocks:drop_block id set from entity @s item.id
2-
data modify storage custom_blocks:drop_block DisplayName set from entity @s item.tag.display.CustomName
3-
data modify storage custom_blocks:drop_block Lore set from entity @s item.tag.display.Lore
4-
data modify storage custom_blocks:drop_block CustomModelData set from entity @s item.tag.CustomModelData
5-
data modify storage custom_blocks:drop_block Tags set from entity @s item.tag.BlockProperties.Tags
6-
data modify storage custom_blocks:drop_block BaseBlock set from entity @s item.tag.BlockProperties.BaseBlock
2+
data modify storage custom_blocks:drop_block item_name set from entity @s item.components.minecraft:item_name
3+
data modify storage custom_blocks:drop_block lore set from entity @s item.components.minecraft:lore
4+
data modify storage custom_blocks:drop_block custom_model_data set from entity @s item.components.minecraft:custom_model_data
5+
data modify storage custom_blocks:drop_block Tags set from entity @s item.components.minecraft:custom_data.block_properties.Tags
6+
data modify storage custom_blocks:drop_block base_block set from entity @s item.components.minecraft:custom_data.block_properties.base_block

data/custom_blocks/functions/break/spawn_drop.mcfunction

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Reset Storage
22
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
3+
data remove storage custom_blocks:drop_block item_name
4+
data remove storage custom_blocks:drop_block lore
5+
data remove storage custom_blocks:drop_block custom_model_data
66
data remove storage custom_blocks:drop_block Tags
7-
data remove storage custom_blocks:drop_block BaseBlock
7+
data remove storage custom_blocks:drop_block base_block
88

99
# Check If Custom Block Has Been Broken Then Store Block Info In Storage
1010
execute as @e[type=item_display,tag=customBlock] at @s if block ~ ~ ~ air run tag @s add spawn_drop
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
execute as @a run function custom_blocks:place/set_storage
2-
function custom_blocks:break/spawn_drop
2+
3+
# Update old lock "CustomBlocks:Block" to "custom_blocks:block"
4+
execute as @a if items entity @s weapon.* #custom_blocks:placers[minecraft:lock="CustomBlocks:Block"] run item modify entity @s weapon.mainhand custom_blocks:update_lock
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
data modify entity @s item.id set from storage custom_blocks:current_block id
2-
data modify entity @s item.tag.display.CustomName set from storage custom_blocks:current_block DisplayName
3-
data modify entity @s item.tag.display.Lore set from storage custom_blocks:current_block Lore
2+
data modify entity @s item.components.minecraft:item_name set from storage custom_blocks:current_block item_name
3+
data modify entity @s item.components.minecraft:lore set from storage custom_blocks:current_block lore
44

55
# Set Model
6-
data modify entity @s item.tag.CustomModelData set from storage custom_blocks:current_block CustomModelData
7-
data modify entity @s item.tag.BlockEntityTag.Lock set value "CustomBlocks:Block"
8-
data modify entity @s item.tag.BlockProperties.Tags set from storage custom_blocks:current_block Tags
6+
data modify entity @s item.components.minecraft:custom_model_data set from storage custom_blocks:current_block custom_model_data
7+
data modify entity @s item.components.minecraft:lock set value "custom_blocks:block"
8+
data modify entity @s item.components.minecraft:custom_data.block_properties.Tags set from storage custom_blocks:current_block Tags
99
data modify entity @s Tags set from storage custom_blocks:current_block Tags
1010
tag @s add customBlock
11-
data modify entity @s item.tag.BlockProperties.BaseBlock set from storage custom_blocks:current_block BaseBlock
11+
data modify entity @s item.components.minecraft:custom_data.block_properties.base_block set from storage custom_blocks:current_block base_block
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 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"}
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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=north]{Lock:"custom_blocks: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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=south]{Lock:"custom_blocks: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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=east]{Lock:"custom_blocks: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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=west]{Lock:"custom_blocks: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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=up]{Lock:"custom_blocks: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 with storage custom_blocks:current_block base_block"} replace #custom_blocks:placers[facing=down]{Lock:"custom_blocks:block"}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Places The Base Block Armor Stand
2-
execute if block ~ ~ ~ command_block[facing=north] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,0.0f],Tags:["customBlock","placing"]}
3-
execute if block ~ ~ ~ command_block[facing=south] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[-180.0f,0.0f],Tags:["customBlock","placing"]}
4-
execute if block ~ ~ ~ command_block[facing=east] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[90.0f,0.0f],Tags:["customBlock","placing"]}
5-
execute if block ~ ~ ~ command_block[facing=west] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[-90.0f,0.0f],Tags:["customBlock","placing"]}
6-
execute if block ~ ~ ~ command_block[facing=up] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,90.0f],Tags:["customBlock","placing","up"]}
7-
execute if block ~ ~ ~ command_block[facing=down] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",Count:1b},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,-90.0f],Tags:["customBlock","placing","down"]}
1+
# Spawns The Item Display
2+
execute if block ~ ~ ~ command_block[facing=north] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,0.0f],Tags:["customBlock","placing"]}
3+
execute if block ~ ~ ~ command_block[facing=south] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[-180.0f,0.0f],Tags:["customBlock","placing"]}
4+
execute if block ~ ~ ~ command_block[facing=east] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[90.0f,0.0f],Tags:["customBlock","placing"]}
5+
execute if block ~ ~ ~ command_block[facing=west] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[-90.0f,0.0f],Tags:["customBlock","placing"]}
6+
execute if block ~ ~ ~ command_block[facing=up] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,90.0f],Tags:["customBlock","placing","up"]}
7+
execute if block ~ ~ ~ command_block[facing=down] align xyz positioned ~0.5 ~0.5 ~0.5 summon item_display run data merge entity @s {item:{id:"minecraft:stone",count:1},brightness:{block:0,sky:15},transformation:{scale:[1.003,1.003,1.003]},Rotation:[0.0f,-90.0f],Tags:["customBlock","placing","down"]}
88

9-
# Updates The Base Block To Include All The Block Info From Storage
9+
# Updates The Item Display To Include All The Block Info From Storage
1010
execute as @e[type=item_display,tag=placing] at @s run function custom_blocks:place/apply_block_info_from_storage
1111

1212
# Remove Temporary Tag And Set Base Block
13-
setblock ~ ~ ~ stone
14-
execute as @e[type=item_display,tag=placing] at @s run function custom_blocks:place/set_base_block with storage custom_blocks:current_block BaseBlock
13+
tag @s remove placing
14+
$setblock ~ ~ ~ $(value)
1515

1616
# Resets Storage After Player Places Custom Block Or Deselects It
1717
execute as @a[gamemode=!creative,predicate=!custom_blocks:selected_placer] run function custom_blocks:place/reset_storage
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Resets Block Info Storage
22
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
3+
data remove storage custom_blocks:current_block item_name
4+
data remove storage custom_blocks:current_block lore
5+
data remove storage custom_blocks:current_block custom_model_data
66
data remove storage custom_blocks:current_block Tags
7-
data remove storage custom_blocks:current_block BaseBlock
7+
data remove storage custom_blocks:current_block base_block

data/custom_blocks/functions/place/set_base_block.mcfunction

Lines changed: 0 additions & 2 deletions
This file was deleted.

data/custom_blocks/functions/place/set_storage.mcfunction

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
execute as @a[gamemode=creative,predicate=!custom_blocks:selected_placer] run function custom_blocks:place/reset_storage
33

44
# 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
5+
data modify storage custom_blocks:current_block custom_model_data set from entity @s SelectedItem.components.minecraft:custom_model_data
66
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 Tags set from entity @s SelectedItem.tag.BlockProperties.Tags
10-
data modify storage custom_blocks:current_block BaseBlock set from entity @s SelectedItem.tag.BlockProperties.BaseBlock
7+
data modify storage custom_blocks:current_block item_name set from entity @s SelectedItem.components.minecraft:item_name
8+
data modify storage custom_blocks:current_block lore set from entity @s SelectedItem.components.minecraft:lore
9+
data modify storage custom_blocks:current_block Tags set from entity @s SelectedItem.components.minecraft:custom_data.block_properties.Tags
10+
data modify storage custom_blocks:current_block base_block set from entity @s SelectedItem.components.minecraft:custom_data.block_properties.base_block
1111

1212
# Runs The Check Block Function
1313
function custom_blocks:place/check_for_block

data/custom_blocks/functions/setup.mcfunction

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ gamerule commandBlockOutput false
22
gamerule logAdminCommands false
33

44
# Remove old scoreboard objective
5-
# `scoreboard objectives remove cbCompareResult` is now deprecated and will be removed in a future version
6-
scoreboard objectives remove cbCompareResult
5+
# `scoreboard objectives remove cbCalcModel` is now deprecated and will be removed in a future version
76
scoreboard objectives remove cbCalcModel dummy
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"function": "set_components",
3+
"components": {"minecraft:lock": "custom_blocks:block"}
4+
}

data/custom_blocks/predicates/is_placer.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

data/custom_blocks/predicates/selected_placer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"predicate": {
55
"equipment": {
66
"mainhand": {
7-
"tag": "custom_blocks:placers"
7+
"items": "#custom_blocks:placers"
88
}
99
}
1010
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"values": [
3-
"custom_blocks:main"
3+
"custom_blocks:main",
4+
"custom_blocks:break/spawn_drop"
45
]
56
}

pack.mcmeta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pack": {
3-
"pack_format": 26,
3+
"pack_format": 41,
44
"description": "Allows you to add new blocks easily"
55
}
66
}

0 commit comments

Comments
 (0)