TeamDman / Zen-Summoning

A mod that allows for pack creators to set up custom summoning situations using ZenScript
2 stars 1 forks source link

Entity data not being treated as it is with /summon command #31

Closed RobertHDPotatoes closed 2 years ago

RobertHDPotatoes commented 2 years ago

Minecraft Version: 1.16.5 Zen Summoning Version: 1.3.6 Quark Version: 2.4.322 Forge Version: 36.2.33 CraftTweaker Version: 7.1.2.508

I'm running a heavily modded instance and having some trouble with NBT item data relating to Quark. I'm trying to give a quark rune color (Item NBT data) to a bow for a Stray that I am spawning through zen summoning, and that is causing this error: Bosses\TESTFORBUGREPORT.zs:46:5 Bosses\TESTFORBUGREPORT.zs:46:5: Empty map without known type

This is the entire section where the problem lies:

"HandItems": [{ id: "extrabows:golden_bow", Count:1, tag:{display:{Name:'[{"text":"Infinite Dread","italic":false,"color":"red"}]',Lore:['[{"text":"A long forgotten bow, filled with the dread of the many souls it has collected.","italic":false,"color":"light_purple"}]']},Enchantments:[{id:"infinity",lvl:1},{id:"mending",lvl:1}, {id:"corpsecomplex:soulbinding",lvl:1},{id:"unbreaking",lvl:3},{id:"sneakymagic:plundering",lvl:3}], "quark:RuneAttached": 1b, "quark:RuneColor":{id:"quark:magenta_rune", Count: 1b}} }]

specifically the last part of the tag, starting here: "quark:RuneAttached": 1b, "quark:RuneColor":{id:"quark:magenta_rune", Count: 1b}

If I remove quarks NBT data ("quark:RuneAttached": 1b, "quark:RuneColor":{id:"quark:magenta_rune", Count: 1b}), the script will work fine. However, it should work as written originally, because using the /summon command can correctly summon a mob exactly the same way, so the tag section seems to be functioning slightly differently than it should(?).

Here is the entire example script showing off the error which you can load up. Obviously you need Zen Summoning and Quark installed in order to replicate this issue or troubleshoot it.

Script: https://pastebin.com/EMdvtH3S

Here is the summon command for a nearly identical mob to show that my tags SHOULD work (Needs to be run through a command block because it's too long for chat):

/summon minecraft:stray ~ ~ ~ {CustomName:'[{"text":"Stray Soul","color":"red"}]',CustomNameVisible:1b,Health:25,HandItems:[{id:bow,tag:{display:{Name:'[{"text":"Infinite Dread","italic":false,"color":"red"}]',Lore:['[{"text":"A long forgotten bow, filled with the dread of the many souls it has collected.","italic":false,"color":"light_purple"}]']},Enchantments:[{id:infinity,lvl:1},{id:mending,lvl:1},{id:unbreaking,lvl:3}],"quark:RuneAttached":1b,"quark:RuneColor":{id:"quark:magenta_rune",Count:1b}},Count:1}],HandDropChances:[1.00f],Attributes:[{Name:"generic.max_health",Base:25f}]}

I am pretty sure there is an issue here, but in case I am simply doing something wrong formatting wise I apologize. I've quadruple checked so hopefully it's not me overlooking some basic error. This issue also may effect other mods NBT data, quark is just the one I happened to notice it with.

TeamDman commented 2 years ago

Looks like a difference between zenscript syntax vs command block syntax

left is yours, right is mine

image

This ran without errors on my side, I added a few line breaks in addition to the above fix

import mods.zensummoning.SummoningDirector;
import mods.zensummoning.SummoningAttempt;
import mods.zensummoning.SummoningInfo;
import mods.zensummoning.MobInfo;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.world.MCWorld;
import crafttweaker.api.world.MCServerWorld;
import crafttweaker.api.events.CTEventManager;
import crafttweaker.api.event.MCEvent;
import crafttweaker.api.event.entity.MCEntityEvent;
import crafttweaker.api.event.entity.MCEntityJoinWorldEvent;
import crafttweaker.api.event.entity.MCLivingEvent;
import crafttweaker.api.event.entity.living.MCLivingDeathEvent;
import crafttweaker.api.event.entity.player.MCPlayerEvent;
import crafttweaker.api.event.entity.player.MCPlayerRespawnEvent;
import crafttweaker.api.event.entity.living.MCLivingHealEvent;
import crafttweaker.api.event.entity.living.MCLivingHurtEvent;
import crafttweaker.api.event.living.MCLivingUpdateEvent;
import crafttweaker.api.entity.MCEntity;

################################################################################## SWAMPJAW ############################################################################################

SummoningDirector.addSummonInfo(
    SummoningInfo.create()
        .setCatalyst(<item:minecraft:dirt>)
        .setConsumeCatalyst(false)
        .setReagents([<item:minecraft:bone>])
        .addMob(MobInfo.create()
            .setMob(<entityType:minecraft:stray>)
            .setCount(1)
            .setOffset(1,1,1)
            .setSpread(1,1,1)
            .setData({
            DeathLootTable: "minecraft:empty",
            Team: "bossbattles",
            "Health": 4,
            "Attributes":
                [{"Name":"generic.max_health","Base":4}],
            CustomName: "\"§cStray Soul\"",
            "CustomNameVisible":1,
            ArmorDropChances:[0.0f,0.0f,0.0f,0.0f],
            HandDropChances:[1.00f,0.0f],
                ActiveEffects:
                [{Id:28,Amplifier:0,Duration:100,ShowParticles:false}, {Id:7,Amplifier:69,Duration:1,ShowParticles:false}],
            "ArmorItems":
                [{},{},{},{}],
            "HandItems":
                [{
                    id: "minecraft:bow",
                    Count:1,
                    tag:{
                        display:{
                            Name:'[{"text":"Infinite Dread","italic":false,"color":"red"}]',
                            Lore:['[{"text":"A long forgotten bow, filled with the dread of the many souls it has collected.","italic":false,"color":"light_purple"}]']
                        },
                        Enchantments:[
                            {id:"infinity",lvl:1},
                            {id:"mending",lvl:1},
                            {id:"unbreaking",lvl:3}
                        ],
                        "quark:RuneAttached": 1,
                        "quark:RuneColor":{
                            id:"quark:magenta_rune",
                            Count: 1
                        }}
                }]
            })
        )
        .setMutator((attempt as SummoningAttempt) => {
            if (attempt.world.dayTime) {
                attempt.success = false;
                attempt.message = "This summoning can only be performed at night.";
            } else {
                attempt.message = "§cThe sky grows dark and cold.";
                attempt.world.asServerWorld().server.executeCommand("playsound minecraft:ambient.cave hostile @a ~ ~ ~ 1 0.7 1");
                attempt.world.asServerWorld().server.executeCommand("team add bossbattles");
                attempt.world.asServerWorld().server.executeCommand("team modify bossbattles friendlyFire false");
            }
        })
);
RobertHDPotatoes commented 2 years ago

That works, thank you so much! Is there some program/way to catch these mistakes or did you manually have to find the problem? If it's the former I'd appreciate it if you could let me know what the program/method is so that I can hopefully solve more of my own issues in the future! Also sorry about my trash formatting lol

TeamDman commented 2 years ago

There's a few vscode extensions for zenscript syntax highlighting, but other than that and good indentation there's not much beyond the error messages it gives you. Glad it's working!!