Jump to content

Recommended Posts

Posted

I read on one of these threads to use addScheduledTask to do things "next tick". I call it on the server side, and it seems like the Runnable I give it only gets called on the client.

 

Is this normal?

 

Posted
Just now, Animefan8888 said:

If you are using Minecraft#addScheduledTask yes. You probably want WorldServer#addScheduledTask

Ahh, thanks so much. I was already trying to come up with silly workarounds like recursively adding tasks til it gets called on the server.

Posted
32 minutes ago, Animefan8888 said:

Well depending on what you are doing there might be a better way to run code on the next tick.

Still working on that load chunk -> teleport entity bit. I wanted to make sure the chunk was loaded and also have access to the variables in the function that loads the chunk. Maybe its possible without the next-tick bit though, couldn't really find information on whether forceChunk happens right away or queues the chunk up for loading

Posted
6 minutes ago, stepsword said:

Maybe its possible without the next-tick bit though, couldn't really find information on whether forceChunk happens right away or queues the chunk up for loading 

If I'm not mistaken I don't think you should use forceChunk as that is meant for persistent chunk loading. So if you were to just do something along the lines of Chunk chunk = World#getChunkAt(...); Which should load the chunk immediately. Then you can get the entity either from the chunk or from the world. Then move the Entity. And the chunk will unload just like that.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
5 minutes ago, Animefan8888 said:

If I'm not mistaken I don't think you should use forceChunk as that is meant for persistent chunk loading. So if you were to just do something along the lines of Chunk chunk = World#getChunkAt(...); Which should load the chunk immediately. Then you can get the entity either from the chunk or from the world. Then move the Entity. And the chunk will unload just like that.

Haha - I learned that the hard way actually, while trying to get the Chunk to check isLoaded() I called getChunkAt().. which loads the chunk. That said, I do have one command planned where it would be useful to keep the chunk loaded so I'm trying to get it working with tickets for this one which will be simpler to test than the other one.

Edited by stepsword
Posted (edited)

As an update: something I think wasn't immediately clear to me is that forceChunk seems to be only for chunks which are already loaded? i.e. if you call forceChunk on an unloaded chunk, nothing happens - you have to load it, then call forceChunk to keep it loaded. I haven't done a lot of testing of this theory to confirm if it's true, but based on the usage of getPersistentChunks() by Forge, I think it's true.

 

This is in the "unload chunks" method. I guess this probably isn't a problem for most people but in case someone stumbles on this later looking for why their forceChunks on a remote location isn't working, it could be because forceChunks only prevents loaded things from being unloaded, so they have to be loaded first for forceChunks to actually work.

 

if (!this.droppedChunksSet.isEmpty())
{
    for (ChunkPos forced : this.world.getPersistentChunks().keySet())
    {
Edited by stepsword

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); It says that '.get()' is deprecated since version 1.21.1 and has been marked for removal. How should I replace this line or section of code so it works? Or is there a way to fix it? Full Block of Code: IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();    // This is the line that's messed up... I don't know why modEventBus.addListener(this::commonSetup); MinecraftForge.EVENT_BUS.register(this);
    • Sorry to have bothered everyone.  I think I've figured it out: NbtUtils.snbtToStructure() will allow me to get the compound tag from a string I can load, and ItemStack.setTag() will allow me to write it to an item. Again, sorry to bother everyone -- it took a long time to work it out, it seems finding answers on the internet by googling isn't a viable way to get info so it took a lot of guessing, experimenting, and trial and error until I hit upon the path to a solution.
    • Hello, My modded forge server was working with no issues up until last night. The current issue is that the server crashes as soon as another player joins.   Steps I have already tried: Deleted these files: banned-ips.json, banned-players.json, ops.json, usercache.json, whitelist.json. Deleted all player files Deleted the chunk that player was in   Mods: Pixelmon 1.20.2, 9.2.10 Crash log: https://pastebin.com/qauuZLRE Latest Log: https://pastebin.com/TxCGS4sc Other issue I get when starting up the server: [LanServerPinger #1/WARN] [net.minecraft.client.server.LanServerPinger/]: LanServerPinger: Network is unreachable
    • I tried to reinstall the server multiple times but nothing worked and I keep getting the same error... I do have the correct java 21 installed or whatever it was. I couldn't find whats causing this problem as I tried a lot to reinstall the files again and again.
    • OK, what I need is to be able to take a JSON string, from a config file or data pack, and convert into NBT that can be applied to any arbitrary item (technically, item stack). This could easily be done in 1.12.2 using JsonToNBT.getTagFromJson(String data) like so: NBTFromJsonWrapper(String label, String data) { super(label, label); try { wrapped = JsonToNBT.getTagFromJson(data); } catch (NBTException e) { System.err.println("Exception reading json-nbt string: " + e.getMessage()); wrapped = new NBTTagCompound(); } } However, I can't seem to find a way to do this in newer version, specifically 1.19.4 (though once I'm done updating to that version I plan to be updating the latest 1.20 and 1.21 version). Alternately, of these NBT strings that resemble JSON but are not quite would be just as good, perhaps better: {ench:[{lvl:3s,id:35s},{lvl:5s,id:32s}],Unbreakable:1b,display:{Lore:["Believe it or not, this comes from ","an ancient Vanilla World. "],Name:"Fortuna Major"}} This was previously used for several purposes, one was simply to create purely vanilla potions.  The other was to create special items, primarily as trophies albeit practically useful trophies, often in the form of Easter Eggs. (I also had a homebrew system along side it, but I don't think I'll be updating it.) Any help would be appreciated.  Surely there is still a way to do this, and codecs do not seem to be the answer.  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.