Jump to content

JayZX535

Members
  • Posts

    83
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

JayZX535's Achievements

Stone Miner

Stone Miner (3/8)

3

Reputation

  1. Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is. I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins. I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding. However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc. These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly? But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
  2. That's basically what the failure does, my apologies for failing to specify. It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity. From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user. There should be few cases where that actually happens. Yes, that is my understanding of forceloading. That's why on a successful summon, it removes the forceload. Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful! I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
  3. Ah, it appears I spoke too soon, I still need a little help here. I now have the forceloading working reliably. However, I've realized it's not always the first tick that loads the entity. I've seen it take anywhere from 2-20ish to actually go through, in which time my debugging has revealed that the chunk is loaded, but during which time calling serverLevelIn.getEntity(uuidIn) returns a null result. I suspect this has to do with queuing and how entities are loaded into the game. While not optimal, it's acceptable, and I don't think there's a whole ton I can do to avoid it. However, my concern is that occasionally teleporting an entity in this manner causes a lag spike. It's not every time and gives the appearance of being correlated with when other chunks are loading in. It's also not typically a long spike, but can last a second or two, which is less than ideal. The gist of how I'm summoning is here (although I've omitted some parts that weren't relevant. The lag occurs before the actual summon so I'm pretty confident it's the loading, and not the actual summon call). ChunkPos chunkPos = new ChunkPos(entityPosIn); if (serverLevelIn.areEntitiesLoaded(chunkPos.toLong())) { boolean isSummoned = // The method I'm using for actual summoning is called here. Apart from a few checks, the bulk of it is shown later on. if (isSummoned) { // Code that runs here just notifies the player of the summon, clears it from the queue, and removes the forceload } } else { // I continue forcing the chunk until the summon succeeds, to make sure it isn't inadvertently cleared ForgeChunkManager.forceChunk(serverLevelIn, MODID, summonPosIn, chunkPos.x, chunkPos.z, true, true); } The summon code itself uses serverLevelIn.getEntity(uuidIn) to retrieve the entity, and moves it as such. It is then moved thusly: if (entity.isAlive()) { entity.moveTo(posIn.getX(), posIn.getY(), posIn.getZ()); serverLevelIn.playSound(null, entity, SoundEvents.ENDERMAN_TELEPORT, SoundSource.NEUTRAL, 1.0F, 1.0F); return true; } I originally was calling .getEntity() more frequently and didn't have the check for whether or not entities were loaded in place to prevent unnecessary code calls, but even with those safety measures in place, the lag still persists. Could this just be an issue with 1.18's lack of optimization in certain areas? Is there anything I can do to mitigate it? Is there a performance boosting mod I could recommend alongside my own to reduce the chunk loading lag? At the end of the day, it does work, and I'm putting measures in place to prevent players from abusing the system to cause lag (i.e. each player can only have one queued summon at a time-- trying to summon another replaces the first call). It's also not an unacceptable level of lag, IMO, given the infrequency of such calls, and the fact that I'm providing the option to toggle off the feature if server admins don't want it used. However, no amount of lag is ideal, so if possible I'd love to find a more elegant solution-- or at least a mod recommendation to help improve it. Thanks!
  4. Finally circling back to this, and I think all of us were half right. getChunk() does appear to immediately load the chunk, but what changed between 1.16 and 1.18 is that the list of entities is now stored in the server, not per chunk. So while it was possible to load a chunk in 1.16 and immediately grab an entity out of it, 1.18 loads the chunk and submits a request to load its entities on the next tick (if I understand correctly). All this to say, you can immediately access the chunk itself, however you have to wait an additional tick for its entities to load in. In my case what this means is that I do have to set up an interface to wait an additional tick before submitting the request to retrieve the entity. However, other functions do appear to be available immediately. Just depends on what you're trying to do. Thank you all for the help!
  5. I've tried multiple ways to get the chunk coordinates and none of them have worked, so I'm guessing it may be getChunk(). Is there another way to forcibly load a chunk on that same tick? If all else fails I guess I can just delay my action by a tick, but that's a pain in the butt and makes it more complex to provide appropriate feedback... Also welcome, Zander. If you're searching for a similar solution, I hope this (eventually) helps you too 😅
  6. I'm saving and storing the position at a different point. I know it's accurate in my testing cases because I'm also displaying the entity's coordinates, and if I manually teleport to them I can verify the entity is there.
  7. Huh, well that's more straightforward than I expected. Good to know, thanks! Entity here is still coming back null, though. Do I need to retrieve the entity differently? Right now I'm doing it like this- serverLevel.getChunk(chunkPos.x, chunkPos.z); Entity entity = serverLevel.getEntity(uuidIn);
  8. Hey all, I'm wondering if there's a way to forceload a chunk instantly in 1.18.2. I'm updating an older mod from 1.16, and in that version of the game I was able to do so just by calling serverWorld.forceChunk(chunkPos.x, chunkPos.z, false); which would then enable me to access the Chunk at that location and get a list of the entities inside it (which is my end goal here as well). However, although in 1.18 I still have the ability to call serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false); it no longer seems to load the chunk immediately, but instead (from my understanding) submits a ticket to load it on the next tick. This is problematic for my use case, as my goal is to load the chunk, access an entity within it, and then deload the chunk on completion, which I can no longer do in a single tick with this method. LevelChunks also don't seem to contain a list of entities anymore in 1.18, and seem to have less automated functions connected to them, which could I suppose also be the source of my issue. Is there a way to load a chunk instantaneously from its coordinates and immediately access the entities within it?
  9. Update: After much more digging, I finally found an answer: Microsoft must've changed something on their end that altered authentication. If multiplayer is showing as disabled for you, you need to follow the steps listed here to get your access token from a profile that authenticates normally outside the dev environment: https://gist.github.com/50ap5ud5/beebcf056cbdd3c922cc8993689428f4#minecraft-authentication-in-dev-environments In my case it turned out I just needed my access token, it may or may not still need the UUID. The guide is older so I don't know how many versions it will hold up in, but in my case this did seem to be what Eclipse was looking for.
  10. Is there a setting I need to enable to allow me to use multiplayer through Eclipse? Launching the client works, but the multiplayer and realms button are greyed out and hovering over them gives me a "multiplayer is disabled" tooltip that asks me to check my Microsoft account settings, which is... not great for testing purposes. I know on the server end you have to put it in offline mode to be able to sign in, but I've never seen it have this happen on the client end.
  11. Oh! I will take a look at those methods, thank you! Do entities written as NBT using the built-in methods to write them to NBT tend to be particularly bulky? That's my biggest concern here. I'm hoping many of them won't be, but I'm especially worried about the sort that can actually have inventories. I need to save the data for them, ideally a potentially large quantity without having to worry about overloading anything, into a capability, but if that's likely to get out of control quickly, I'll have to figure out how to cap it.
  12. Hey all, This is another mostly theoretical question-- how much data can a capability be reasonably expected to store without getting overwhelmed and crashing (and more importantly, how does that practically correspond to the amount seen in items, entities, etc.). I've seen cases where modpacks have experienced crashes due to players putting full storage containers in storage containers in storage containers, but even when the crash occurred, it seemed like it took a lot to get to that point. If I want to create capabilities that can store the data for example of a storage container, or write the data of a bunch of entities to a capability, for example, at what point should I be concerned about storing too much data? Or is it something that I likely don't need to worry about because it really only occurs when someone is storing many full chests' worth of items within a single inventory? Thank you for your time, and have a great day.
  13. Well, right, the exact drops each time are random, but if I can get the list of what items are possible then I can compare that to the ItemStacks given in the drop event to see what to rule out as a probable natural drop. But thank you! I'll take a look at it and see what I can do.
  14. Thank you! And ooooh hm, alright, well that's a start... at the very least sounds like that's my EXP issue solved. Is there a way to get the possible list of drops from a loot table in code? And how would I go about getting the loot table from an entity? At the very least, it seems like that could give me a slightly dirty solution of killing anything that matches up with the loot table. It's not perfect because if the entity is carrying an item it can also drop, it would still get destroyed. But that would cover most cases...
  15. Hello, I'm trying to figure out how to approach a feature I'd like to include in a mod (I don't have code to show for it yet because it doesn't exist yet, I'm still determining how to go about it in the first place). In essence, I want to cancel the loot and exp drops specifically, not the entire drop event as a whole. This is conditional per entity in a way I'm pretty sure the loot tables themselves can't detect, so I can't just replace the loot table for all entities. Redirecting it to a blank one would be an acceptable solution if I can do so from within the mod. I also can't just cancel drops as a whole because I want entities with gear to still be able to drop it, nor can I override based on a list of specific predefined entities because I'd like to make this as flexible as possible. So the basic outcome I'm looking for is... Death/Drops Event is intercepted and if the entity matches the criteria-- -It will NOT drop exp -It will NOT drop its normal loot table drops -It WILL drop any gear that has been equipped to it Does this seem like something that would be possible to do, and if so, could someone point me toward some resources/examples on how I might be able to pull it off? I'm mostly not sure what events I would even need to look at, or how to catch and alter what loot table it's pulling from. Thank you for your time.
×
×
  • Create New...

Important Information

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