Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.