Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not full compiling #12

Closed
JackYevhen opened this issue Jun 4, 2023 · 2 comments
Closed

Not full compiling #12

JackYevhen opened this issue Jun 4, 2023 · 2 comments

Comments

@JackYevhen
Copy link

I'v got a code:

def load:
    scoreboard objectives add JYID_I.renew dummy
    scoreboard objectives add JYID_I.half_b_progress dummy

    scoreboard objectives add JY.give_control trigger
    forceload add 0 0 0 0

    #  for testing purpose, must be removed later...
    scoreboard objectives add give_bedrock trigger
    scoreboard objectives add remove_bedrock trigger


def process:
    grabber = summon marker ~ ~ ~
    data modify entity grabber#1 Pos set from entity @s data.origin
    if entity @s[tag=JYID_I.half_breakable]
        if score @s progress matches 5
            setblock 0 -64 0 barrier
        if score @s progress matches 4 at grabber
            clone ~-4 ~ ~ ~-4 ~ ~ 0 -64 0
        if score @s progress matches 3 at grabber
            clone ~-3 ~ ~ ~-3 ~ ~ 0 -64 0
        if score @s progress matches 2 at grabber
            clone ~-2 ~ ~ ~-2 ~ ~ 0 -64 0
        if score @s progress matches 1 at grabber
            clone ~-1 ~ ~ ~-1 ~ ~ 0 -64 0
        if score @s progress matches 0 at grabber
            clone ~ ~ ~ ~ ~ ~ 0 -64 0
    def else:
        at grabber
            clone ~ ~ ~ ~ ~ ~ 0 -64 0
    kill grabber
    clone 0 -64 0 0 -64 0 ~ ~ ~
    setblock 0 -64 0 bedrock



