Jump to content

Recommended Posts

Posted (edited)
    @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
Posted (edited)

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
Posted

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 

  • Like 1
Posted

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?

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




×
×
  • Create New...

Important Information

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