Skip to content

Commit

Permalink
Merge branch 'Gamemode4Dev:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor authored Aug 24, 2023
2 parents fbc1bd4 + 060a5a7 commit c522622
Show file tree
Hide file tree
Showing 72 changed files with 2,458 additions and 5 deletions.
9 changes: 9 additions & 0 deletions gm4_double_doors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Double Doors<!--$headerTitle--><!--$pmc:delete-->

Tired of clicking twice to open a double door? Annoyed by the fact that doors are only two blacks tall? This data pack automatically opens adjecent doors, making double doors fully functional! Additionally, bottom trapdoors of matching wood type placed above a door are opened alongside the door when it is opened by a player. <!--$pmc:headerSize-->

### Features
- When a player interacts with a door that is part of a double door, both doors are opened/closed automatically!
- Open bottom-half trapdoors placed above a door will open/close alongside the door!
- Only doors and trapdoors which are of the same type and adjacent show this behavior.
- Hold shift to enforce normal 'vanilla' door behavior!
24 changes: 24 additions & 0 deletions gm4_double_doors/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
id: gm4_double_doors
name: Double Doors
version: 1.0.0

data_pack:
load: .

pipeline:
- gm4_double_doors.generate
- gm4.plugins.extend.module

meta:
gm4:
versioning:
schedule_loops: []
website:
description: Tired of clicking twice to open a double door? Annoyed by the fact that doors are only two blacks tall? This data pack automatically opens adjecent doors, making double doors fully functional! Additionally, bottom trapdoors of matching wood type placed above a door are opened alongside the door when it is opened by a player.
recommended: []
notes: []
video: null
wiki: https://wiki.gm4.co/wiki/Double_Doors
credits:
Creator:
- Bloo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
execute unless score double_doors gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Double Doors"}
execute unless score double_doors gm4_earliest_version < double_doors gm4_modules run scoreboard players operation double_doors gm4_earliest_version = double_doors gm4_modules
scoreboard players set double_doors gm4_modules 1

scoreboard objectives add gm4_double_doors_data dummy
execute unless score $trap_door_limit gm4_double_doors_data matches 0.. run scoreboard players set $trap_door_limit gm4_double_doors_data 2

#$moduleUpdateList
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"criteria": {
"requirement": {
"trigger": "minecraft:item_used_on_block",
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_sneaking": false
}
}
}
],
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"block": {
"blocks": [
"minecraft:{{ material_name }}_door"
]
}
}
}
]
}
}
},
"rewards": {
"function": "gm4_double_doors:{{ material_name }}/use_door"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checks the hinge block state of the door which was clicked.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/get_facing

# check the hinge block state of this door
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/east/left/check_neighbours
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/east/right/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/east/left/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/east/left/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~ ~ ~1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/east/right/toggle
execute positioned ~1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/west/right/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/east/left/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/east/left/open ~ ~ ~

# get target trapdoor state (0->1, 1->0 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 0

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=west] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=north] run function gm4_double_doors:{{ material_name }}/trapdoor/south_east/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/east/right/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/east/right/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~ ~ ~-1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/east/left/toggle
execute positioned ~1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/west/left/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/east/right/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/east/right/open ~ ~ ~

# get target trapdoor state (0->1, 1->0 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 0

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=west] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=south] run function gm4_double_doors:{{ material_name }}/trapdoor/north_east/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Checks the facing block state of the door which was clicked.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/get_lower_half

execute if block ~ ~ ~ minecraft:{{ material_name }}_door[facing=south] run function gm4_double_doors:{{ material_name }}/door/south/get_hinge
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[facing=west] run function gm4_double_doors:{{ material_name }}/door/west/get_hinge
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[facing=north] run function gm4_double_doors:{{ material_name }}/door/north/get_hinge
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[facing=east] run function gm4_double_doors:{{ material_name }}/door/east/get_hinge
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Forces the block selected by the raycast to be the lower half of a door
# @s = player that interacted with a door
# at location of the door the player has interacted with
# run from gm4_double_doors:player/ray