def tick:
    as @a[scores={give_control=1}]
        scoreboard players set @s give_control 0
        give @s written_book{pages:['["",{"text":"Console for JYServerBockEsencials - by "},{"text":"Jack_Yevhen","bold":true,"italic":true,"underlined":true,"color":"red","hoverEvent":{"action":"show_text","contents":"The creator"}},{"text":"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n& ","color":"reset"},{"text":"[ChatGPT]","bold":true,"italic":true,"underlined":true,"color":"#51CD9C","clickEvent":{"action":"open_url","value":"https://chat.openai.com"},"hoverEvent":{"action":"show_text","contents":"Click to open ChatGPT page... I am terrible at grammar (both my first language and English), that\'s why this is the only text in this datapack not checked by ChatGPT. He is just an AI, but I can\'t don\'t give credits to the one, who helped."}}]','["",{"text":"Features:\\n\\n"},{"text":"I","bold":true,"hoverEvent":{"action":"show_text","contents":"1"}},{"text":".","bold":true},{"text":" ","color":"reset"},{"text":"Half-breakable","italic":true,"underlined":true,"hoverEvent":{"action":"show_text","contents":"When broken, it will transition to the next stage. There is a limit of 5 stages, after which it will become a barrier. If not broken within 5 seconds, it will revert back to the 1st stage."}},{"text":"\\n","color":"reset"},{"text":"II","bold":true,"hoverEvent":{"action":"show_text","contents":"2"}},{"text":".","bold":true},{"text":" ","color":"reset"},{"text":"Never-ending","italic":true,"underlined":true,"hoverEvent":{"action":"show_text","contents":"It will place itself back within 5 seconds after being broken."}},{"text":"\\n","color":"reset"},{"text":"III","bold":true,"hoverEvent":{"action":"show_text","contents":"3"}},{"text":".","bold":true},{"text":" ","color":"reset"},{"text":"Custom bedrock","italic":true,"underlined":true,"hoverEvent":{"action":"show_text","contents":"It won\'t drop an item; it will immediately replace itself when broken. It is not recommended to use it for server spawn, as it may cause lag on low-performance PCs."}},{"text":"\\n ","color":"reset"}]','["",{"text":"Console features:\\n\\n"},{"text":"I.","bold":true,"clickEvent":{"action":"change_page","value":4},"hoverEvent":{"action":"show_text","contents":"1"}},{"text":" Create new ","color":"reset","clickEvent":{"action":"change_page","value":4}},{"text":"JYBlock type","italic":true,"underlined":true,"clickEvent":{"action":"change_page","value":4},"hoverEvent":{"action":"show_text","contents":"Half-breackable / Never-ending / Custom bedrock"}},{"text":"\\n","color":"reset"},{"text":"II","bold":true,"clickEvent":{"action":"change_page","value":5},"hoverEvent":{"action":"show_text","contents":"2"}},{"text":". Remove ","color":"reset","clickEvent":{"action":"change_page","value":5}},{"text":"JYBlocks","italic":true,"underlined":true,"clickEvent":{"action":"change_page","value":5},"hoverEvent":{"action":"show_text","contents":"in 1/2/5/10/20 block radius."}},{"text":"\\n","color":"reset"},{"text":"III","bold":true,"hoverEvent":{"action":"show_text","contents":"3"}},{"text":". ","color":"reset"},{"text":"Self-destruct","hoverEvent":{"action":"show_text","contents":"Instructions on how to delete this datapack. (WIP)"}}]','["",{"text":"Create new "},{"text":"JYBlock type","italic":true,"underlined":true,"hoverEvent":{"action":"show_text","contents":"Half-breackable / Never-ending / Custom bedrock"}},{"text":" :\\n\\n","color":"reset"},{"text":"[Half-breakable]","italic":true,"underlined":true,"clickEvent":{"action":"run_command","value":"tag @s add JYID_I.create.half_breakable"},"hoverEvent":{"action":"show_text","contents":"Click to create! It will place five blocks of bedrock under you. The one directly under you is the 1st stage. You will be given a stick, which is called a key-stick. Walk on the bedrock with it in your off-hand to turn that bedrock into a half-breakable state, which is bound to the current key-stick."}},{"text":"\\n","color":"reset"},{"text":"[Never-ending]","italic":true,"underlined":true,"clickEvent":{"action":"run_command","value":"tag @s add JYID_I.create.never_ending"},"hoverEvent":{"action":"show_text","contents":"Click to create! It will place bedrock under your feet and give you a key-stick, which is bound to the current block. Walk on the bedrock with the key-stick in your off-hand to turn the bedrock into a never-ending state, bound to the current stick."}},{"text":"\\n","color":"reset"},{"text":"[Custom bedrock]","italic":true,"underlined":true,"clickEvent":{"action":"run_command","value":"tag @s add JYID_I.create.custom_bedrock"},"hoverEvent":{"action":"show_text","contents":"Click to create! It will place bedrock under your feet and give you a key-stick, which is bound to the current block. Walk on the bedrock with the key-stick in your off-hand to transform the bedrock into custom bedrock, which will be bound to the current stick."}}]','["",{"text":"Delete all "},{"text":"JYBlocks","italic":true,"underlined":true,"hoverEvent":{"action":"show_text","contents":"Half-breackable / Never-ending / Custom bedrock"}},{"text":" in :\\n\\n","color":"reset"},{"text":"[1-block radius]","italic":true,"clickEvent":{"action":"run_command","value":"kill @e[tag=JYID_I.process, distance=..1]"}},{"text":"\\n","italic":true},{"text":"[2-block radius]","italic":true,"clickEvent":{"action":"open_url","value":"kill @e[tag=JYID_I.process, distance=..2]"}},{"text":"\\n","italic":true},{"text":"[5-block radius]","italic":true,"clickEvent":{"action":"run_command","value":"kill @e[tag=JYID_I.process, distance=..5]"}},{"text":"\\n","italic":true},{"text":"[10-block radius]","italic":true,"clickEvent":{"action":"run_command","value":"kill @e[tag=JYID_I.process, distance=..10]"}},{"text":"\\n","italic":true},{"text":"[20-block radius]","italic":true,"clickEvent":{"action":"run_command","value":"kill @e[tag=JYID_I.process, distance=..20]"}}]'],title:"JYServerBockEsencials console",author:Jack_Yevhen,display:{Lore:["Console for JYServerBockEsencials."]}}

    as @a[tag=JYID_I.create.half_breakable] at @s
        tag @s remove JYID_I.create.half_breakable
        forceload add ~ ~ ~ ~
        fill ~ ~-1 ~ ~-4 ~-1 ~ bedrock
        stick = summon item ~ ~-0.5 ~ {Item:{id:"minecraft:stick", tag:{display:{Name:'["",{"text":"Key-Stick (","bold":true,"italic":true,"color":"aqua"},{"text":"Half-breakable","bold":true,"italic":true,"underlined":true,"color":"light_purple"},{"text":")","bold":true,"italic":true,"color":"aqua"}]', Lore:['{"text":"Rename in anvil","bold":true,"italic":true,"color":"light_purple"}']}, JYID_I_data:{placeCustomBlock:true, customBlockType:"half-breakable"}}, Count:1}}
        data modify entity stick#1 Item.tag.JYID_I_data.source set from entity stick#1 Pos
    as @a[tag=JYID_I.create.never_ending] at @s
        tag @s remove JYID_I.create.never_ending
        forceload add ~ ~ ~ ~
        setblock ~ ~-1 ~ bedrock
        stick = summon item ~ ~-0.5 ~ {Item:{id:"minecraft:stick", tag:{display:{Name:'["",{"text":"Key-Stick (","bold":true,"italic":true,"color":"aqua"},{"text":"Never-ending","bold":true,"italic":true,"underlined":true,"color":"light_purple"},{"text":")","bold":true,"italic":true,"color":"aqua"}]', Lore:['{"text":"Rename in anvil","bold":true,"italic":true,"color":"light_purple"}']}, JYID_I_data:{placeCustomBlock:true, customBlockType:"never-ending"}}, Count:1}}
        data modify entity stick#1 Item.tag.JYID_I_data.source set from entity stick#1 Pos
    as @a[tag=JYID_I.create.custom_bedrock] at @s
        tag @s remove JYID_I.create.custom_bedrock
        forceload add ~ ~ ~ ~
        setblock ~ ~-1 ~ bedrock
        stick = summon item ~ ~-0.5 ~ {Item:{id:"minecraft:stick", tag:{display:{Name:'["",{"text":"Key-Stick (","bold":true,"italic":true,"color":"aqua"},{"text":"Custom bedrock","bold":true,"italic":true,"underlined":true,"color":"light_purple"},{"text":")","bold":true,"italic":true,"color":"aqua"}]', Lore:['{"text":"Rename in anvil","bold":true,"italic":true,"color":"light_purple"}']}, JYID_I_data:{placeCustomBlock:true, customBlockType:"custom-bedrock"}}, Count:1}}
        data modify entity stick#1 Item.tag.JYID_I_data.source set from entity stick#1 Pos

    as @a[nbt={Inventory:{Slot:-106b, id:"minecraft:stick", tag:{JYID_I_data:{placeCustomBlock:true}}}}]
        if block ~ ~-0.1 ~ bedrock
            core = summon marker ~ ~ ~ {Tags:[JYID_I.process]}
            align xyz
                 tp core ~0.5 ~-0.5 ~0.5
            if nbt={Inventory:{Slot:-106b, tag:{JYID_I_data:{customBlockType:"half-breakable"}}}}
                tag core add JYID_I.half_breakable
            if nbt={Inventory:{Slot:-106b, tag:{JYID_I_data:{customBlockType:"never-ending"}}}}
                tag core add JYID_I.never_ending
            if nbt={Inventory:{Slot:-106b, tag:{JYID_I_data:{customBlockType:"custom-bedrock"}}}}
                tag core add JYID_I.custom_bedrock
            data modify entity core#1 data.origin set from entity @s Inventory[{Slot:-106b}].tag.source
            scoreboard players set core renew 0

    as @e[tag=JYID_I.process]
        if scores={renew=100}
            progress
        def else:
            unless tag=JYID_I.never_ending
                if block ~ ~ ~ air
                    progress



    scoreboard players reset @a[gamemode=!creative] JY.give_control
    scoreboard players enable @a[gamemode=creative] JY.give_control

    #  for testing purpose, must be removed later...
    scoreboard players enable Jack_Yevhen JY.give_control
    scoreboard players enable Dragonlordgen2 JY.give_control
    scoreboard players enable @a[name="Yota Ai"] JY.give_control
    scoreboard players enable tastybread10564 JY.give_control
    scoreboard players enable Jack_Yevhen give_bedrock
    scoreboard players enable Dragonlordgen2 give_bedrock
    scoreboard players enable @a[name="Yota Ai"] give_bedrock
    scoreboard players enable tastybread10564 give_bedrock
    scoreboard players enable Jack_Yevhen remove_bedrock
    scoreboard players enable Dragonlordgen2 remove_bedrock
    scoreboard players enable @a[name="Yota Ai"] remove_bedrock
    scoreboard players enable tastybread10564 remove_bedrock
    as @a[scores={give_bedrock=1..}]
        scoreboard players remove @s give_bedrock 1
        give @s bedrock
    as @a[scores={remove_bedrock=1}] at @s
        scoreboard players set @s remove_bedrock 0
        setblock ~ ~-1 ~ air

