Jump to content

[1.12.2] Storing unique integer for custom entities?


Electric

Recommended Posts

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.

Link to comment
Share on other sites

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;
    }

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.