Initial commit

This commit is contained in:
Rares Bozga
2025-11-29 22:53:32 +02:00
parent e9fa13dbd3
commit 461e95114c
157 changed files with 7597 additions and 1 deletions

View File

@@ -0,0 +1,130 @@
templatetools_command_templatetools:
debug: false
type: command
name: templatetools
description: TemplateTools info.
usage: /templatetools
aliases:
- tt
permission: templatetools.command.tt
tab completions:
1: <list[]>
script:
- narrate format:templatetools_formats_main "TemplateTools (Denizen impl.) v1.0.0.0"
- narrate format:templatetools_formats_main "Author: unsafemalloc"
templatetools_command_ttpack:
debug: false
type: command
name: ttpack
description: Changes pack for Template Tool usage.
usage: /ttpack (pack)
permission: templatetools.command.ttpack
tab completions:
1: <proc[templatetools_available_packs].context[<player>]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- if <context.args.size> != 1:
- narrate "<&c>Invalid use. Please try /<context.alias> (pack)."
- stop
- if !<proc[templatetools_available_packs].contains[<context.args.get[1]>]>:
- narrate "<&c>There is no such pack: <context.args.get[1]>"
- stop
- flag <player> templatetools_pack:<context.args.get[1]>
- flag <player> templatetools_pack_index:1
- ~run templatetools_schematic_set_index def.player:<player>
- run templatetools_preview_queue def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
- narrate format:templatetools_formats_main "Set TemplateTools pack to <context.args.get[1]> (use /ttschematic to select a schematic)"
templatetools_command_ttschematic:
debug: false
type: command
name: ttschematic
description: Changes schematic for Template Tool usage.
usage: /ttschematic (schematic)
permission: templatetools.command.ttschematic
tab completions:
1: <proc[templatetools_available_schematics].context[<player>]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- if <context.args.size> != 1:
- narrate "<&c>Invalid use. Please try /<context.alias> (schematic)."
- stop
- if !<player.has_flag[templatetools_pack]>:
- narrate "<&c>Please select a template pack first using /ttpack."
- stop
- if !<proc[templatetools_available_schematics].context[<player>].contains[<context.args.get[1]>]>:
- narrate "<&c>There is no such schematic: <context.args.get[1]>"
- stop
- if <schematic.list.contains[templatetools_<player.uuid>]>:
- ~schematic unload name:templatetools_<player.uuid>
- schematic load name:templatetools_<player.uuid> filename:<player.flag[templatetools_pack]>/<context.args.get[1]>
- flag <player> templatetools_schematic:templatetools_<player.uuid>
- narrate format:templatetools_formats_main "Set TemplateTools schematic to <context.args.get[1]> (you can preview it using a Spider Eye)"
templatetools_command_ttundo:
debug: false
type: command
name: ttundo
description: Undoes last operation.
usage: /ttundo
permission: templatetools.command.ttundo
tab completions:
1: <list[]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- if <player.flag[templatetools_undo].if_null[<list[]>].is_empty>:
- narrate format:templatetools_formats_main "Nothing left to undo."
- stop
- run templatetools_pop_undo def.player:<player>
- narrate format:templatetools_formats_main "Undid previous operation."
templatetools_command_ttsetcursor:
debug: false
type: command
name: ttsetcursor
aliases:
- ttsc
description: Sets blocks in WorldEdit selection using the material you're looking at.
usage: /ttsetcursor
permission: templatetools.command.ttsetcursor
tab completions:
1: <list[]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- define material <player.cursor_on.material.if_null[null]>
- if <[material]> == null:
- narrate "<&c>Invalid material. Please look at a material to set first!"
- stop
- define we_selection <player.we_selection.if_null[null]>
- if <[we_selection]> == null:
- narrate "<&c>You must first make a WorldEdit selection."
- stop
- ~modifyblock <[we_selection]> <[material]> no_physics
- narrate format:templatetools_formats_main "Set cursor blocks (<[we_selection].volume.if_null[?]>)."
templatetools_command_that:
debug: false
type: command
name: that
description: TemplateTools info.
usage: /that
permission: templatetools.command.that
tab completions:
1: <list[]>
script:
- define material <player.cursor_on.material.if_null[null]>
- if <[material]> == null:
- narrate "<&c>Nothing to copy."
- define item <item[<[material].name>].if_null[null]>:
- narrate "<&c>Nothing to copy."
- inventory set slot:hand origin:<[item]>
- narrate format:templatetools_formats_main "Copied <[material].name>."

