Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How can I change the player model
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
BananaBlighter

How can I change the player model

By BananaBlighter, July 10, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 10, 2016

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.

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 10, 2016

@SubscribeEvent to RenderPlayerEvent. Cancel rendering. Render your own (as in make new model and Render it).

 

Rendering is literally impossible to be compatible with anything so unless you provide API for others to use, you mod's rendering can't really be compatible with anything.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 11, 2016

OK thanks I'll try that.

 

EDIT: I tried canceling the event, but it didn't do anything. How do I cancel the rendering then?

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1623

Choonster

Choonster    1623

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1623
  • 5050 posts
Posted July 11, 2016

Don't subscribe to

RenderPlayerEvent

itself, subscribe to

RenderPlayerEvent.Pre

. This is the actual event you want and the only sub-event of

RenderPlayerEvent

that can be cancelled.

 

Attempting to cancel a non-cancellable event will throw an

IllegalArgumentException

.

 

I suspect you didn't register your event handler, so your method was never being called.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 11, 2016

I had it registered to the MinecraftForge.EVENT_BUS, is that the right one?

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1623

Choonster

Choonster    1623

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1623
  • 5050 posts
Posted July 11, 2016

Yes, that's the correct bus.

 

If it seems like it's not working, put a breakpoint in your event handler method and ensure it's actually being called.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 11, 2016

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...

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 11, 2016

1. Will this be client-only (visual) mod?

 

2. Will your boolean be per-player or global?

 

3.

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

I am convincing you. Feel convinced yet? :P

 

While for normal entities you can easily replace their Render class, for players it doesn't seem to be working in the same way (at least it didn't last time I replaced renderer in registry).

Anyway - no matter what - if you are going to apply changes as big as joints and some special animations - you will need to store additional per-player data (e.g to hold bend level of joints).

As to your questions about armours and such - those are called layers and again - if you plan on tounching stuff that pretty much builds whole base of player's model (because joints and all) - you can forget about using ANY part (aside from general ideas) of vanilla code.

 

You have to make your own models and render them on your own. Then recreate layers (for armours and such) that will also bend with said joints. So basically rewrite of whole vanilla animations.

 

 

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 12, 2016

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?

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 12, 2016

In order:

2.1. To store per-player data you need @Capability

http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

Example:

https://github.com/MinecraftForge/MinecraftForge/blob/1.9/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java

And recent posts on this forum (you could lookup my post history).

 

2.2. Input events are fired on client. What you need to do is send "state" packet to server when input happens and from server's handler change server side state.

 

1.1. I will just write "Smart Moving" (mod).

 

1.2. Again - input happens on client, server received packets and server does shit (also updates other clients with your actions - again, with packets).

 

1.3. For keyboard events look again. Also depending on what exacly you want you might want to use ClientTickEvent and check directly LWJGL Keyboard class (in this case, probably client tick is the way, but check out KeyBinding class/event) Examples can be found even in GuiScreen#handleInput() as well as other more fundamental classes.

 

3. If your animation/model changes only when you go into high profile mode then you can dynamically swap renders to be vanilla or yours when you need it. But if it will be possible to eat during your "special run" - then yeah, you have to animate on your own most likely.

 

4. ("Also, for animation..."). Well, not you dive into client/server data and interpolation.

First of all - there is tick and renderTick (FPS) - usually called "partialTick" which is float representing at what position between this tick and next tick current render Frame is placed. While data will always happen on logical tick, partialTicks allow you to make interpolations between previous and next data change, giving you smooth transition. Also note - if you want all clients to see same animation you will need that data to by synced (logical data, not interpolation data because that is per-client and different on every client - FPS).

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 12, 2016

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.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 13, 2016

Here (http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2216984-solved-dorender-custom-player-model) it says you can do:

RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new CustomRender());

So can I simply call this at any point, say in a tick event if the player is high profile?

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 13, 2016

Here (http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2216984-solved-dorender-custom-player-model) it says you can do:

RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new CustomRender());

So can I simply call this at any point, say in a tick event if the player is high profile?

 

This is exactly what I mentioned earlier about EntityPlayers working differently than other Entities.

As of 1.9 (I think) RenderRegistry#registerEntityRenderingHandler is deprecated in favor of factory system = RenderRegistry#registerEntityRenderingHandler (different params).

 

In pre 1.9 renders were held directly in map and could actually be replaced outside mod's init phases.

As of now - render classes are produced by factory classes which can only be registered in preInit and then those factory classes will produce render class internally (on init).

 

