Skip to content

Commit

Permalink
Improved 'vegetation_overhaul' function
Browse files Browse the repository at this point in the history
- Added more block types for saplings to land on.
- Added sounds for each type of block.
- Added Azalea saplings and crops.
- Items will not be planted if player is near 3 block radius.
- Fixed items being deleted out of nothing.

Maybe a implementation until the end of this release is to add a chance for the sapling to be planted. It should be different from crops and should be configurable.
  • Loading branch information
SimplyCEO committed Jun 3, 2024
1 parent 158fce0 commit c0ff43c
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/crop §floaded."

# Init variables
scoreboard players set vo_crop_id count 0

# Get item stack count and remove 1
execute store result score @s count run data get entity @s Item.Count
scoreboard players remove @s count 1

# Identify the compatible block and the crop
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:wheat_seeds"}}] run scoreboard players set vo_crop_id count 1
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:pumpkin_seeds"}}] run scoreboard players set vo_crop_id count 2
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:melon_seeds"}}] run scoreboard players set vo_crop_id count 3
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:beetroot_seeds"}}] run scoreboard players set vo_crop_id count 4
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:potato"}}] run scoreboard players set vo_crop_id count 5
execute if block ~ ~ ~ minecraft:farmland if entity @s[nbt={Item:{id:"minecraft:carrot"}}] run scoreboard players set vo_crop_id count 6
execute if block ~ ~ ~ minecraft:soul_sand if entity @s[nbt={Item:{id:"minecraft:nether_wart"}}] run scoreboard players set vo_crop_id count 7

# Filter crops and handle events
execute unless block ~ ~1 ~ #minecraft:crops if score vo_crop_id count matches 1..6 run function hss:environment/vegetation_overhaul/plant/crop_normal
execute unless block ~ ~1 ~ minecraft:nether_wart if score vo_crop_id count matches 7 run function hss:environment/vegetation_overhaul/plant/crop_underworld

# Free from memory
scoreboard players reset @s count
scoreboard players reset vo_crop_id count
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@

