Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch VillagerTrades.EmeraldsForVillagerTypeItem to allow modders to make Custom VillagerTypes #1875

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from

Conversation

JT122406
Copy link
Contributor

@JT122406 JT122406 commented Jan 19, 2025

Currently if you make a custom Villager type the game will crash when you Load into or Create a world, since mc throws an exception when a VillagerType has no Trades, This makes sense in Vanilla's case but makes it impossible for modders to make there own villager types without extreme difficulty.

  • The first change in the patch simply removes the check completely, preventing the crash. (The other option would be to leave the check but make the list empty so it never throws the exception, I decided against this as then the check here would just be pointless code to run but I am willing to do it this way if need be)

  • The second change in the patch makes sure that the item cost itemstack isn't empty since there will be no trades of this type for Modded VillagerTypes, if it is empty we return null, if we don't include this check we would get air trades

Fabric has a very similar mixin to allow this:
https://github.com/FabricMC/fabric/blob/1.21.4/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/TradeOffersTypeAwareBuyForOneEmeraldFactoryMixin.java

@neoforged-automation neoforged-automation bot added the 1.21.4 Targeted at Minecraft 1.21.4 label Jan 19, 2025
@neoforged-pr-publishing
Copy link

  • Publish PR to GitHub Packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.4 Targeted at Minecraft 1.21.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant