-
|
Greetings, So there is DataComponentUtil.createStack(ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get(), ModRegistry.DataComponents.RIGHT_TURTLE_UPGRADE.get(), UpgradeData.ofDefault(CCRegistration.PLAYER_DETECTOR_POCKET));But I really struggle with the whole holder and reference stuff from mojang, so I am not sure how I can create a And I have a second problem I hope someone smarter than me can help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
You need to get the upgrade registry in the available public MerchantOffer getOffer(Entity trader, RandomSource random) {
var registryaccess = trader.level().registryAccess();
var upgrade = registryaccess.registryOrThrow(IPocketUpgrade.REGISTRY)
.getHolder(ResourceLocation.fromNamespaceAndPath("mymod", "my_upgade_id"))
.orElseThrow();
var stack = DataComponentUtil.createStack(ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get(), ModRegistry.DataComponents.RIGHT_TURTLE_UPGRADE.get(), UpgradeData.ofDefault(upgrade));
return new MerchantOffer(...)
}I guess it's worth remembering that upgrades are not guaranteed to be present (someone can remove them via datapacks!). It's a real shame that villager trades aren't data-driven :/. I kinda wonder if you could mimic that by using data maps to map turtle/pocket upgrades to emerald costs, but maybe not as part of the initial update. 😉 |
Beta Was this translation helpful? Give feedback.
You need to get the upgrade registry in the available
HolderLookup.Provider, and then fetch the upgrade from that. For village trades, you can probably use the enchantment or potion trades as an example: