Jump to content

prujohn

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by prujohn

  1. Solution: I can use the DynamicTexture class and the method .getDynamicTextureLocation() to handle this at runtime (from my RenderLiving class): @Override protected ResourceLocation getEntityTexture(Entity par1Entity){ MyEntity entity= (MyEntity)par1Entity; if (entity.imageTexture != null){ entity.texture = this.renderManager.renderEngine.getDynamicTextureLocation("skin_"+entity.getCustomNameTag(), new DynamicTexture(entity.imageTexture)); entity.imageTexture = null; } return entity.texture; }
  2. My apologies. I should have been more clear about my use case. I'm trying to apply these skins to "dumb" NPC models with limited AI. I basically just want them to walk around while I stream on Twitch (follower perk). I've got all of it done - I can spawn a model with the Steve skin and it wanders around. However I want to be able to switch it's skin to any arbitrary Minecraft IGN when I use a nametag on it. I went down the RenderPlayer path for a while. Unfortunately, it's tightly coupled with the AbstractClientPlayer class, which extends EntityPlayer. I tried using these as base classes for my own entity, but these classes appear to have hooks into the game loop for "player communication" and the constructor also requires a "GameProfile" object. Also minecraft crashes when I try to use them, because it's trying to send messages to the Entity, expecting it to be an actual player (I think). Currently my Entity extends from EntityCreature and my Render class for it extends from RenderLiving. It was pretty trivial for me to apply the Steve skin to the ModelBiped model, so I'm just trying to figure out how to do the same with a downloaded skin at runtime? I can download the skin, but pointing to it with a ResourceLocation object is where I'm currently stuck.
  3. I've made some progress on my own. After I apply a nametag to my NPC entity, I can download a player texture and store it locally. At the moment I'm writing them into a cache directory inside "config/{mymod}/skincache/ What I'm trying to figure out now is where to put these files so that I can address them properly with the "ResourceLocation" object? Once I can point to the file like so: ResourceLocation joy = new ResourceLocation('path/to/downloaded/skin.png'); ...then I should be able to return it here in my render class like so: @Override protected ResourceLocation getEntityTexture(Entity par1Entity){ return ((MyEntity)par1Entity).texture; // assumes I've successfully assigned the new ResourceLocation object to .texture } My problem is that ResourceLocation is (AFAIK) like a virtual directory at runtime, pointing to read-only resource areas? This is where I'm getting lost at the moment. Any guidance appreciated. Thanks! John
  4. Thanks to some excellent help from this community, I've been able to write a mod that spawns little Steve's whenever I like and also allows me to rename them with name tags. I was able to override the "setCustomNameTag()" method of my NPC entity, which is properly called whenever I use a nametag on it. Wanted to check and see if anyone had experience with this? I saw some code in minecraft's AbstractClientPlayer class that performs a download of a player skin, but it seems narrowly focused on skinning the player during construction. Still, some of the plumbing is there. I was just wonder if someone has found an easier entry point to accomplish downloading/skinning at runtime? The fallback would be the Steve texture of course. Thanks, John
  5. droke0920 did you have any luck with this? I'm curious about how to apply arbitrary skins from the minecraft skin server to a npc player model.
  6. Did the trick. Thank you much! Odd that the pitch and yaw aren't set to 0 by default - oh well. Follow up, if I can trouble you a bit more: My end goal is to be able to spawn a player model (as an NPC) and assign arbitrary AI to it. EntityPlayerMP seems too heavy for this purpose, because it contains a lot of logic for an actual "player", and I just want the NPC version of it. Is this something I need to put together manually (model/texture -> class extended from EntityLivingBase)? If so, no worries, I'll figure it out. I was looking at extending from EntityVillager perhaps? But I want to use the player model, so maybe a custom binding - not sure still exploring. Thanks again, John
  7. I can spawn a cow, but it seems only on the client side. The cow disappears after a moment, which is my clue that it is only happening on client side. I figured the best approach was to send a message to the server, and then spawn the cow within that context. I was able to send the message successfully, and verified that the "side" is "SERVER", but when I attempt to spawn the cow, it again appears to spawn on the client instead. Apologies in advance. Long time programmer, but this minecraft modding has me back to the "hello world" stage apparently. Here's the code (in my message handler class) that receives the message from client side: @Override public IMessage onMessage(MoshMessage message, MessageContext ctx) { // this works as expected, indicating (I think) that I have received a message from client-side. System.out.println("I got a message [" + message.msg + "] from " + ctx.getServerHandler().playerEntity.getDisplayName()); // this says "SERVER" as expected System.out.println("side: " + ctx.side.toString()); // this works as expected, time is set to 0 ctx.getServerHandler().playerEntity.worldObj.setWorldTime(0); // This DOESN'T work as expected. The cow is spawned client-side and disappears soon after. // I want it to spawn on server-side. Entity e = new EntityCow(ctx.getServerHandler().playerEntity.worldObj); e.posX = ctx.getServerHandler().playerEntity.posX; e.posY = ctx.getServerHandler().playerEntity.posY; e.posZ = ctx.getServerHandler().playerEntity.posZ; ctx.getServerHandler().playerEntity.worldObj.spawnEntityInWorld(e); return null; } I'm probably overlooking a simple concept here so I would appreciate any guidance. Thanks, John
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.