Simple Plugin about Villagers

Discussion in 'Archived: Plugin Requests' started by Anubis3467, Aug 21, 2014.

  1. Offline

    Anubis3467

    Plugin category: Mechanincs

    Suggested name: FriendlyVillagers

    What I want:

    Enabling Villagers to trade for more than 1 player at the same time

    Ideas for commands: No commands needed for this plugin.

    Ideas for permissions: No permissions needed.

    When I'd like it by: As soon as possible :).
     
  2. Offline

    WeeSkilz

    Do you mean wild villagers or ones you spawn in to make set trades?
     
    Apple_ likes this.
  3. Offline

    Anubis3467

    Any villager who is on any world of the Server
     
  4. Offline

    Anubis3467

    D:! Please I need this
     
  5. Offline

    SlenderDerpHead

    I don't know allot about java but there is a slight possibility that it's not possible because minecraft has its own laws and physics and changing the amount of people trading with villagers at once might possibly break minecraft.
     
  6. Offline

    CMG

    Not necessarily, plugins can always make their own custom trade inventories for multiple players, the plugin could check when a player clicks the villager (PlayerInteractEntityEvent) - cancel the open of the regular trade inventory, and then open the custom trade inventory for the player with the usual trade items.
     
  7. Offline

    ChipDev

    SlenderDerpHead
    So practically not opening the reg. villager inventory, Opening a fake one.
     
  8. Offline

    CMG

    Yeah, its virtual, but you can obviously go look at the original minecraft code for villager trading and and just use the default items as used in vanilla minecraft. See i have just gone and looked at the regular minecraft code in forge for adding the items to the villager and you can easily see what items are added and what for in this method below pulled out of the EntityVillager class.

    Code:java
    1. /**
    2.   * based on the villagers profession add items, equipment, and recipies adds par1 random items to the list of things
    3.   * that the villager wants to buy. (at most 1 of each wanted type is added)
    4.   */
    5. private void addDefaultEquipmentAndRecipies(int par1)
    6. {
    7. if (this.buyingList != null)
    8. {
    9. this.field_82191_bN = MathHelper.sqrt_float((float)this.buyingList.size()) * 0.2F;
    10. }
    11. else
    12. {
    13. this.field_82191_bN = 0.0F;
    14. }
    15.  
    16. MerchantRecipeList var2;
    17. var2 = new MerchantRecipeList();
    18. int var6;
    19. label50:
    20.  
    21. switch (this.getProfession())
    22. {
    23. case 0:
    24. func_146091_a(var2, Items.wheat, this.rand, this.adjustProbability(0.9F));
    25. func_146091_a(var2, Item.getItemFromBlock(Blocks.wool), this.rand, this.adjustProbability(0.5F));
    26. func_146091_a(var2, Items.chicken, this.rand, this.adjustProbability(0.5F));
    27. func_146091_a(var2, Items.cooked_fished, this.rand, this.adjustProbability(0.4F));
    28. func_146089_b(var2, Items.bread, this.rand, this.adjustProbability(0.9F));
    29. func_146089_b(var2, Items.melon, this.rand, this.adjustProbability(0.3F));
    30. func_146089_b(var2, Items.apple, this.rand, this.adjustProbability(0.3F));
    31. func_146089_b(var2, Items.cookie, this.rand, this.adjustProbability(0.3F));
    32. func_146089_b(var2, Items.shears, this.rand, this.adjustProbability(0.3F));
    33. func_146089_b(var2, Items.flint_and_steel, this.rand, this.adjustProbability(0.3F));
    34. func_146089_b(var2, Items.cooked_chicken, this.rand, this.adjustProbability(0.3F));
    35. func_146089_b(var2, Items.arrow, this.rand, this.adjustProbability(0.5F));
    36.  
    37. if (this.rand.nextFloat() < this.adjustProbability(0.5F))
    38. {
    39. var2.add(new MerchantRecipe(new ItemStack(Blocks.gravel, 10), new ItemStack(Items.emerald), new ItemStack(Items.flint, 4 + this.rand.nextInt(2), 0)));
    40. }
    41.  
    42. break;
    43.  
    44. case 1:
    45. func_146091_a(var2, Items.paper, this.rand, this.adjustProbability(0.8F));
    46. func_146091_a(var2, Items.book, this.rand, this.adjustProbability(0.8F));
    47. func_146091_a(var2, Items.written_book, this.rand, this.adjustProbability(0.3F));
    48. func_146089_b(var2, Item.getItemFromBlock(Blocks.bookshelf), this.rand, this.adjustProbability(0.8F));
    49. func_146089_b(var2, Item.getItemFromBlock(Blocks.glass), this.rand, this.adjustProbability(0.2F));
    50. func_146089_b(var2, Items.compass, this.rand, this.adjustProbability(0.2F));
    51. func_146089_b(var2, Items.clock, this.rand, this.adjustProbability(0.2F));
    52.  
    53. if (this.rand.nextFloat() < this.adjustProbability(0.07F))
    54. {
    55. Enchantment var8 = Enchantment.enchantmentsBookList[this.rand.nextInt(Enchantment.enchantmentsBookList.length)];
    56. int var10 = MathHelper.getRandomIntegerInRange(this.rand, var8.getMinLevel(), var8.getMaxLevel());
    57. ItemStack var11 = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(var8, var10));
    58. var6 = 2 + this.rand.nextInt(5 + var10 * 10) + 3 * var10;
    59. var2.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, var6), var11));
    60. }
    61.  
    62. break;
    63.  
    64. case 2:
    65. func_146089_b(var2, Items.ender_eye, this.rand, this.adjustProbability(0.3F));
    66. func_146089_b(var2, Items.experience_bottle, this.rand, this.adjustProbability(0.2F));
    67. func_146089_b(var2, Items.redstone, this.rand, this.adjustProbability(0.4F));
    68. func_146089_b(var2, Item.getItemFromBlock(Blocks.glowstone), this.rand, this.adjustProbability(0.3F));
    69. Item[] var3 = new Item[] {Items.iron_sword, Items.diamond_sword, Items.iron_chestplate, Items.diamond_chestplate, Items.iron_axe, Items.diamond_axe, Items.iron_pickaxe, Items.diamond_pickaxe};
    70. Item[] var4 = var3;
    71. int var5 = var3.length;
    72. var6 = 0;
    73.  
    74. while (true)
    75. {
    76. if (var6 >= var5)
    77. {
    78. break label50;
    79. }
    80.  
    81. Item var7 = var4[var6];
    82.  
    83. if (this.rand.nextFloat() < this.adjustProbability(0.05F))
    84. {
    85. var2.add(new MerchantRecipe(new ItemStack(var7, 1, 0), new ItemStack(Items.emerald, 2 + this.rand.nextInt(3), 0), EnchantmentHelper.addRandomEnchantment(this.rand, new ItemStack(var7, 1, 0), 5 + this.rand.nextInt(15))));
    86. }
    87.  
    88. ++var6;
    89. }
    90.  
    91. case 3:
    92. func_146091_a(var2, Items.coal, this.rand, this.adjustProbability(0.7F));
    93. func_146091_a(var2, Items.iron_ingot, this.rand, this.adjustProbability(0.5F));
    94. func_146091_a(var2, Items.gold_ingot, this.rand, this.adjustProbability(0.5F));
    95. func_146091_a(var2, Items.diamond, this.rand, this.adjustProbability(0.5F));
    96. func_146089_b(var2, Items.iron_sword, this.rand, this.adjustProbability(0.5F));
    97. func_146089_b(var2, Items.diamond_sword, this.rand, this.adjustProbability(0.5F));
    98. func_146089_b(var2, Items.iron_axe, this.rand, this.adjustProbability(0.3F));
    99. func_146089_b(var2, Items.diamond_axe, this.rand, this.adjustProbability(0.3F));
    100. func_146089_b(var2, Items.iron_pickaxe, this.rand, this.adjustProbability(0.5F));
    101. func_146089_b(var2, Items.diamond_pickaxe, this.rand, this.adjustProbability(0.5F));
    102. func_146089_b(var2, Items.iron_shovel, this.rand, this.adjustProbability(0.2F));
    103. func_146089_b(var2, Items.diamond_shovel, this.rand, this.adjustProbability(0.2F));
    104. func_146089_b(var2, Items.iron_hoe, this.rand, this.adjustProbability(0.2F));
    105. func_146089_b(var2, Items.diamond_hoe, this.rand, this.adjustProbability(0.2F));
    106. func_146089_b(var2, Items.iron_boots, this.rand, this.adjustProbability(0.2F));
    107. func_146089_b(var2, Items.diamond_boots, this.rand, this.adjustProbability(0.2F));
    108. func_146089_b(var2, Items.iron_helmet, this.rand, this.adjustProbability(0.2F));
    109. func_146089_b(var2, Items.diamond_helmet, this.rand, this.adjustProbability(0.2F));
    110. func_146089_b(var2, Items.iron_chestplate, this.rand, this.adjustProbability(0.2F));
    111. func_146089_b(var2, Items.diamond_chestplate, this.rand, this.adjustProbability(0.2F));
    112. func_146089_b(var2, Items.iron_leggings, this.rand, this.adjustProbability(0.2F));
    113. func_146089_b(var2, Items.diamond_leggings, this.rand, this.adjustProbability(0.2F));
    114. func_146089_b(var2, Items.chainmail_boots, this.rand, this.adjustProbability(0.1F));
    115. func_146089_b(var2, Items.chainmail_helmet, this.rand, this.adjustProbability(0.1F));
    116. func_146089_b(var2, Items.chainmail_chestplate, this.rand, this.adjustProbability(0.1F));
    117. func_146089_b(var2, Items.chainmail_leggings, this.rand, this.adjustProbability(0.1F));
    118. break;
    119.  
    120. case 4:
    121. func_146091_a(var2, Items.coal, this.rand, this.adjustProbability(0.7F));
    122. func_146091_a(var2, Items.porkchop, this.rand, this.adjustProbability(0.5F));
    123. func_146091_a(var2, Items.beef, this.rand, this.adjustProbability(0.5F));
    124. func_146089_b(var2, Items.saddle, this.rand, this.adjustProbability(0.1F));
    125. func_146089_b(var2, Items.leather_chestplate, this.rand, this.adjustProbability(0.3F));
    126. func_146089_b(var2, Items.leather_boots, this.rand, this.adjustProbability(0.3F));
    127. func_146089_b(var2, Items.leather_helmet, this.rand, this.adjustProbability(0.3F));
    128. func_146089_b(var2, Items.leather_leggings, this.rand, this.adjustProbability(0.3F));
    129. func_146089_b(var2, Items.cooked_porkchop, this.rand, this.adjustProbability(0.3F));
    130. func_146089_b(var2, Items.cooked_beef, this.rand, this.adjustProbability(0.3F));
    131. }
    132.  
    133. if (var2.isEmpty())
    134. {
    135. func_146091_a(var2, Items.gold_ingot, this.rand, 1.0F);
    136. }
    137.  
    138. Collections.shuffle(var2);
    139.  
    140. if (this.buyingList == null)
    141. {
    142. this.buyingList = new MerchantRecipeList();
    143. }
    144.  
    145. for (int var9 = 0; var9 < par1 && var9 < var2.size(); ++var9)
    146. {
    147. this.buyingList.addToListWithCheck((MerchantRecipe)var2.get(var9));
    148. }
    149. }
     
    WeeSkilz likes this.
  9. Offline

    Anubis3467


    Can you help me please? :c I mean doing the plugin
     
  10. Offline

    CMG

    Oh hai nerdfall.
     
  11. Offline

    Anubis3467

    :DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD Thanks!!!!!!!!
     
  12. Offline

    Anubis3467

    :C!!!!!!!!!!! Please.... Help me
     
  13. Offline

    Anubis3467

    The guys was going to do the plugin deleted his coment :C And I really need this plugin
     
  14. Anubis3467 He may have decided to not make it, I am sure someone will just be patient.
     
  15. Offline

    Anubis3467

    I needed it for today ;_;
     
  16. Offline

    Anubis3467

    Can somebody please do it? :c
     
  17. Offline

    Anubis3467

    Please :C
     

Share This Page