I am trying to make a custom entity from a mod to spawn in a structure
I tried doing so using jigsaw blocks, but they keep the exact same details each time, causing some issues
I want to know if the issue can be avoided by using a script, that will generate the entity each time the structure spawns
Also I don't really know how scripts work so might need some help with that
#Making the spawned mob have nbt data
1 messages · Page 1 of 1 (latest)
What details do you mean are the same
Like their NBT
Structure blocks copy the exact entity
or the items they have
Yeah but what details need to be changed
nbt
Also Java doesn't have scripts
so I made this pack for the cobblemon mod
and the entity(the pokemon) I made always had the same ID
meaning that they are considered dupes and are removed upon relogging
Youmean UUID?
maybe I got it confused with functions?
yes
you can use the jigsaw blocks to spawn a marker and then use a function to summon the entity at that position whilst killing the marker.
Functions exist, yeah
Odd 🤔 Shouldn't be doing that
oh for real?
cobblemon has a custom UUID system right?
Possibly
I thought it was intended behavior
I think so
Probably to avoid duped cobblemon
No idea
Yea I think it is, I saw this issue a long time ago
This should work though
how would I go about doing that?
Have you ever used functions?
and will it work in a world where commands are turned off?
yea
nope
started doing this while making custom mons
taking this as a learning expiriance
View this guide on datapack.wiki: https://datapack.wiki/guide/getting-started/
You should read this first
Oop wrong reply
I recommend checking out the beginners guide
can the functions also call commands who are specific to the mod?
Yes
because cobblemon doesn't use the normal summon command
yea most of the time, thats no problem, I'm pretty sure it works for cobblemon
I think I'm getting somwhere with this
I assume the way I make this not accessible by just renaming the armor stand is making it invisible and maybe even giving it an effect?
ok this is strange
It spawns my entity wrong
could this be tied to the fect my datapck only loads after a world is made?
ok yeah /place works fine
any way around this?
You're gonna need to be more specific
so what my datapack does is add a form for the pokemon eldegoss
the way it handles forms is by giving them a tag
when the world is made(a completely new one)
normal eldegoss spawn on the trees despite having the datapck
Shouldn't have anything to do with load order, the data pack is loaded when those entities get spawned since you're spawning them with functions.
then why are they loaded as normal?
When I use /place my version shows up
I don't know
is there a way to make it so my command only works while the player is close to the structure?
yea use execute if entity @a[distance=..50] for example
won't replace them at all now, did I get something wrong?
You're checking if the player is exactly 300 blocks away
Blackswitch's example included .. for a reason, they indicate a range/greater than or equal to/less than or equal to
Is that what you think it does?
no
What do you think it does?
I just think I got something wrong
I believe the part that checks where the player is and the detection of the armorstand should be seprate
Correct
like @a is to check where the palyer is
and @e is to located the armor stand
Right now you have it checking if there is a player within ranger that is an armor stand, which of course will never be true
so right after my if should be an as statement?
execute if entity @a[distance=..300] as @e[type=armor_stand,name="Spawn"] at @s run pokespawn eldegoss end status=sleep
something like this
You want to switch your as @e at @s and the if entity
Think about it logically. First the function needs to know who it's running as and from where, before it can accurately check who is near it
oh so the if just comes right at the end?
ok no still confused
in the first part, I tell it who to run the command on
shouldn't the second part check if a player is nearby?
so like @e as then if entity @a and then @s
I believe I'm still doing something wrong, the entity is spawning but I don't think my distance has anything to do with it
What would you like more clarification for
Yeah that makes sure that every player is within 50 blocks
..50 is the same as <(or equal to)50
so this is written out correctly?
Assuming your goal is that every player needs to be within 50 blocks then yes
Then probably add sort=nearest and limit=1
How is it not working?
if I'm more then 50 blocks away, I would still not see the armor stands I placed
That might be a thing with armour stands
Place an armour stand then go 50 blocks away and just test it
disappears immdietly without spawning anything
I might have understood why
I'm killing them on loop
so even if they don't spawn anything they would still be replaced
That would be it
What do you mean?
It kills before you get close enough
maybe?
That should be tested
even if I place it down it disappeares instantly
how can I make it so it only kills it when replaced
Make the check run a function that summons eldegoss and kills the stand
I can run 2 commands at once?
ohhhhh so basicaly make a file that has the command and call it by saying run function name
It would have 2 commands but yeah
execute ... run function namespace:function
ok so I can now see the armor stand
first time placing the structure went fine
second time they won't spawn the mob
and I am close to them
So now the issue is it only spawns the armour stands?
execute as @e[type=armor_stand,name="Spawn_shiny"] if entity @a[distance=..10,sort=nearest,limit=1] at @s run function endegoss:eldegoss_shiny_spawn```
kill @e[type=armor_stand,name="Spawn"]```
kill @e[type=armor_stand,name="Spawn_shiny"]```
so it spawns once, but when you /place it again it doesnt?
yeah
yeah but that's from the jigsaws
pretty close
try a bit further away and see if it changes
alright that is weird
probably not
when are these functions even running
What makes this run
tick.json
alright
ok I loaded the chunk it's in but nothing changed
and it works in spawn chunks?
no stopped working there as well
ok
it does work well for a while after /kill @e
thats incredibly weird
also with this the @e is unnecessary, try @s
since it already runs as the armour stand
still spawns armor stands
how are you applying these changes btw
wdym?
/reload or relogging the world
tried both
alrighty
so unfortunately I do have to go for a bit, but another helper might be able to help you fix your issue
no problem
thanks for the help!
ok so my problem is defiantly related to the player distance check
removing it solved everything
also I think I might not need it
what I do need to know is if there is a way to do a /reload automatically on load
oh wait really?
why is that?
I removed the @a part entirely
it just runs
but upon loading it for the first time it still has an issue which causes it to spawn the wrong version of the entity
but running a /reload before entering the end solves that
so is it possiable to run /reload as soon as my pack is loaded?
and will it have a negative impact on other packs?
It might
Probably won't
Just add reload to a load function
Like tick.json but load.json
it might cause a loop of reloads
so I would add a scoreboard that checks if it has been ran before
ohhh never done that before
so basicaly I make it run it once, up the scoreboard, and then it won't run again becasue the scoreboard says it already did
kinda like a flag
yeah exactly
alright
but the main function should be called from load.json
no?
no, it automatically runs once when your datapack is loaded
so when a server starts or a singleplayer worlds gets made/joined
this is about load.json?
yes
and inside will be a call to the function that does a /reload when it is the first ever time being loaded
which I will know by setting a scoreboard
where do I generate the scoreboard
asumming it's supposed to happen once
"values": ["endegoss:reloader"]
}```
this is how this looks now
reloader just has reload command in
and it in fect just spammed it like you said
so do I add a function here that makes a scoreboard?
Not a separate function
So just in load.json?
Won't it make it run in a loop
Or remake the same scoreboard over and over again?
Gonna be honest kinda lost here
how can I use scorboards as a flag?
like I get how you set one up it's just
how do I add something to it to act as my flag
You don't need to do anything special, there is no "flag" setting
You just set it to 1 or 0, or whatever value(s) you care about to determine the status of whatever it represents
scoreboard players set #reload reload 0```
like this?
Sure
because what I'm trying to do is to make my datapack run the /reload command on the first time it's loaded in
yeah but if you don't reload right as the pack is added it spawns my entity wrong
No I mean even when added to a completly new world
from the create world screen
Then you need to reasses what is in your load function
Cause that shouldn't be the case
what I wanted it to do is to check the scoreboard and see what the value is
if 0, then run a reload and set the value to 1
then every time it will open in the future, it won't force a reload
But what is in your load function right now that isn't running correctly when the world actually loads?
oh I didn't have a load function
I just added it
I had a tick.json file just running my spawn command
I see
but now I want to add a load.json that does what I described here
will this not work?
It will technically work, but it's bad practice and solves a problem the cause of which isn't well-understood
yeah I do get that part of it but I fr don't get what the problem is
It spawn correctly after I use /reload or log out
it just that I want everyone to be able to just use it without having to run a command or relog
Naturally
so I'll keep going with what I started here
but I don't know how you check things in a scoreboard
is it another execute if
Yep
also, is the load.json file running every single tick as well?
and in the way it is rn, won't it just reset back to 0 every time I open the world?
and remake the scoreboard?
Well it won't remake the scoreboard, but yes it will reset it to 0
so condition for the second line as well
Or instead, you don't have to set the score to 0 at all
And you can just do execute unless score ... to see if the score has already been set to 1, and if it hasn't, set the score to 1 then reload
scoreboard players set #reload reload
execute unless reload=1 ```
Is this right? still trying to get the hang of it
scoreboard players set #reload reload
execute unless score #reload reload = 1```
Line 2 is incorrect syntax and will fail to validate. You also don't need it
do I not have to add the player?
Shouldn't need to
Line 3 is also incorrect syntax and will fail to validate. Rather than using an = here, you instead need to use matches
oh in game it was =
Writing either of those in-game would have shown as errors
= is acceptable in that command but you're using it wrong
It's used to compare two scores of one or more entities. If you're comparing to a specific value, you use matches
oh I see it now
ok
and after this one all I should do is run the command for a reload and up the score for #reload to 1
Yes. You'll need to do both of those in a new function that gets run by that command
execute unless score #reload reload matches 1 run function reload_updater```
reload_updater
```reload
scoreboard players set #reload reload 1```
You have a logical error in reload_updater, can you see it?
maybe reload after updating becasue if I do it before it all gets reset and then it will not work
Yep
ok so either what I did didn't solve the problem or it just stright up didn't work
say reloading!!!!
say reloading!!!!
reload```
I placed this to see if it actually worked or not, is this a valid way to check, becasue I didn't see anything
It is a valid way to check, but it may be sending the say commands before the player enters the world
logs then
Mhm
nothing in the logs
that means it's not calling it
also when I check the scoreboard, it's empty
In that case, try adding a new line 2 with scoreboard players add #reload reload 0
won't it reset every time then?
oh right
list still empty
and logs show no sign of my message
it's like I can't even add a dummy player to the list
when I try it ingame, it does say it worked but won't show at all
yeah
Elaborate
it does make the scoreboard named reload
but when I type this in
it says that it did that, but nothing shows up on the sidebar ingame
works fine when I add myself
Mhm
do they not react to the get command as well?
They do.
oh it worked this time
the value is 0
no the problem is still here I'm afride
it's the get command that worked
if it reloads, the value should be 1
yet it's zero
you mean the problem with the reloader or the one with the entity
because the entity problem is solved when I /reload
...Yes, I know that, which means I must be talking about the reloader, huh?
sorry I get confused easily sometimes
the scoreboard is still 0, even after reloading
What happens if you run /execute unless score #reload reload matches 1 in chat?
Well we weren't changing it
Define nothing
no output at all
It should at least tell you if the test passed or failed
Turn on sendCommandFeedback?
passed
So that's working fine
but with the run command attached to it it doesn't say anything
Can you run reload_updater from chat?
idk then
execute unless score #reload reload matches 1 run function reload_updater
this is the way I call for it
Mhm
so everything is correct yet it still won't work
Seems like it
For now you can wait and see if another helper can spot something I missed
k
thanks for the help!
welp through trial and error, I believe it now works as intended
ok so new problem
I want my entity to not despawn at all
but cobblemon made it difficult
is there a way for me to run the /data merge command with {PersistanceRequired:1b} but only on the entity that spawns on the armor stand?
like maybe by executing a command using @n for near entities
execute as @e[type=armor_stand,name="Spawn"] at @s run data marge @n {PersistenceRequired:1b}
kill @s[type=armor_stand,name="Spawn"]```
I did this but I it didn't work
I think my logic is wrong somewhere
Making the spawned mob have nbt data