Jump to content

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


Recommended Posts

Posted

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

Posted

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.
Consider supporting the team on Patreon

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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