Posted October 28, 20178 yr 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?
October 28, 20178 yr 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.
October 28, 20178 yr 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; }
October 28, 20178 yr 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.
October 29, 20178 yr 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 October 29, 20178 yr by jabelar Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 29, 20178 yr 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.
October 29, 20178 yr 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.