execute as @e[type=minecraft:player,scores={debug=1,verbose=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/main §floaded."

# Plant only if current block is empty and under block is soil compatible
execute as @e[type=minecraft:item] at @s if block ~ ~ ~ minecraft:air if block ~ ~-1 ~ #minecraft:dirt run function hss:environment/vegetation_overhaul/plant
# Vegetation Overhaul events

## Crop: Plant only if current block is farmland/soul_sand
execute as @e[type=minecraft:item] at @s unless entity @e[type=minecraft:player,distance=..3] if block ~ ~ ~ #hss:plot run function hss:environment/vegetation_overhaul/crop

## Sapling: Plant only if current block is empty and under block is soil compatible
execute as @e[type=minecraft:item] at @s unless entity @e[type=minecraft:player,distance=..3] if block ~ ~ ~ minecraft:air if block ~ ~-1 ~ #minecraft:dirt run function hss:environment/vegetation_overhaul/sapling
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/plant/crop_normal §floaded."

# Handle stack only if crop block is already set
execute run function hss:environment/vegetation_overhaul/stack/crop_normal

# Spawn sapling block
execute if score vo_crop_id count matches 1 run setblock ~ ~1 ~ minecraft:wheat
execute if score vo_crop_id count matches 2 run setblock ~ ~1 ~ minecraft:pumpkin_stem
execute if score vo_crop_id count matches 3 run setblock ~ ~1 ~ minecraft:melon_stem
execute if score vo_crop_id count matches 4 run setblock ~ ~1 ~ minecraft:beetroots
execute if score vo_crop_id count matches 5 run setblock ~ ~1 ~ minecraft:potatoes
execute if score vo_crop_id count matches 6 run setblock ~ ~1 ~ minecraft:carrots
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/plant/crop_underworld §floaded."

# Handle stack only if crop block is already set
execute run function hss:environment/vegetation_overhaul/stack/crop_underworld

# Spawn sapling block
execute if score vo_crop_id count matches 7 run setblock ~ ~1 ~ minecraft:nether_wart

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/plant/sapling §floaded."

# Handle stack only if sapling block is already set
execute run function hss:environment/vegetation_overhaul/stack/sapling

# Spawn sapling block
execute if score vo_sapling_id count matches 1 run setblock ~ ~ ~ minecraft:oak_sapling
execute if score vo_sapling_id count matches 2 run setblock ~ ~ ~ minecraft:spruce_sapling
execute if score vo_sapling_id count matches 3 run setblock ~ ~ ~ minecraft:birch_sapling
execute if score vo_sapling_id count matches 4 run setblock ~ ~ ~ minecraft:jungle_sapling
execute if score vo_sapling_id count matches 5 run setblock ~ ~ ~ minecraft:acacia_sapling
execute if score vo_sapling_id count matches 6 run setblock ~ ~ ~ minecraft:dark_oak_sapling
execute if score vo_sapling_id count matches 7 run setblock ~ ~ ~ minecraft:azalea
execute if score vo_sapling_id count matches 8 run setblock ~ ~ ~ minecraft:flowering_azalea
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/plant §floaded."
execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/sapling §floaded."

# Init variables
scoreboard players set vo_sapling_id count 0

# Get item stack count and remove 1
execute store result score @s count run data get entity @s Item.Count
scoreboard players remove @s count 1

# Identify the sapling and spawn the block
execute if entity @s[nbt={Item:{id:"minecraft:oak_sapling"}}] run setblock ~ ~ ~ minecraft:oak_sapling
execute if entity @s[nbt={Item:{id:"minecraft:spruce_sapling"}}] run setblock ~ ~ ~ minecraft:spruce_sapling
execute if entity @s[nbt={Item:{id:"minecraft:birch_sapling"}}] run setblock ~ ~ ~ minecraft:birch_sapling
execute if entity @s[nbt={Item:{id:"minecraft:jungle_sapling"}}] run setblock ~ ~ ~ minecraft:jungle_sapling
execute if entity @s[nbt={Item:{id:"minecraft:acacia_sapling"}}] run setblock ~ ~ ~ minecraft:acacia_sapling
execute if entity @s[nbt={Item:{id:"minecraft:dark_oak_sapling"}}] run setblock ~ ~ ~ minecraft:dark_oak_sapling
# Identify the sapling
execute if entity @s[nbt={Item:{id:"minecraft:oak_sapling"}}] run scoreboard players set vo_sapling_id count 1
execute if entity @s[nbt={Item:{id:"minecraft:spruce_sapling"}}] run scoreboard players set vo_sapling_id count 2
execute if entity @s[nbt={Item:{id:"minecraft:birch_sapling"}}] run scoreboard players set vo_sapling_id count 3
execute if entity @s[nbt={Item:{id:"minecraft:jungle_sapling"}}] run scoreboard players set vo_sapling_id count 4
execute if entity @s[nbt={Item:{id:"minecraft:acacia_sapling"}}] run scoreboard players set vo_sapling_id count 5
execute if entity @s[nbt={Item:{id:"minecraft:dark_oak_sapling"}}] run scoreboard players set vo_sapling_id count 6
execute if entity @s[nbt={Item:{id:"minecraft:azalea"}}] run scoreboard players set vo_sapling_id count 7
execute if entity @s[nbt={Item:{id:"minecraft:flowering_azalea"}}] run scoreboard players set vo_sapling_id count 8

# Set the value to stack, only if sapling block is already set
execute unless block ~ ~ ~ minecraft:air store result entity @s Item.Count int 1 run scoreboard players get @s count
# Filter saplings and handle events
execute unless block ~ ~ ~ #minecraft:saplings if score vo_sapling_id count matches 1..8 run function hss:environment/vegetation_overhaul/plant/sapling

# Free from memory
scoreboard players reset @s count
scoreboard players reset vo_sapling_id count
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/stack/crop_normal §floaded."

# Apply sound
playsound minecraft:block.azalea_leaves.step block @a ~ ~ ~

# Handle stack only if crop block is already set
execute store result entity @s Item.Count int 1 run scoreboard players get @s count
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/stack/crop_underworld §floaded."

# Apply sound
playsound minecraft:block.wet_grass.step block @a ~ ~ ~

# Handle stack only if crop block is already set
execute store result entity @s Item.Count int 1 run scoreboard players get @s count
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This script file is owned by SimplyCEO, from repository:
# https://github.com/SimplyCEO/HardSurvivalStrategie
#
# You are allowed to translate, adapt, alter, transform, modify, or arrange it
# according with the OSL-3.0 license.
#
# Thanks for playing!

execute as @e[type=minecraft:player,scores={debug=1}] run tellraw @s "[§2§lENVIRONMENT§f] Function §9hss:environment/vegetation_overhaul/stack/sapling §floaded."

# Init variables
scoreboard players set vo_block_id count 0

# Detect block
execute if block ~ ~-1 ~ minecraft:grass_block run scoreboard players set vo_block_id count 1
execute if block ~ ~-1 ~ minecraft:moss_block run scoreboard players set vo_block_id count 1
execute if block ~ ~-1 ~ minecraft:podzol run scoreboard players set vo_block_id count 2
execute if block ~ ~-1 ~ minecraft:rooted_dirt run scoreboard players set vo_block_id count 2
execute if block ~ ~-1 ~ minecraft:mycelium run scoreboard players set vo_block_id count 3

# Apply sound
execute if score vo_block_id count matches 0 run playsound minecraft:block.composter.fill block @a ~ ~ ~
execute if score vo_block_id count matches 1 run playsound minecraft:block.grass.step block @a ~ ~ ~
execute if score vo_block_id count matches 2 run playsound minecraft:block.azalea_leaves.step block @a ~ ~ ~
execute if score vo_block_id count matches 3 run playsound minecraft:block.azalea.step block @a ~ ~ ~

# Handle stack only if sapling block is already set
execute store result entity @s Item.Count int 1 run scoreboard players get @s count

# Free from memory
scoreboard players reset vo_block_id count
7 changes: 7 additions & 0 deletions datapack/data/hss/tags/blocks/plot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"minecraft:farmland",
"minecraft:soul_sand"
]
}

0 comments on commit c0ff43c

Please sign in to comment.