Jump to content

Recommended Posts

Posted

In 1.12.2 I was able to use messages between the client and server (https://github.com/ImNotJahan/danmachi-mod/tree/master/v1.12.2/src/main/java/imnotjahan/mod/danmachi/network) I can't figure out how to get any of that to work for 1.16.5 though. This is all my capability code

IStatus

  Reveal hidden contents

StatusStorage

  Reveal hidden contents

Status

  Reveal hidden contents

StatusProvider

  Reveal hidden contents

Where I'm accessing the capability:

StatusGui

  Reveal hidden contents

MonsterBase (Inside die method)

  Reveal hidden contents

 

Posted (edited)
  On 9/3/2021 at 7:35 AM, diesieben07 said:

This is invalid.

  1. instance is not a LazyOptional, this cast will always fail.
Expand  

Bit off-course from the original question, but I've changed my getCapability code to this

@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction side)
{
	return capability == STATUS_CAP ? lazyStatus.cast() : LazyOptional.empty();
}

based off of what I found in the forge docs on capabilities, but capability is now never equaling STATUS_CAP, so I'm not sure what's going wrong

Here's what the STATUS_CAP code looks like:

    @CapabilityInject(IStatus.class)
    public static final Capability<IStatus> STATUS_CAP = null;

And also the lazyStatus incase that's important

private static final LazyOptional<IStatus> lazyStatus = LazyOptional.of(Status::new);

 

Edit: It also looks like the getCapability function isn't used at all? At least that's what I've gotten from placing random System.out.println's everywhere. I'm guessing I'm not registering the capability correctly 

    @SubscribeEvent
    public void attachCapability(AttachCapabilitiesEvent<Entity> event) 
    {
        if (!(event.getObject() instanceof PlayerEntity)) return;

        event.addCapability(new ResourceLocation(Reference.MODID, "status"),
                new StatusProvider());
    }

but this seems to be what the docs say to do so I'm not sure if anything's wrong with it

Edited by ImNotJahan
Posted

It wasn't!

This isn't really a good thing but now I figured out that it shouldn't be on the mod bus, and so now it's attaching correctly and the getCapability function is being ran, and everything else seems to be working even without networking (for now at least) so thank you very very much

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.