View File

@@ -0,0 +1,4 @@
templatetools_formats_main:
debug: false
type: format
format: <&8>(<&b><&l>TT<&8>) <&7><[text]>

View File

@@ -0,0 +1,183 @@
templatetools_available_packs:
debug: false
type: procedure
script:
- determine <util.list_files[schematics].filter_tag[<[filter_value].advanced_matches[*.*].not>]>
templatetools_pack_length:
debug: false
type: procedure
definitions: player
script:
- if !<[player].has_flag[templatetools_pack]>:
- determine 0
- determine <proc[templatetools_available_schematics].context[<[player]>].size>
templatetools_pack_increment:
debug: false
type: task
definitions: player
script:
- define pack_length <proc[templatetools_pack_length].context[<[player]>]>
- if <[pack_length]> == 0:
- stop
- define index <[player].flag[templatetools_pack_index].add[1]>
- if <[index]> > <[pack_length]>:
- define index 1
- flag <[player]> templatetools_pack_index:<[index]>
templatetools_pack_decrement:
debug: false
type: task
definitions: player
script:
- define pack_length <proc[templatetools_pack_length].context[<[player]>]>
- if <[pack_length]> == 0:
- stop
- define index <[player].flag[templatetools_pack_index].sub[1]>
- if <[index]> < 1:
- define index <[pack_length]>
- flag <[player]> templatetools_pack_index:<[index]>
templatetools_available_schematics:
debug: false
type: procedure
definitions: player
script:
- if !<[player].has_flag[templatetools_pack]>:
- determine <list[]>
- determine <util.list_files[schematics/<[player].flag[templatetools_pack]>].parse_tag[<[parse_value].replace_text[regex:.schem$].with[]>].if_null[<list[]>].alphanumeric>
templatetools_schematic_set_index:
debug: false
type: task
definitions: player
script:
- define schematics <proc[templatetools_available_schematics].context[<[player]>]>
- if <schematic.list.contains[<[player].flag[templatetools_schematic]>]>:
- ~schematic unload name:<[player].flag[templatetools_schematic]>
- schematic load name:templatetools_<[player].uuid> filename:<[player].flag[templatetools_pack]>/<[schematics].get[<[player].flag[templatetools_pack_index]>]>
- actionbar "<&e>Schematic <[player].flag[templatetools_pack_index]>: <&f><[schematics].get[<[player].flag[templatetools_pack_index]>]>" targets:<[player]>
templatetools_preview_queue:
debug: false
type: task
definitions: player|schematic
script:
- if <[player].has_flag[templatetools_preview_queue]>:
- stop
- flag <[player]> templatetools_preview_queue:true expire:0.5s
- wait 0.5s
- if !<schematic.list.contains[<[schematic]>]>:
- stop
- waituntil <schematic[<[schematic]>].width.if_null[-1]> != -1 max:2s
- flag <[player]> templatetools_preview_queue:!
- run templatetools_preview def.player:<[player]> def.schematic:<[schematic]>
templatetools_preview_show:
debug: false
type: task
definitions: player|schematic
script:
- define cursor_on <[player].cursor_on.if_null[null]>
- if <[cursor_on]> == null:
- stop
- if !<schematic.list.contains[<[schematic]>]>:
- stop
- define cuboid <schematic[<[schematic]>].cuboid[<[cursor_on]>]>
- define middle <[cuboid].center>
- define smallest_y <[cuboid].corners.get[first].y>
- if <[cuboid].corners.get[last].y> < <[smallest_y]>:
- define smallest_y <[cuboid].corners.get[last].y>
- define difference_y <[cursor_on].y.sub[<[smallest_y]>]>
- define cursor_on <[cursor_on].sub[0,<[difference_y].sub[1]>,0]>
- define fakedlocations <list[]>
- if !<[player].item_in_hand.advanced_matches[spider_eye]>:
- run templatetools_preview_clear def.player:<[player]>
- stop
- define halfwidth <schematic[<[schematic]>].width.div[2]>
- define halflength <schematic[<[schematic]>].length.div[2]>
- repeat <schematic[<[schematic]>].width> from:0 as:x:
- repeat <schematic[<[schematic]>].height> from:0 as:y:
- repeat <schematic[<[schematic]>].length> from:0 as:z:
- define location <location[<[x]>,<[y]>,<[z]>,<[player].world.name>]>
- define block <schematic[<[schematic]>].block[<[location]>]>
- if <[block].name> == air:
- repeat next
- define fakedlocation <[cursor_on].add[<[location]>].sub[<[halfwidth]>,0,<[halflength]>].add[1,0,1]>
- showfake <schematic[<[schematic]>].block[<[location]>]> <[fakedlocation]> players:<[player]> duration:1h
- define fakedlocations <[fakedlocations].include[<[fakedlocation]>]>
- flag <[player]> templatetools_preview_region:<[fakedlocations]>
templatetools_preview_clear:
debug: false
type: task
definitions: player
script:
- if !<[player].has_flag[templatetools_preview_region]>:
- stop
- showfake cancel <[player].flag[templatetools_preview_region]>
- flag <[player]> templatetools_preview_region:!
templatetools_preview:
debug: false
type: task
definitions: player|schematic
script:
- ~run templatetools_preview_clear def.player:<[player]>
- run templatetools_preview_show def.player:<[player]> def.schematic:<[schematic]>
templatetools_preview_paste:
debug: false
type: task
definitions: player|schematic
script:
- define cursor_on <[player].cursor_on.if_null[null]>
- if <[cursor_on]> == null:
- stop
- define cuboid <schematic[<[schematic]>].cuboid[<[cursor_on]>]>
- define middle <[cuboid].center>
- define smallest_y <[cuboid].corners.get[first].y>
- if <[cuboid].corners.get[last].y> < <[smallest_y]>:
- define smallest_y <[cuboid].corners.get[last].y>
- define difference_y <[cursor_on].y.sub[<[smallest_y]>]>
- define cursor_on <[cursor_on].sub[0,<[difference_y].sub[1]>,0]>
- if !<[player].item_in_hand.advanced_matches[spider_eye]>:
- run templatetools_preview_clear def.player:<[player]>
- stop
- define halfwidth <schematic[<[schematic]>].width.div[2]>
- define halflength <schematic[<[schematic]>].length.div[2]>
- define count 0
- define undodata <map[]>
- repeat <schematic[<[schematic]>].width> from:0 as:x:
- repeat <schematic[<[schematic]>].height> from:0 as:y:
- repeat <schematic[<[schematic]>].length> from:0 as:z:
- define location <location[<[x]>,<[y]>,<[z]>,<[player].world.name>]>
- define block <schematic[<[schematic]>].block[<[location]>]>
- if <[block].name> == air:
- repeat next
- define fakedlocation <[cursor_on].add[<[location]>].sub[<[halfwidth]>,0,<[halflength]>].add[1,0,1]>
- define previousmaterial <[fakedlocation].material>
- modifyblock <schematic[<[schematic]>].block[<[location]>]> <[fakedlocation]> no_physics
- define undodata <[undodata].with[<[fakedlocation]>].as[<[previousmaterial]>]>
- define count <[count].add[1]>
- run templatetools_push_undo def.player:<[player]> def.data:<[undodata]>
- determine <[count]>
templatetools_push_undo:
debug: false
type: task
definitions: player|data
script:
- flag <[player]> templatetools_undo:<[player].flag[templatetools_undo].if_null[<list[]>].include[<[data]>]>
templatetools_pop_undo:
debug: false
type: task
definitions: player
script:
- if <[player].flag[templatetools_undo].if_null[<list[]>].is_empty>:
- stop
- foreach <[player].flag[templatetools_undo].last> key:location as:material:
- modifyblock <[material]> <[location]> no_physics
- flag <[player]> templatetools_undo:<[player].flag[templatetools_undo].remove[last]>