But it dasn't compile fully. When it compiles, you see that content of tick.mcfunction is:

execute as @a[scores={give_control=1}] run function jy_serever_block_essencials:tick.e0
execute as @a[tag=JYID_I.create.half_breakable] at @s run function jy_serever_block_essencials:tick.e1
execute as @a[tag=JYID_I.create.never_ending] at @s run function jy_serever_block_essencials:tick.e2

but, correct content of tick.mcfunction must be:

execute as @a[scores={give_control=1}] run function jy_serever_block_essencials:tick.e0
execute as @a[tag=JYID_I.create.half_breakable] at @s run function jy_serever_block_essencials:tick.e1
execute as @a[tag=JYID_I.create.never_ending] at @s run function jy_serever_block_essencials:tick.e2
execute as @a[tag=JYID_I.create.custom_bedrock] at @s run function jy_serever_block_essencials:tick.e3
execute as @a[nbt={Inventory:{Slot:-106b, id:"minecraft:stick", tag:{JYID_I_data:{placeCustomBlock:true}}}}] run function jy_serever_block_essencials:tick.e4
execute as @e[tag=JYID_I.process] run function jy_serever_block_essencials:tick.e5
scoreboard players reset @a[gamemode=!creative] JY.give_control
scoreboard players enable @a[gamemode=creative] JY.give_control
scoreboard players enable Jack_Yevhen JY.give_control
scoreboard players enable Dragonlordgen2 JY.give_control
scoreboard players enable @a[name="Yota Ai"] JY.give_control
scoreboard players enable tastybread10564 JY.give_control
scoreboard players enable Jack_Yevhen give_bedrock
scoreboard players enable Dragonlordgen2 give_bedrock
scoreboard players enable @a[name="Yota Ai"] give_bedrock
scoreboard players enable tastybread10564 give_bedrock
scoreboard players enable Jack_Yevhen remove_bedrock
scoreboard players enable Dragonlordgen2 remove_bedrock
scoreboard players enable @a[name="Yota Ai"] remove_bedrock
scoreboard players enable tastybread10564 remove_bedrock
execute as @a[scores={give_bedrock=1..}] run function jy_serever_block_essencials:tick.e6
execute  as @a[scores={remove_bedrock=1}] at @s run function jy_serever_block_essencials:tick.e7

