feat: expose updateDemand and restock on Villager (#12608)

This commit is contained in:
Mart 2025-06-07 06:42:11 -04:00 committed by GitHub
parent 03efecf0d3
commit 3527ccdf2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View File

@ -419,6 +419,7 @@ public net.minecraft.world.entity.npc.Villager increaseMerchantCareer()V
public net.minecraft.world.entity.npc.Villager numberOfRestocksToday public net.minecraft.world.entity.npc.Villager numberOfRestocksToday
public net.minecraft.world.entity.npc.Villager releaseAllPois()V public net.minecraft.world.entity.npc.Villager releaseAllPois()V
public net.minecraft.world.entity.npc.Villager setUnhappy()V public net.minecraft.world.entity.npc.Villager setUnhappy()V
public net.minecraft.world.entity.npc.Villager updateDemand()V
public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos;
public net.minecraft.world.entity.player.Abilities flyingSpeed public net.minecraft.world.entity.player.Abilities flyingSpeed
public net.minecraft.world.entity.player.Abilities walkingSpeed public net.minecraft.world.entity.player.Abilities walkingSpeed

View File

@ -391,4 +391,21 @@ public interface Villager extends AbstractVillager {
* reputation regardless of its impact and the player associated. * reputation regardless of its impact and the player associated.
*/ */
public void clearReputations(); public void clearReputations();
/**
* Updates the demand for Villager offers.
* Demand can rise and fall based on how often offers are traded.
* They can fall when an item is not traded for a while, or rise when the item is resupplied next.
* Demand is used to calculate the price of items in the Villager's offers.
* <br>
* <b>Note: Demand is stored per item and not per Villager.</b>
*/
public void updateDemand();
/**
* Resets uses of all offers for the Villager. This also internally calls {@link #updateDemand()}.
* Calling this will trigger a {@link org.bukkit.event.entity.VillagerReplenishTradeEvent} for each offer that is restocked.
* Demand is still updated even if all events are canceled.
*/
public void restock();
} }

View File

@ -380,4 +380,14 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
public void clearReputations() { public void clearReputations() {
getHandle().getGossips().gossips.clear(); getHandle().getGossips().gossips.clear();
} }
@Override
public void updateDemand() {
getHandle().updateDemand();
}
@Override
public void restock() {
getHandle().restock();
}
} }