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

Hello,

 

I’m trying to store a per-entity int using capabilities, which seems to be working. The problem I have is accessing them form the model file. entityIn.getcapability seems to only return the default capability values I’ve set. Any suggestions? 

You need to synchronize the capability from the server to the client yourself.

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
1 hour ago, Draco18s said:

You need to synchronize the capability from the server to the client yourself.

Okay, now I'm confused on what goes in this method. How can I send the player capability data?

@Override
        public IMessage onMessage(MessageUpdateClientTardis message, MessageContext ctx) {
            EntityPlayerMP serverPlayer = ctx.getServerHandler().player;
            serverPlayer.getServerWorld().addScheduledTask(() -> {
                
            });
        return null;
    }

 

  • Author

I've done the toBytes and fromBytes. I'm just not sure how to copy it to the client-side instance, since there isn't much documentation on it.

4 hours ago, diesieben07 said:

Well, how can there be documentation, if it's your code?
And you certainly know how to copy data from one field to another, right?

I think he probably means that from the message class, how do you figure out the world and thus the entities instances available to match against.

 

I'm not entirely sure it is the best way, but I used to do the following in a mod. Note that getting entity by ID might have changed in more recent versions. In the message from server to client, in the onMessage() method I would get the player from the context then the world from that as follows:

 

EntityPlayer thePlayer = MainMod.proxy.getPlayerEntityFromContext(ctx);
Entity theEntity = thePlayer.world.getEntityByID(message.entityId);

 

Where in my proxy I had the getPlayerEntityFromContext() method as follows for client proxy:

    public EntityPlayer getPlayerEntityFromContext(MessageContext ctx)
    {
        return (ctx.side.isClient() ? Minecraft.getMinecraft().player : super.getPlayerEntityFromContext(ctx));
    }

And in my common proxy had:

    public EntityPlayer getPlayerEntityFromContext(MessageContext ctx)
    {
        return ctx.getServerHandler().player;
    }

 

 

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Why you would ever have to pass that through your proxy, I don't know. You already know which side it's on as packets should only go one way: it's sent from the server to the client, the packet handler therefor only exists on the client and it's safe to use Minecraft.getMinecraft()

Likewise, going the other way.

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.

1 minute ago, diesieben07 said:

Packet handlers always exist on both sides.

Hmm. My mental model must be out of date. I just checked and I'm running stuff through my proxy as well.

Never mind.

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.

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.