Solved How to disable villager trade discounts?

Discussion in 'Spigot Plugin Development' started by MrShawn, Feb 24, 2020.

  1. Hey, I'm looking to disable the discounts that villagers give when you trade with them a few times. I've had a look through the MerchantRecipe class, but can't find anything there. It's not the PriceMultiplier because that doesn't change when a discount is applied. Any help?
  2. You'll probably have to use NBT and edit the villager's specialPrice and/or demand tags for each recipe, depending on which one (or both) get updated when the villager changes the price.
  3. Alright. I'll try and figure out how to do that lol. I have 0 experience with NMS / NBT.
  4. You shouldn't have to use NMS for this, I'm pretty sure you can use the new Persistence API with NamespacedKey.MINECRAFT to get built-in NBT tags.
  5. Figured it out through the most part with NBT tags. Only problem is that the client still sees the discount, but the server takes the proper amount. Not sure if that's possible to fix or not though.
  6. Hello, i'm trying to do the same thing as you : disable villager trade discounts.
    Here is my code :
    Code (Text):
        public void onRightClickOnPNJ(PlayerInteractEntityEvent event) {
            if ( event.getRightClicked().getType() == EntityType.VILLAGER ) {          
                Entity targetVillager = ((CraftEntity) event.getRightClicked()).getHandle(); //Handle of villager object
                NBTTagCompound tag = NBTTagCompound()); //NBT tag of target entity
                NBTTagList recipeData = (NBTTagList) tag.getCompound("Offers").get("Recipes");
        private void modifyNBT(NBTTagList tagList) {
            final String SPECIALPRICE = "specialPrice";
            for (int i = 0; i < tagList.size(); i++) {
                tagList.getCompound(i).setInt(SPECIALPRICE, 0);
    And here is the output :

    The issue that i have is that even if in the output it is said that the specialPrice is 0 , the discount is effective and for example, here : , it takes me 25 potatoes for the emerald and 2 emeralds for the cookies !