Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I made a capability that saves 1 int in the player. It acts as the amount of money they have in their account. Upon death or relog, the cap resets back to it's default value. It works PERFECTLY otherwise.

I've asked multiple people. 5/6 don't know how caps work, the remaining 1/6 couldn't figure out the issue because my cap is basically a carbon copy of his, yet his persists.

 

Anyways, capability package:

https://github.com/LordSaad44/Cash-Shop/tree/master/src/main/java/me/lordsaad/cashshop/api/capability

 

Class that's hooking the cap to the player:

https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/api/ModCapabilities.java

 

Packet:

https://github.com/LordSaad44/Cash-Shop/tree/master/src/main/java/me/lordsaad/cashshop/common/network

 

Registering the cap:

https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/CommonProxy.java#L26

(registering the event down in postInit) (works perfectly, i breakpointed)

 

I tried the respawn event (PlayerEvent.Clone), but the original entity in the event had it's cap reset as well, so i was copying the default reset value from the original entity over to the new entity.

 

Respawn(clone) event:

https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/core/EventHandler.java

 

 

Because all you're doing on the respawn/clone event is telling the client about the old data.  You're not actually transferring the data to the new capability.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

How is it not updating though? I have a hud thing that renders the int on my hud, running the command (which sends a sync packet) updates it on my hud as well, therefore I can only assume it's being sent and read properly. Is the packet insufficient? What would I have to do?

  • Author

So basically make a packet that sends from client to server that acts on the cap. Right? That's what I'm getting here. That should be easy.

No.

 

Your capability exists serverside, this is where you make ALL CHANGES.  When a change is made you send a packet to the client to update the display.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

No no no... My display is updating properly. Getting the cap seems to return the proper one as well. So it's definitely working CLIENT side. But the clone event returns the default cap, so it's not changing on the SERVER. So i have to send the packet from client to server, right? You said it exists on the server, but I'm updating the value from the client.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.