Also, files jy_serever_block_essencials:tick.e3, jy_serever_block_essencials:tick.e4, ... don't even exist. Output of compilation is just "successfully created datapack 'jy_serever_block_essencials'"

@JackYevhen
Copy link
Author

JackYevhen commented Jun 4, 2023

I'm gust dumb. I exidently wrote 'def else:' instead of 'else:', but please make it show the error properly instead of giving up on compiling

@emorgan00
Copy link
Owner

Hi, about this issue as well as your other issue (and as a general comment to anyone who is also interested in using or contributing to EasyDatapacks):

I made EasyDatapacks 4 years ago as a learning experience when I was new to programming. I only spent about 2 months on it before abandoning it completely, primarily because I was such a python noob that I had "coded myself into a hole" by making something that was extremely fragile and not extensible at all, and I didn't have the skill to rewrite it to be better. In particular, as you've discovered, I don't validate that your code is syntactically correct, meaning any syntax error is undefined behaviour, usually taking the form of either the output of the tool being a datapack which itself has syntax errors, or lines of code just being treated as if they weren't there.

A lot has changed since I originally wrote this -- although I could probably fix these bugs now if I wanted to, I don't really have the time or interest to do that anymore.

I never really intended this to be a serious project that other people actually use, but I'm happy that over the years some people have come back to this and used it to create their datapack projects. I'm not up to date on the current minecraft datapack world, but my memory is that not long after I released this, there was a minecraft update which obsoleted a lot of the edge of using this tool over writing datapacks by hand. It might also be broken on newer versions of minecraft -- I think we were at version 1.13 when I originally created this, and I haven't tested it on any subsequent versions.

If anyone reading this wants to work on making this tool better, either by fixing bugs, ensuring it's compatible with newer version of minecraft, adding new features, or taking it in a whole new direction, I welcome you to contribute. Though, my advice is that you might have an easier time rewriting it from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants