kyrptonaught / customportalapi

Developer Api for creating custom portals to any dimension
MIT License
63 stars 22 forks source link

Portal color is always black #60

Open Unreal852 opened 2 years ago

Unreal852 commented 2 years ago

Hi, I'm using CPA with a mod that i made. Everything is working nicely except that the portal is always black no matter which color i use. I create the world and the portal on the server side. Am i doing it wrong or is this a bug?

Unreal852 commented 2 years ago

I just noticed, if i disconnect and then reconnect to my server the color is the good one, i assume there is a sync issue when creating a portal.

kyrptonaught commented 2 years ago

What mc version and cpa are you using? Is your mod installed on both the server and client?

Unreal852 commented 2 years ago

I'm using minecraft 1.19.2 and CPA 0.0.1-beta53-1.19. Yes the mod is installed on both the server and client.

kyrptonaught commented 2 years ago

I never officially updated cpa to 1.19.1 or .2, I wonder if that could be causing any issues. I'll investigate later today.

In the meantime, could you link your code somewhere? Just to check it out and rule out any errors that might be there

Unreal852 commented 2 years ago

Sure, here is the project and here is where i create the portal. If you want to try it, start a dedicated server and a client, OP your client and then use /quantum create your_world_name. When thats done just build a bedrock portal and ignite it with a diamond, you should see it black, then disconnect and reconnect your client and you should see it green.

kyrptonaught commented 2 years ago

I think I see why. The portal is getting created on the sever when you generate a world with the command. Portals get synced to the client on join. So since the portal is created after the client has already joined, it never syncs.

I'll have to add a way to force sync a portal

Syncing code: https://github.com/kyrptonaught/customportalapi/blob/1.19/src/main/java/net/kyrptonaught/customportalapi/networking/PortalRegistrySync.java

Unreal852 commented 2 years ago

Yeah i see the problem, i can write my own sync code for now. If you don't want to always sync portals on creation maybe you can add a .forceSync() in the portal builder class and then when registering the portal if the forceSync was used, you broadcast a packet to all connected clients.

kyrptonaught commented 2 years ago

One issue with this is that we need to get an instance of the MinecraftServer. I did add the methods to send the packet in PortalRegistrySync. Just not sure on the best way to call this.

See latest commit for more info

Unreal852 commented 2 years ago

Maybe you can ask for a MinecraftServer instance within the forceSync in the builder but i don't think its a good way of doing it.

warior456 commented 1 year ago

wierd issue i have something similar: in my dev enviroment with intellij my portal color is completely fine but in my released version it is broken somehow

kyrptonaught commented 1 year ago

There was a sodium incompatibility. This was fixed in beta63

wierd issue i have something similar: in my dev enviroment with intellij my portal color is completely fine but in my released version it is broken somehow