View File

@@ -0,0 +1,98 @@
templatetools_world_cleanup:
debug: false
type: world
events:
after server start:
- foreach <schematic.list.filter_tag[<[filter_value].starts_with[templatetools_]>]> as:schematic:
- schematic unload name:<[schematic]>
- foreach <server.players_flagged[templatetools_undo]> as:player:
- flag <[player]> templatetools_undo:!
templatetools_world_preview:
debug: false
type: world
events:
on player walks:
- if !<player.item_in_hand.advanced_matches[spider_eye]>:
- stop
- if !<player.has_permission[templatetools.tools.schematic]>:
- stop
- if !<player.has_flag[templatetools_pack]>:
- stop
- if !<player.has_flag[templatetools_schematic]>:
- stop
- run templatetools_preview_queue def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
on player scrolls their hotbar:
- if !<player.has_permission[templatetools.tools.schematic]>:
- stop
- if !<player.has_flag[templatetools_pack]>:
- stop
- if <player.is_sneaking>:
- if !<player.item_in_hand.advanced_matches[spider_eye]>:
- stop
- determine cancelled passively
- if <context.new_slot> > <context.previous_slot>:
- if <context.previous_slot> == 1 && <context.new_slot> == 9:
- run templatetools_pack_increment def.player:<player>
- else:
- run templatetools_pack_decrement def.player:<player>
- else:
- if <context.previous_slot> == 9 && <context.new_slot> == 1:
- run templatetools_pack_decrement def.player:<player>
- else:
- run templatetools_pack_increment def.player:<player>
- run templatetools_schematic_set_index def.player:<player>
- run templatetools_preview_queue def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
- else:
- if !<player.has_flag[templatetools_schematic]>:
- stop
- if <player.inventory.slot[<context.new_slot>].material.name> == spider_eye:
- run templatetools_preview_queue def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
- else:
- run templatetools_preview_clear def.player:<player>
after player clicks in inventory:
- if !<player.has_permission[templatetools.tools.schematic]>:
- stop
- if !<player.has_flag[templatetools_pack]>:
- stop
- if !<player.has_flag[templatetools_schematic]>:
- stop
- if <player.item_in_hand.advanced_matches[spider_eye]>:
- run templatetools_preview def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
- determine cancelled passively
- else:
- run templatetools_preview_clear def.player:<player>
on player left clicks block:
- if !<player.has_permission[templatetools.tools.schematic]>:
- stop
- if !<player.item_in_hand.advanced_matches[spider_eye]>:
- stop
- if !<player.has_flag[templatetools_pack]>:
- stop
- if !<player.has_flag[templatetools_schematic]>:
- stop
- determine cancelled passively
- if <player.is_sneaking>:
- schematic rotate name:<player.flag[templatetools_schematic]> angle:90
- run templatetools_preview_queue def.player:<player> def.schematic:<player.flag[templatetools_schematic]>
- actionbar "<&e>Rotated schematic 90 degrees."
- else:
- run templatetools_preview_paste def.player:<player> def.schematic:<player.flag[templatetools_schematic]> save:return
- define count <entry[return].created_queue.determination.get[1]>
- narrate format:templatetools_formats_main "Placed schematic (<[count]>)."
templatetools_world_redtorchtool:
debug: false
type: world
events:
on player right clicks block:
- if !<player.has_permission[templatetools.tools.redtorch]>:
- stop
- if !<player.item_in_hand.advanced_matches[redstone_torch]>:
- stop
- if <player.is_sneaking>:
- stop
- determine cancelled passively
- if <context.location.material.switched.if_null[null]> != null:
- switch <context.location> no_physics
- narrate format:templatetools_formats_main "Switched block state."