#Datapack for Cobblemon

1 messages · Page 1 of 1 (latest)

compact breach
#

Hi, I’m trying to make a datapack for Cobblemon where wild Pokémon get cleared when the world changes from day to night and night to day. The function I created works perfectly, but only when I run it manually. I need it to happen automatically.

I already tried setting up tick.json and load.json and made a system to detect the time change, but it’s still not working properly. It just won’t trigger on its own.

If anyone can help me figure out what I might be doing wrong, I’d really appreciate it.

sonic skiff
#

can you show your work?

compact breach
sonic skiff
#

you should put your tags in data/minecraft/tags/function (assuming you're in 1.21+)

compact breach
#

yeah

sonic skiff
#

also why does your load function contain hs?

#

same with your tick function

compact breach
#

I'm a total noob at this and I was using GPT to help me, so it might be an error on their end.

sonic skiff
#

yea don't use AI for making datapacks or even just learning code. You're better off actually searching on google

sullen mapleBOT
sonic skiff
#

anyways you just need a way to detect the time right?

compact breach
#

yes

sonic skiff
#

let's start by removing the hs in those files :P

compact breach
#

and to have the function executed at a specific time.

sonic skiff
#

yea, here is what you should do:

  1. create a new scoreboard in your load function using scoreboard objectives add... The score will be used to store a value. https://minecraft.wiki/w/Commands/scoreboard
  2. query the time using the /time command and store this in a fake player score holder using execute store result.... https://minecraft.wiki/w/Commands/execute#storescore
  3. check if the score matches the right time using execute if score... https://minecraft.wiki/w/Commands/execute#(if|unless)_score

You should be able to find everything you need on the wiki pages refrenced.

A fake player is a name with a special character in front. This character is usually there since so no real player name could ever match that value. For example: #this_is_a_fake_player is a fake player score holder. Using # in front actually makes the commands more performant and doesn't make them show when you show your scoreboard in your sidebar

compact breach
#

scoreboard objectives add time dummy; something this?

stone kestrel
sonic skiff
#

ooh yea right

#

uum whoops

sonic skiff
# compact breach scoreboard objectives add time dummy; something this?

I'm sorry I gave you a significantly over complicated solution (maybe I shouldn't have helped you at 11PM :P) Here is a new and better solution:

  1. Create a predicate that checks for the right time. You'll need the condition time_check. Here is a nice generator: https://misode.github.io/predicate/
  2. check if the predicate is true to detect your right time using execute if predicate and run your function https://minecraft.wiki/w/Commands/execute#ifunlesspredicate

Again, you should be able to find everything you need on the wiki pages referenced.

Minecraft Wiki

Executes another command but allows changing the executor, changing the position and angle it is executed at, adding preconditions, and storing its result.