Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.9] Custom villagers get rendered as farmers because of hardcoded vanilla valu


Lothrazar
 Share

Recommended Posts

I am trying to create a custom villager.  I am using the registry system, so I create the proffession first

         String sage = Const.MODRES+"textures/entity/villager/elder.png";

elderProfession = new VillagerProfession(Const.MODRES+"elder", sage){
	@Override
	    public ResourceLocation getSkin() {
			return sageTexture;
		}
	};

 

Then I add the career which has the trades

new VillagerCareer(elderProfession, "sage_career"){
@Override
       public ITradeList[][] getTrades(){
           return sageTrades;
       }
};

 

Now the trades work just fine, the villager spawns when i do

 

/summon Villager ~ ~ ~ {Profession:5,Career:0}

 

it also spawns naturally with eggs or breeding.  But the skin does not register.  I looked into EntityVillager.java and see this

 

    public int getProfession()
    {
        return Math.max(((Integer)this.dataWatcher.get(PROFESSION)).intValue() % 5, 0);
    }

 

So in other words the %5 sets the maximum limit of 4,  its treating ALL villagers registered using forge as profession zero which is farmer. 

 

Is there any forge way to do this without relying on reflection or something to override this vanilla method?  I know that [a different modder] on twitter fixed this with a core mod, but i want to do this the 'right' way.

 

Full Code:

 

https://github.com/PrinceOfAmber/CyclicMagic/blob/master/src/main/java/com/lothrazar/cyclicmagic/registry/VillageTradeRegistry.java

Link to comment
Share on other sites

The %4 is in there to prevent vanilla from crashing.

We need to move the texture getter from using getProfession to getProfessionForge

 

As for the person who 'fixed' it with a coremod, they an die in a fucking fire.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

 Share

×
×
  • Create New...

Important Information

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