Ad Astra

Ad Astra

23M Downloads

[Bug][NeoForge]: star-map does not work

canitzp opened this issue ยท 4 comments

commented

Bug Description

I'm testing the latest AdAstra version (1.16.3) with NeoForge and I ahve noticed, that the star-map does not work. It is just empty.
I don't have any additional datapacks installed.
I also tested several versions of NeoForge, but nothing changed.

2024-02-09_13 52 28

How to Reproduce?

  1. Install AdAstra with NeoForge on Minecraft 1.20.4
  2. Create a new world
  3. Run command "/adastra planets"
  4. View the non-existent planets

Expected Behavior

No response

Version

1.16.3

Mod Loader Version

1.20.4 - 20.4.146-beta

Mod Loader

NeoForge

Logs or additional context

There is no error in log

Code of Conduct

  • I have searched the issue tracker and confirmed that the issue has not been reported
  • I have checked the FAQ (if one is present) and my issue is not listed
  • I have verified that I am using the latest version of the mod
  • I have verified that I have installed all the required dependencies for the mod
  • I have verified that I do not have Optifine installed. We will close issues if we detect Optifine is in your pack. We cannot fix Optifine issues. Please do not report issues with Optifine present.
commented

So I have investigated this problem a bit. Turns out the "ClientboundSyncPlanetsPacket" does not work properly. The encode (

(buf, a) -> AdAstraData.encodePlanets(new FriendlyByteBuf(buf)),
) and decode (
(buf) -> AdAstraData.decodePlanets(new FriendlyByteBuf(buf)).stream()
) are never called. Since I don't know, how the ResourcefulLib networking works, I can't investigate further.

commented

So I have investigated this problem a bit. Turns out the "ClientboundSyncPlanetsPacket" does not work properly. The encode (

(buf, a) -> AdAstraData.encodePlanets(new FriendlyByteBuf(buf)),

) and decode (

(buf) -> AdAstraData.decodePlanets(new FriendlyByteBuf(buf)).stream()

) are never called. Since I don't know, how the ResourcefulLib networking works, I can't investigate further.

The reason they are never called is because Encode and Decode dont get all in singleplayer this is to optimize the games performance as to not do unneeded operations when there is no actual network all it does is send the packet object to the handle method right away.

commented

I was able to reproduce it so I'll check it out

commented

problem was that since there were no encoding and decoding, ie the map reference was sent directly instead of creating a copy, it was clearing itself and then setting itself to itself. Fixed it by just creating a copy of the map before clearing the original and then setting the original to the copy. It was working on fabric because I guess fabric still encodes and decodes?

public static void setPlanets(Map<ResourceKey<Level>, Planet> planets) {
PLANETS.clear();
PLANETS.putAll(planets);