Jump to content

BananaBlighter

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by BananaBlighter

  1. 4 hours ago, LeoCTH said:

    and your model's texture seems broken too...

    idk

    Well I haven't tried adding a texture yet. I just assumed that's how it looks when you don't add one. I mean I originally thought that it's meant to be pink and black but yeah I didn't think much of it when the texture came out like this.

  2. So I'm trying to make a parkour mod and part of it involves replacing the player model. I made a thread asking how to do this about a year and a half ago: (http://www.minecraftforge.net/forum/topic/40238-how-can-i-change-the-player-model/#comment-215772http://www.minecraftforge.net/forum/topic/40238-how-can-i-change-the-player-model/#comment-215772) and then I left modding for a while because I basically gave up and because I was busy with other stuff. Anyway, I came back to my mod a few days ago and finally figured out how to do it (also turns out Ernio was right and it was just my version of forge at the time), but for some reason my model has come out abnormally large (see the 1st attached image).

     

    I figured there had to be some sort of scale factor to make it the same size as the regular player model, so I looked at the ModelPlayer class (and in the ModelBiped class) and in the constructor, a version of the addBox method that had a 7th argument for a scaleFactor was being used, whose value was being passed into the constructor as an argument called modelSize. So I looked at the RenderPlayer class and in the constructor they set 'new ModelPlayer(0.0F, useSmallArms)' as the mainModel. I thought it was a bit strange that they were using 0 as the so called 'scale factor', but I thought maybe the addBox method was just weird like that. So I tried using that version of the addBox method and using a scale factor similar to how it was done in the RenderPlayer class, and I of course set it to 0.

     

    Turns out that was a stupid idea because setting it to 0 does nothing (they stay the same size) and it wouldn't work doing it like this anyway, because scaling each individual box doesn't scale the entire model as a whole (see the 2nd attached image - scale factor of 2). Now I know I could just scale the model using GlStateManager but I specifically want to scale it to the EXACT same size as the regular player model (I tried random values and just under 0.6 works pretty well, though the change in size is still noticeable when the model switches, which I don't want). I can't find where the scaling of the regular player model is taking place or if there even is a scale factor at play. It could just be I've done something terribly stupid that somehow ended up with my model being about 5/3 as large as it should be (which is more likely). If someone recognizes this issue and has any idea what is going on here, or knows what scale factor I can use to get it to the same size, then that would be greatly appreciated. I mean I probably could just find a value that's close enough through trial and error, but I'd rather know if there's something I've done wrong and how to properly fix it.

     

    My rendering code:

    public class ModelAssassin extends ModelBase
    {
    	public ModelRenderer body;
    	public ModelRenderer head;
    	public ModelRenderer rightShoulder;
    	public ModelRenderer leftShoulder;
    	public ModelRenderer rightForearm;
    	public ModelRenderer leftForearm;
    	public ModelRenderer rightThigh;
    	public ModelRenderer leftThigh;
    	public ModelRenderer rightFoot;
    	public ModelRenderer leftFoot;
    	public ModelRenderer nose;
    	
    	public int textureWidth = 0;
    	public int textureHeight = 0;
    	
    	public ModelAssassin(float modelSize)
    	{	
    		body = new ModelRenderer(this, 0, 0);
    		body.addBox(-4, -6, -2, 8, 12, 4, modelSize);
    		body.setRotationPoint(0, 18, 0);
    		body.setTextureSize(textureWidth, textureHeight);
    		setRotation(body, 0, 0, 0);
    		
    		head = new ModelRenderer(this, 0, 0);
    		head.addBox(-4, 0, -4, 8, 8, 8, modelSize);
    		head.setRotationPoint(0, 6, 0);
    		head.setTextureSize(textureWidth, textureHeight);
    		body.addChild(head);
    		setRotation(head, 0, 0, 0);
    		
    		rightShoulder = new ModelRenderer(this, 0, 0);
    		rightShoulder.addBox(-4, -4, -2, 4, 6, 4, modelSize);
    		rightShoulder.setRotationPoint(-4, 4, 0);
    		rightShoulder.setTextureSize(textureWidth, textureHeight);
    		body.addChild(rightShoulder);
    		setRotation(rightShoulder, 0, 0, 0);
    		
    		leftShoulder = new ModelRenderer(this, 0, 0);
    		leftShoulder.addBox(0, -4, -2, 4, 6, 4, modelSize);
    		leftShoulder.setRotationPoint(4, 4, 0);
    		leftShoulder.setTextureSize(textureWidth, textureHeight);
    		body.addChild(leftShoulder);
    		setRotation(leftShoulder, 0, 0, 0);
    		
    		rightForearm = new ModelRenderer(this, 0, 0);
    		rightForearm.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		rightForearm.setRotationPoint(-2, -4, 0);
    		rightForearm.setTextureSize(textureWidth, textureHeight);
    		rightShoulder.addChild(rightForearm);
    		setRotation(rightForearm, 0, 0, 0);
    		
    		leftForearm = new ModelRenderer(this, 0, 0);
    		leftForearm.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		leftForearm.setRotationPoint(2, -4, 0);
    		leftForearm.setTextureSize(textureWidth, textureHeight);
    		leftShoulder.addChild(leftForearm);
    		setRotation(leftForearm, 0, 0, 0);
    		
    		rightThigh = new ModelRenderer(this, 0, 0);
    		rightThigh.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		rightThigh.setRotationPoint(-2, -6, 0);
    		rightThigh.setTextureSize(textureWidth, textureHeight);
    		body.addChild(rightThigh);
    		setRotation(rightThigh, 0, 0, 0);
    		
    		leftThigh = new ModelRenderer(this, 0, 0);
    		leftThigh.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		leftThigh.setRotationPoint(2, -6, 0);
    		leftThigh.setTextureSize(textureWidth, textureHeight);
    		body.addChild(leftThigh);
    		setRotation(leftThigh, 0, 0, 0);
    		
    		rightFoot = new ModelRenderer(this, 0, 0);
    		rightFoot.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		rightFoot.setRotationPoint(0, -6, 0);
    		rightFoot.setTextureSize(textureWidth, textureHeight);
    		rightThigh.addChild(rightFoot);
    		setRotation(rightFoot, 0, 0, 0);
    		
    		leftFoot = new ModelRenderer(this, 0, 0);
    		leftFoot.addBox(-2, -6, -2, 4, 6, 4, modelSize);
    		leftFoot.setRotationPoint(0, -6, 0);
    		leftFoot.setTextureSize(textureWidth, textureHeight);
    		leftThigh.addChild(leftFoot);
    		setRotation(leftFoot, 0, 0, 0);
    		
    		nose = new ModelRenderer(this, 0, 0);
    		nose.addBox(-1, -1, 0, 2, 2, 2, modelSize);
    		nose.setRotationPoint(0,  4,  4);
    		nose.setTextureSize(textureWidth, textureHeight);
    		head.addChild(nose);
    		setRotation(nose, 0, 0, 0);
    	}
    	
    	@Override
    	public void render(Entity entity, float time, float swingSuppress, float par4, float headAngleY, float headAngleX, float par7)
    	{
    		this.setRotationAngles(time, swingSuppress, par4, headAngleY, headAngleX, par7, entity);
    		
    		GlStateManager.pushMatrix();
    		GlStateManager.scale(1, 1, 1);
    		
    		body.render(par7);
    		
    		GlStateManager.popMatrix();
    	}
    	
    	@Override
    	public void setRotationAngles(float time, float swingSuppress, float par3, float headAngleY, float headAngleX, float par6, Entity entity)
    	{
    		if(entity.posX != entity.prevPosX || entity.posZ != entity.prevPosZ)
    		{
    			this.setRotation(body, 0, -headAngleY, 0);
    		}
    		
    		this.setRotation(head, headAngleX, -headAngleY - radToDeg(body.rotateAngleY), 0);
    	}
    	
    	protected float degToRad(float degrees)
    	{
    		return degrees * (float) Math.PI / 180;
    	}
    	
    	protected float radToDeg(float radians)
    	{
    		return radians * 180 / (float) Math.PI;
    	}
    
    	protected void setRotation(ModelRenderer model, float rotX, float rotY, float rotZ)
    	{
    		model.rotateAngleX = degToRad(rotX);
    		model.rotateAngleY = degToRad(rotY);
    		model.rotateAngleZ = degToRad(rotZ);
    	}
    }

     

    public class RenderAssassin extends RenderLivingBase<AbstractClientPlayer>
    {		
    	public RenderAssassin()
    	{
    		super(Minecraft.getMinecraft().getRenderManager(), new ModelAssassin(0), (float) 0.5);
    	}
    	
    	@Override
    	protected ResourceLocation getEntityTexture(AbstractClientPlayer entity)
    	{
    		return null;
    	}
    	
    	@Override
    	public void doRender(AbstractClientPlayer entity, double x, double y, double z, float entityYaw, float partialTicks)
        {
            this.getMainModel().render(entity, 0, 0, entity.getAge(), entity.rotationYaw, entity.rotationPitch, (float) 0.1);
        }
    }

     

    public class RenderEventHandler
    {
    	public RenderAssassin renderAssassin = new RenderAssassin();
    	
    	@SubscribeEvent
    	public void onPlayerRender(RenderPlayerEvent.Pre event)
    	{
    		if(event.getRenderer() instanceof RenderPlayer)
    		{	
    			AbstractClientPlayer player = (AbstractClientPlayer) event.getEntity();
    			
    			if(player.getCapability(CapabilityProvider.PROFILE_STATE, null).isHighProfile())
    			{
    				event.setCanceled(true);
    				
    				renderAssassin.doRender(player, event.getX(), event.getY(), event.getZ(), 0, 0);
    				//System.out.println(player.rotationYaw + " , " + player.rotationPitch);
    			}
    		}
    	}
    }

     

    2018-01-03_21.10.15.png

    2018-01-03_21.49.20.png

  3. Oh sorry, version 1.8, forge 11.14.1.1334. Though tbh I should update now.

     

    Here's where I register the event handler:

     

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	ParkourEventHandler eventHandler = new ParkourEventHandler();
    	MinecraftForge.EVENT_BUS.register(eventHandler);
    	FMLCommonHandler.instance().bus().register(eventHandler);
    }

     

    It's in the main mod class, which is how the tutorial I followed said it should be done. There are two other events in that class, they both work, but the RenderPlayerEvent doesn't.

  4. Well I do really want the model to change on demand, are you sure this is not feasible?

     

    If the approach I mentioned doesn't work, how do I do it then? If I get the RenderPlayerEvent, I cancel it but then what do do exactly? How does the doRender() method work?

     

    Also, for some reason the event isn't working for me. I just wrote:

    @SubscribeEvent
    public void onPlayerRender(RenderPlayerEvent.Pre event)
    {
    	System.out.println("Player rendered");
    }

     

    I'm sure I've also registered the class to the correct bus. I can't see the message appear however. When I tried canceling the event th eplayer did not turn invisible (as I assume would happen).

     

    As I said, I'm pretty much clueless on what I am trying to do. I have never made any real mods before.

  5. As I said, I'm new to modding, with this being my first 'real' mod in the sense that I didn't just copy a tutorial on how to add new items or something. I don't know much about packet handling or rendering for that matter. If you could give me some good tutorials that'd be great.

     

    So far, to make the model I had copied this tutorial: http://jabelarminecraft.blogspot.co.uk/p/introduction-first-of-all-to-understand.html, but I couldn't really gather from it how I'd actually render the model instead of the existing player one.

     

    2.1. To store player variables like whether they were in high or low profile, I used IExtendedEntityProperties. Not sure if it was a good idea but for what I've done so far it works fine.

     

    1.1. Oh no I was talking about a different mod, the Mo' Bends mod, look it up. I don't think Smart Moving actually changes the model, only the animations iirc.

     

    1.3. I see keyboard events but they are not cancelable. I tried checking each tick for whether the player had space pressed and was high profile and then setting the key bind state to false, and to my surprise it actually kinda works. Only problem is that every so often (1/20 times I enter high profile) the player will still jump when space is initially pressed but not continue when held.

     

    3. I'm just not sure exactly how I would 'swap renders'.

     

    4. The tutorial I linked above has the angles for each body part stored in an array, with columns being each part and rows being each frame. I was wondering if there was an easier way to do this.

  6. 2) Per player. All I've done for my mod so far is make it so that as long as you hold down the middle click button with an empty hand you enter 'high profile mode' and the camera switches to 3rd person view. In high profile mode, when you walk forward the player sprints instead, entering 'free run mode'. I've also coded the new model and added a few little functionalities like making the scroll wheel ineffective while middle click is held down. What I want to do is replace the player model when in high profile.

     

    1) No, it's not just visual like the Mo' Bends mod. It's a parkour mod taking inspiration from Assassin's Creed, so when you are in 'free run mode' you can do all sorts of things like climbing up walls. In fact all the controls sort of change in 'high profile mode'. When free running you're not meant to be able to jump, and pressing space will cause you to dive roll instead, while holding it as you run towards a wall will initiate a climb. With the middle click it was easy to change what it does (you can still pick block but that happens if you let go in under 20 ticks) because there is the cancelable MouseEvent. However I do not know of any keyboard equivalent.

     

    3) No I don't think I am convinced. Does this mean that I'll have to make a new animation for even simple things like eating? If I can get the model to only change when the player is high profile, then I guess I wouldn't have to do animations like walking, and technically I could prevent the player from doing things like eating and sneaking.

     

    Also, for animation, do I have to set the angles frame by frame for every tick or can I smoothly move a part from one point to another using maths?

  7. Hmmm...I'm still not convinced this is the best way to do it.

     

    Sorry I'm rather new to modding, but if I did stop the normal player model rendering, how would I replace it with my own model? Would making a whole new model mean I have to redo every animation? What about the skins and armour?

     

    I also forgot to mention that preferably the model would only change when a certain boolean variable is true (that would make it more compatible too, wouldn't it?). How would I do this then?

     

    If I only I could look at the Mo' Bends mod or something to see how it was done over there...

  8. So I'm making a parkour mod, with animations and all, similar to how it looks in mods like Animated Player or Mo' Bends. How would I change the player model to look like that, so that it has elbows and knees?

     

    The only way I can think of doing such a thing would be to make the player invisible and replace it with another entity when in 3rd person view. There has to be a better way than this for sure.

×
×
  • Create New...

Important Information

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