Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been working a Minecraft sever mod and i want to be able to add a new entity to the server, but then make the server send the packets to the client, imitating another mob, for example..

Lets say say i have EntityPlayerNPC.class, what i want to do is have all of the packets that get sent to the client look like they are from that of another player which is on the player, therefore allowing me to add custom NPC's... Thinking about the theory i'm sure this can be done.

I've tried looking around for where the packets are being sent from and whatnot, can anyone think up a solution?

edit:

i tried adding a new constructor to the Packet20NamedEntitySpawn class like so:

public Packet20NamedEntitySpawn(String username, EntityLiving e){
       this.entityId = 0;
       this.name = username;
       this.xPosition = MathHelper.floor_double(e.posX * 32.0D);
       this.yPosition = MathHelper.floor_double(e.posY * 32.0D);
       this.zPosition = MathHelper.floor_double(e.posZ * 32.0D);
       this.rotation = (byte)((int)(e.rotationYaw * 256.0F / 360.0F));
       this.pitch = (byte)((int)(e.rotationPitch * 256.0F / 360.0F));
       this.metadata = e.getDataWatcher();
}

unfortunatley, that didn't work :(

share|improve this question
1  
What's with all the down votes, this is a well structured question. What's the point in a forum for asking questions, where you get penalized for asking questions? –  Shaun Wild Nov 26 '12 at 16:28

1 Answer 1

Im not too familiar with minecraft coding, but Id say take a look at other mods that have done similar things, such as adding extra animals and that, or also look at the code for existing NPCs such as the Pigmen Villagers and such.

Is what your wanting to do is make an NPC clone of the player with all of their fields like username and such?

share|improve this answer
    
Basically, in Minecraft, if an entity does not have a matching id on the client side, then it will not render or display in any way. Now this causes a problem when i want to add a new mob on the server side, I've been brainstorming some solutions and one of them is a type of proxy, which intercepts the packets for my custom entity, and makes them into an entity of my choice. –  Shaun Wild Nov 25 '12 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.