master #5

Merged
epCode merged 255 commits from VoxeLibre/VoxeLibre:master into master 2021-02-02 23:20:01 +01:00
4 changed files with 43 additions and 20 deletions
Showing only changes of commit d820c35937 - Show all commits

View File

@ -11,12 +11,15 @@ Parameters:
stacks_max = 3, -- Maximum number of item stacks to get. Default: 1
items = { -- Table of possible loot items. This function selects between stacks_min and stacks_max of these.
{
weight = 5, -- Likelihood of this item being selected (see below). Optional (default: 1)
itemstack = ItemStack("example:item1"), -- Itemstack to select
-- OR
itemstring = "example:item1", -- Which item to select
amount_min = 1, -- Minimum size of itemstack. Must not be larger than 6553. Optional (default: 1)
amount_max = 10, -- Maximum size of item stack. Must not be larger than item definition's stack_max or 6553. Optional (default: 1)
wear_min = 1, -- Minimum wear value. Must be at least 1. Optional (default: no wear)
wear_max = 1, -- Maxiumum wear value. Must be at least 1. Optional (default: no wear)
weight = 5, -- Likelihood of this item being selected (see below). Optional (default: 1)
},
{ -- more tables like above, one table per item stack }
}
@ -56,6 +59,8 @@ function mcl_loot.get_loot(loot_definitions, pr)
end
if item then
local itemstring = item.itemstring
local itemstack = item.itemstack
if itemstring then
if item.amount_min and item.amount_max then
itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max)
end
@ -72,10 +77,13 @@ function mcl_loot.get_loot(loot_definitions, pr)
itemstring = itemstring .. " " .. tostring(wear)
end
table.insert(items, itemstring)
elseif itemstack then
table.insert(items, itemstack)
else
minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!")
end
end
end
return items
end

View File

@ -320,6 +320,23 @@ function mcl_enchanting.get_randomly_enchanted_book(enchantment_level, treasure,
return mcl_enchanting.enchant_randomly(enchantment_level, treasure, no_reduced_bonus_chance)
end
function mcl_enchanting.get_uniform_randomly_enchanted_book(except)
except = except or except
local stack = ItemStack("mcl_enchanting:book_enchanted")
local list = {}
for enchantment in pairs(mcl_enchanting.enchantments) do
if table.indexof(except, enchantment) == -1 then
table.insert(list, enchantment)
end
end
local index = math.random(#list)
local enchantment = list[index]
local enchantment_def = mcl_enchanting.enchantments[enchantment]
local level = math.random(enchantment_def.max_level)
mcl_enchanting.enchant(stack, enchantment, level)
return stack
end
function mcl_enchanting.get_random_glyph_row()
local glyphs = ""
local x = 1.3

View File

@ -88,8 +88,7 @@ local fish = function(itemstack, player)
items = {
-- TODO: Enchanted Bow
{ itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
-- TODO: Enchanted Book
{ itemstring = "mcl_books:book" },
{ itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)},
-- TODO: Enchanted Fishing Rod
{ itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
{ itemstring = "mcl_mobs:nametag", },

View File

@ -21,8 +21,7 @@ local get_loot = function()
{ itemstring = "mcl_jukebox:record_4", weight = 15 },
{ itemstring = "mobs_mc:iron_horse_armor", weight = 15 },
{ itemstring = "mcl_core:apple_gold", weight = 15 },
-- TODO: Enchanted Book
{ itemstring = "mcl_books:book", weight = 10 },
{ itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}), weight = 10 },
{ itemstring = "mobs_mc:gold_horse_armor", weight = 10 },
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 5 },
-- TODO: Enchanted Golden Apple