# store whether the player opened a door (=1) or closed a door (=0)
scoreboard players set $target_door_state gm4_double_doors_data 0
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[open=true] run scoreboard players set $target_door_state gm4_double_doors_data 1

# if the targeted block is an upper half, get the lower half and reposition execution location
# also ensure that the door is not broken (aka actually has both blocks present)
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[half=upper] positioned ~ ~-1 ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[half=lower] run function gm4_double_doors:{{ material_name }}/door/get_facing
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[half=lower] if block ~ ~1 ~ minecraft:{{ material_name }}_door[half=upper] run function gm4_double_doors:{{ material_name }}/door/get_facing
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checks the hinge block state of the door which was clicked.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/get_facing

# check the hinge block state of this door
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/north/left/check_neighbours
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/north/right/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/north/left/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/north/left/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/north/right/toggle
execute positioned ~ ~ ~-1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/south/right/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/north/left/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/north/left/open ~ ~ ~

# get target trapdoor state (0->0, 1->1 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 1

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=west] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=south] run function gm4_double_doors:{{ material_name }}/trapdoor/north_east/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/north/right/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/north/right/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~-1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/north/left/toggle
execute positioned ~ ~ ~-1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/south/left/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/north/right/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/north/right/open ~ ~ ~

# get target trapdoor state (0->0, 1->1 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 1

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=east] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=south] run function gm4_double_doors:{{ material_name }}/trapdoor/north_west/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checks the hinge block state of the door which was clicked.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/get_facing

# check the hinge block state of this door
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/south/left/check_neighbours
execute if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/south/right/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/south/left/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/south/left/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~-1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/south/right/toggle
execute positioned ~ ~ ~1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=right] run function gm4_double_doors:{{ material_name }}/door/north/right/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/south/left/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/south/left/open ~ ~ ~

# get target trapdoor state (0->0, 1->1 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 1

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=east] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=north] run function gm4_double_doors:{{ material_name }}/trapdoor/south_west/check_neighbours
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks for neighbouring doors which may also have to be opened alongside this door.
# @s = player that interacted with a door
# at location of the lower half of the door the player has interacted with
# run from gm4_double_doors:{{ material_name }}/door/south/right/get_hinge

# open this door
function gm4_double_doors:{{ material_name }}/door/south/right/toggle

# check for potential neighbouring doors which should also be opened
execute positioned ~1 ~ ~ if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/south/left/toggle
execute positioned ~ ~ ~1 if block ~ ~ ~ minecraft:{{ material_name }}_door[hinge=left] run function gm4_double_doors:{{ material_name }}/door/north/left/toggle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Toggles the double door the player has interacted with.
# @s = player that interacted with a door
# at location of the lower half of the left door of the double door the player has interacted with
# run from check_neighbours functions in gm4_double_doors:{{ material_name }}/door/...

# player just closed a door
execute if score $target_door_state gm4_double_doors_data matches 0 run place template gm4_double_doors:{{ material_name }}/door/south/right/closed ~ ~ ~

# player just opened a door
execute if score $target_door_state gm4_double_doors_data matches 1 run place template gm4_double_doors:{{ material_name }}/door/south/right/open ~ ~ ~

# get target trapdoor state (0->0, 1->1 for this direction)
execute store result score $target_trapdoor_state gm4_double_doors_data if score $target_door_state gm4_double_doors_data matches 1

# check for potential trapdoors which should also be opened
scoreboard players operation $trap_door_recursion_level gm4_double_doors_data = $trap_door_limit gm4_double_doors_data
execute positioned ~ ~2 ~ if block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[open=true,half=bottom] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=west] unless block ~ ~ ~ minecraft:{{ material_name }}_trapdoor[facing=north] run function gm4_double_doors:{{ material_name }}/trapdoor/south_east/check_neighbours
Loading

0 comments on commit c522622

Please sign in to comment.