Said that - replacing Player's render class was still not working due to the fact that apparently player was rendered differently - what I am saying here that no matter if you are on old or new version - what you mentioned will (should) not work, unless there was change I don't know about.

 

Now let's just say that whole approach you mentioned is SIMPLY RETARDED!

RnderPlayerEvent is hooked DIRECTLY at the beggining (Pre) and end (Post) of Render#doRender() method. Replacing class in registry is literally equivalent to cancelling said event and rendering on your own.

 

EDIT:

While Render event gives you a bit of compatibility (since you can decide when you render or not), replacing render class in registry effectively kicks out all other rendering mods. Aside from that - you MOST CERTAINLY don't want to replace render on demand (one time this and one time other) because render object is generated for all entities of type and you would have to handle replacement for all currently spawned players.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 13, 2016

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.

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 13, 2016

After all this time I still don't know what version are you on. Version and Forge please.

Also show your registration class.

  • Quote

Share this post


Link to post
Share on other sites

BananaBlighter    0

BananaBlighter

BananaBlighter    0

  • Tree Puncher
  • BananaBlighter
  • Members
  • 0
  • 11 posts
Posted July 14, 2016

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.

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted July 14, 2016

There was short time after Forge was being upgraded to 1.8 where RenderPlayerEvent was NOT fired (because it was WIP).

 

I am not sure if your version is in scope of said time, but:

1. You can find out in changelog - look for log saying that RenderPlayerEvent was reactivated.

2. You should update to 1.9+.

 

Aside from that - why the hell are you registering same event class for 2 buses? Separate your FML and Forge events in 2 classes - otherwise it's waste of resources (okay, well - micro optimization).

 

Next on plate: As of 1.9 (I think, maybe earlier) FML and Forge buses were merged into one - so basically no matter what you call - its same event bus - thus call it only once. Said that - update to 1.9+ and use one bus for all events (not mentioning decorator ones).

  • Like 1
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • BattleDash
      Get all players connected to a bungee server

      By BattleDash · Posted 41 minutes ago

      Hello all, I'm trying to make a mod that can tell you all the players on a bungee server you're connected to, I've never worked with Forge before and this API is very abstract to me compared to plugin development which is what I normally do. Does anyone know how I would go about getting a list of Player Entities of every player on the network you're connected to?
    • Draco18s
      Trouble getting contents of a Chest

      By Draco18s · Posted 1 hour ago

      It isn't merged, so it won't work yet.
    • saxon564
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564 · Posted 2 hours ago

      Does anyone else have any thoughts as to what might be causing this issue?
    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 2 hours ago

      You cannot call Minecraft methods from a separate thread. You need to wait a tick using ClientTickEvent.
    • bismuth210
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210 · Posted 2 hours ago

      I'm creating a custom gamemode using forge in which players get teleported around regularly. I've run into a problem when I do the following:   I spawn a firework rocket near a player I teleport the player to a different location I wait a couple of seconds (or minutes) I teleport the player back to the same location as in step 1. Doing this will show the firework spawned in step 1 in step 4, despite significant time having passed in 3. This video shows what I mean:   I suspect the reason for why this happens is because once I teleport the player somewhere else, the chunk with the firework is no longer loaded and doesn't get updated.   Is there a simple way for me to simply "get rid" of all active fireworks shortly before teleporting players so that this doesn't occur? Or do I really have to forcibly keep all chunks loaded? To be more clear: I don't want to disable fireworks all together, but I don't want remnants of old fireworks showing up when I teleport players. "Killing" all firework rockets when I teleport a player would work fine, but I don't know if/how I can do that.   I've tried using /kill @e[type=!player] But that doesn't work for firework rockets apparently.
  • Topics

    • BattleDash
      0
      Get all players connected to a bungee server

      By BattleDash
      Started 41 minutes ago

    • MattNL
      5
      Trouble getting contents of a Chest

      By MattNL
      Started 12 hours ago

    • saxon564
      12
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564
      Started Friday at 05:11 AM

    • Filip4223
      5
      [1.12.2] How can I close GUI in Forge?

      By Filip4223
      Started 3 hours ago

    • bismuth210
      0
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210
      Started 2 hours ago

  • Who's Online (See full list)

    • DaemonUmbra
    • predator9800
    • EfrenB
    • imacatlolol
    • tday93
    • Cerandior
    • DanielMens
    • MattNL
    • Guy123
    • alox
    • DragonITA
    • Alkia
    • Simon_kungen
    • salvestrom
    • Kharmod
    • diesieben07
    • bluemetalsword
    • Redstoneguy129
    • MrMarioMaster34
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How can I change the player model
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community