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

  • Author
    @SubscribeEvent
    public  void onPlayerPreTick(final TickEvent.PlayerTickEvent  event ,final AttachCapabilitiesEvent<Entity> event1){
      Player player = event.player;
      boolean iof = player  instanceof Player;
        if (iof ==true) {
            LazyOptional<MyCapabilityInterface> stats1 = player.getCapability(MyCapability.INSTANCE);
            MyCapabilityInterface myCapabilityInterface = stats1.orElseThrow(IllegalStateException::new);
            myCapabilityInterface.tick(event.player);
            final MyCapabilityProviderEntity provider = new MyCapabilityProviderEntity(player);
            event1.addCapability(IDENTIFIER, provider);

Is this what you mean? I'm getting an error on this one, but...

 

Edited by ocome

  • Replies 54
  • Views 15.7k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • did you looked at the example

  • in AttachCapabilitiesEvent you need a ICapabilityProvider which holds your Capability

  • yeah add the getManaLevel to the interface of your Capability and and implement it into your CapabilityHandler

  • Author

Do you mean to call Event instead of tickevent and get each item from there?

 

In the case of ManaOvarlay, it was good without using addCapability,

and I thought it would be the same way this time, but I couldn't figure out why this was bad

Edited by ocome

no, you need both the TickEvent which calls your custom logic each Tick and the AttachCapabilitiesEvent which adds the Capability to all Entities which should hava your Capability.

Read the doc about Events it explains everything about how to use Events. If you don't know how to create a Event handler, I would recommend you to first learn the basics of java before modding minecraft 

  • Author

I understand. 
I'm stuck and will study the documentation and java a little deeper.

 

            if (event.phase == TickEvent.Phase.START) {
                MyCapabilityImplementation.tick(event.player);
            }

By the way, is there any problem in creating it this way?

7 hours ago, ocome said:

By the way, is there any problem in creating it this way?

looks okay but I would recommend you to check also the side, since you should call the logic only on server and if it's required update the client via a custom Packet 

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.