This commit is contained in:
Brandon 2020-08-01 08:40:41 -04:00
commit 5e26cfcf3d
10 changed files with 270 additions and 200 deletions

View File

@ -80,3 +80,8 @@ Depending on what you add, the chances for inclusion vary:
Report all bugs and missing Minecraft features here: Report all bugs and missing Minecraft features here:
<https://git.minetest.land/Wuzzy/MineClone2/issues> <https://git.minetest.land/Wuzzy/MineClone2/issues>
## Direct discussion
We have an IRC channel! Join us on #mineclone2 in freenode.net.
<ircs://irc.freenode.net:6697/#mineclone2>

View File

@ -724,6 +724,42 @@ local is_at_cliff_or_danger = function(self)
end end
-- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water
local is_at_water_danger = function(self)
if not self.object:get_luaentity() then
return false
end
local yaw = self.object:get_yaw()
local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5)
local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5)
local pos = self.object:get_pos()
local ypos = pos.y + self.collisionbox[2] -- just above floor
local free_fall, blocker = minetest.line_of_sight(
{x = pos.x + dir_x, y = ypos, z = pos.z + dir_z},
{x = pos.x + dir_x, y = ypos - 3, z = pos.z + dir_z})
if free_fall then
return true
else
local bnode = minetest.get_node(blocker)
local waterdanger = is_node_waterhazard(self, bnode.name)
if
waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then
return false
elseif waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) == false then
return true
else
local def = minetest.registered_nodes[bnode.name]
return (not def and def.walkable)
end
end
return false
end
-- get node but use fallback for nil or unknown -- get node but use fallback for nil or unknown
local node_ok = function(pos, fallback) local node_ok = function(pos, fallback)
@ -2049,40 +2085,40 @@ local do_states = function(self, dtime)
local is_in_danger = false local is_in_danger = false
if lp then if lp then
local is_in_danger = false
-- if mob is flying, only check for node it is currently in (no contact with node below)
if flight_check(self) then
is_in_danger = is_node_dangerous(self, self.standing_in)
elseif (is_node_dangerous(self, self.standing_in) or
is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then
is_in_danger = true
end
-- If mob in or on dangerous block, look for land -- If mob in or on dangerous block, look for land
if is_in_danger then if (is_node_dangerous(self, self.standing_in) or
lp = minetest.find_node_near(s, 5, {"group:solid"}) is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) and (not self.fly) then
is_in_danger = true
-- did we find land? -- If mob in or on dangerous block, look for land
if lp then if is_in_danger then
-- Better way to find shore - copied from upstream
lp = minetest.find_nodes_in_area_under_air(
{x = s.x - 5, y = s.y - 0.5, z = s.z - 5},
{x = s.x + 5, y = s.y + 1, z = s.z + 5},
{"group:solid"})
local vec = { lp = #lp > 0 and lp[random(#lp)]
x = lp.x - s.x,
z = lp.z - s.z -- did we find land?
} if lp then
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate local vec = {
x = lp.x - s.x,
z = lp.z - s.z
}
if lp.x > s.x then yaw = yaw + pi end yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
-- look towards land and jump/move in that direction
yaw = set_yaw(self, yaw, 6) if lp.x > s.x then yaw = yaw + pi end
do_jump(self)
set_velocity(self, self.walk_velocity) -- look towards land and move in that direction
else yaw = set_yaw(self, yaw, 6)
yaw = yaw + random(-0.5, 0.5) set_velocity(self, self.walk_velocity)
end
end
end
-- A danger is near but mob is not inside -- A danger is near but mob is not inside
else else
@ -3218,8 +3254,6 @@ local mob_step = function(self, dtime)
breed(self) breed(self)
follow_flop(self)
if do_states(self, dtime) then if do_states(self, dtime) then
return return
end end
@ -3228,6 +3262,18 @@ local mob_step = function(self, dtime)
runaway_from(self) runaway_from(self)
if is_at_water_danger(self) and self.state ~= "attack" then
if random(1, 10) <= 6 then
set_velocity(self, 0)
self.state = "stand"
set_animation(self, "stand")
yaw = yaw + random(-0.5, 0.5)
yaw = set_yaw(self, yaw, 8)
end
end
follow_flop(self)
if is_at_cliff_or_danger(self) then if is_at_cliff_or_danger(self) then
set_velocity(self, 0) set_velocity(self, 0)
self.state = "stand" self.state = "stand"

View File

@ -83,7 +83,10 @@ local function lay_down(player, pos, bed_pos, state, skip)
end end
-- No sleeping while moving. Slightly different behaviour than in MC. -- No sleeping while moving. Slightly different behaviour than in MC.
if vector.length(player:get_player_velocity()) > 0.001 then -- FIXME: Velocity threshold should be 0.01 but Minetest 5.3.0
-- sometimes reports incorrect Y speed. A velocity threshold
-- of 0.125 still seems good enough.
if vector.length(player:get_player_velocity()) > 0.125 then
minetest.chat_send_player(name, S("You have to stop moving before going to bed!")) minetest.chat_send_player(name, S("You have to stop moving before going to bed!"))
return false return false
end end
@ -115,13 +118,16 @@ local function lay_down(player, pos, bed_pos, state, skip)
mcl_beds.player[name] = nil mcl_beds.player[name] = nil
player_in_bed = player_in_bed - 1 player_in_bed = player_in_bed - 1
end end
mcl_beds.pos[name] = nil
mcl_beds.bed_pos[name] = nil
if p then
player:set_pos(p)
end
-- skip here to prevent sending player specific changes (used for leaving players) -- skip here to prevent sending player specific changes (used for leaving players)
if skip then if skip then
return false return false
end end
if p then
player:set_pos(p)
end
-- physics, eye_offset, etc -- physics, eye_offset, etc
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
@ -134,8 +140,6 @@ local function lay_down(player, pos, bed_pos, state, skip)
player:get_meta():set_string("mcl_beds:sleeping", "false") player:get_meta():set_string("mcl_beds:sleeping", "false")
hud_flags.wielditem = true hud_flags.wielditem = true
mcl_player.player_set_animation(player, "stand" , 30) mcl_player.player_set_animation(player, "stand" , 30)
mcl_beds.pos[name] = nil
mcl_beds.bed_pos[name] = nil
-- lay down -- lay down
else else
@ -198,8 +202,8 @@ local function lay_down(player, pos, bed_pos, state, skip)
return true return true
end end
local function update_formspecs(finished) local function update_formspecs(finished, ges)
local ges = #minetest.get_connected_players() local ges = ges or #minetest.get_connected_players()
local form_n = "size[6,5;true]" local form_n = "size[6,5;true]"
local all_in_bed = ges == player_in_bed local all_in_bed = ges == player_in_bed
local night_skip = is_night_skip_enabled() local night_skip = is_night_skip_enabled()
@ -360,8 +364,14 @@ end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
lay_down(player, nil, nil, false, true) lay_down(player, nil, nil, false, true)
mcl_beds.player[name] = nil players = minetest.get_connected_players()
if check_in_beds() then for n, player in ipairs(players) do
if player:get_player_name() == name then
players[n] = nil
break
end
end
if check_in_beds(players) then
minetest.after(5, function() minetest.after(5, function()
if check_in_beds() then if check_in_beds() then
update_formspecs(is_night_skip_enabled()) update_formspecs(is_night_skip_enabled())
@ -369,7 +379,7 @@ minetest.register_on_leaveplayer(function(player)
end end
end) end)
end end
update_formspecs(false) update_formspecs(false, #players)
end) end)
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)

View File

@ -4,7 +4,6 @@ local function active_brewing_formspec(fuel_percent, brew_percent)
return "size[9,8.75]".. return "size[9,8.75]"..
"background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]".. "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]"..
-- "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory_active.png]"..
"label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]".. "label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,4.5;9,3;9]"..
@ -375,7 +374,7 @@ minetest.register_node("mcl_brewing:stand_000", {
_doc_items_longdesc = S("The stand allows you to brew potions!"), _doc_items_longdesc = S("The stand allows you to brew potions!"),
_doc_items_usagehelp = doc_string, _doc_items_usagehelp = doc_string,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=1, not_in_creative_inventory = 0, not_in_craft_guide = 0}, groups = {pickaxey=1, falling_node=1, brewitem=1 },
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -392,32 +391,16 @@ minetest.register_node("mcl_brewing:stand_000", {
{-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base
{-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base
-- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1
-- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1
-- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1
-- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1
-- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1
{-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1
{-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
{-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1
-- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2
-- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2
-- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2
-- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2
-- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2
{5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2
{4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
{2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2
-- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3
-- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3
{0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3
{0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3
{0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3
@ -427,7 +410,6 @@ minetest.register_node("mcl_brewing:stand_000", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -458,7 +440,7 @@ minetest.register_node("mcl_brewing:stand_100", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -486,21 +468,11 @@ minetest.register_node("mcl_brewing:stand_100", {
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
{-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1
-- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2
-- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2
-- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2
-- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2
-- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2
{5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2
{4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
{2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2
-- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3
-- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3
{0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3
{0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3
{0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3
@ -510,7 +482,6 @@ minetest.register_node("mcl_brewing:stand_100", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -541,7 +512,7 @@ minetest.register_node("mcl_brewing:stand_010", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -558,12 +529,6 @@ minetest.register_node("mcl_brewing:stand_010", {
{-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base
{-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base
-- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1
-- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1
-- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1
-- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1
-- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1
{-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1
{-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
@ -581,9 +546,6 @@ minetest.register_node("mcl_brewing:stand_010", {
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
{2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2
-- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3
-- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3
{0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3
{0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3
{0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3
@ -593,7 +555,6 @@ minetest.register_node("mcl_brewing:stand_010", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -624,7 +585,7 @@ minetest.register_node("mcl_brewing:stand_001", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -641,24 +602,11 @@ minetest.register_node("mcl_brewing:stand_001", {
{-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base
{-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base
-- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1
-- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1
-- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1
-- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1
-- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1
{-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1
{-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
{-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1
-- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2
-- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2
-- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2
-- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2
-- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2
{5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2
{4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
@ -676,7 +624,6 @@ minetest.register_node("mcl_brewing:stand_001", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -707,7 +654,7 @@ minetest.register_node("mcl_brewing:stand_110", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -747,9 +694,6 @@ minetest.register_node("mcl_brewing:stand_110", {
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
{2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2
-- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3
-- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3
{0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3
{0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3
{0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3
@ -759,7 +703,6 @@ minetest.register_node("mcl_brewing:stand_110", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -790,7 +733,7 @@ minetest.register_node("mcl_brewing:stand_101", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -818,13 +761,6 @@ minetest.register_node("mcl_brewing:stand_101", {
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
{-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1
-- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2
-- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2
-- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2
-- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2
-- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2
{5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2
{4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2
{3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2
@ -842,7 +778,6 @@ minetest.register_node("mcl_brewing:stand_101", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,
@ -873,7 +808,7 @@ minetest.register_node("mcl_brewing:stand_011", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -890,18 +825,11 @@ minetest.register_node("mcl_brewing:stand_011", {
{-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base
{-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base
-- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1
-- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1
-- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1
-- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1
-- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1
{-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1
{-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1
{-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1
{-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1
{7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2
{6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2
{5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2
@ -956,7 +884,7 @@ minetest.register_node("mcl_brewing:stand_111", {
description = S("Brewing Stand"), description = S("Brewing Stand"),
_doc_items_create_entry = false, _doc_items_create_entry = false,
_tt_help = S("Brew Potions"), _tt_help = S("Brew Potions"),
groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1},
tiles = tiles, tiles = tiles,
drop = "mcl_brewing:stand", drop = "mcl_brewing:stand",
paramtype = "light", paramtype = "light",
@ -1008,7 +936,6 @@ minetest.register_node("mcl_brewing:stand_111", {
_mcl_blast_resistance = 1, _mcl_blast_resistance = 1,
_mcl_hardness = 1, _mcl_hardness = 1,
on_destruct = on_destruct, on_destruct = on_destruct,
-- after_dig_node = after_dig,
allow_metadata_inventory_take = allow_take, allow_metadata_inventory_take = allow_take,
allow_metadata_inventory_put = allow_put, allow_metadata_inventory_put = allow_put,
on_metadata_inventory_put = on_put, on_metadata_inventory_put = on_put,

View File

@ -277,8 +277,9 @@ minetest.register_craftitem("mcl_potions:river_water", {
}) })
mcl_potions.register_splash("water", S("Splash Potion"), "#0022FF", {tt="No effect", potion_fun=function() end}) -- TODO: Extinguish fire, damage mobs
mcl_potions.register_lingering("water", S("Lingering Potion"), "#0022FF", {tt="No effect", potion_fun=function() end}) mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", {tt="No effect", potion_fun=function() end})
mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", {tt="No effect", potion_fun=function() end})
minetest.register_craftitem("mcl_potions:speckled_melon", { minetest.register_craftitem("mcl_potions:speckled_melon", {
description = S("Glistering Melon"), description = S("Glistering Melon"),

View File

@ -69,9 +69,18 @@ end)
function mcl_potions.register_lingering(name, descr, color, def) function mcl_potions.register_lingering(name, descr, color, def)
local id = "mcl_potions:"..name.."_lingering" local id = "mcl_potions:"..name.."_lingering"
local longdesc = def.longdesc
if not def.no_effect then
longdesc = S("A throwable potion that will shatter on impact, where it creates a magic cloud that lingers around for a while. Any player or mob inside the cloud will receive the potion's effect, possibly repeatedly.")
if def.longdesc then
longdesc = longdesc .. "\n" .. def.longdesc
end
end
minetest.register_craftitem(id, { minetest.register_craftitem(id, {
description = descr, description = descr,
_tt_help = def.tt, _tt_help = def.tt,
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = S("Use the “Punch” key to throw it."),
inventory_image = lingering_image(color), inventory_image = lingering_image(color),
groups = {brewitem=1, not_in_creative_inventory=0}, groups = {brewitem=1, not_in_creative_inventory=0},
on_use = function(item, placer, pointed_thing) on_use = function(item, placer, pointed_thing)

View File

@ -9,6 +9,7 @@ local potion_image = function(colorstring, opacity)
end end
local how_to_drink = S("Use the “Place” key to drink it.") local how_to_drink = S("Use the “Place” key to drink it.")
local potion_intro = S("Drinking a potion gives you a particular effect.")
local function time_string(dur) local function time_string(dur)
if not dur then return nil end if not dur then return nil end
@ -66,7 +67,7 @@ local function register_potion(def)
if effect and def.is_dur then if effect and def.is_dur then
_tt = perc_string(effect).." | "..time_string(dur) _tt = perc_string(effect).." | "..time_string(dur)
if def.name == "poison" or def.name == "regeneration" then if def.name == "poison" or def.name == "regeneration" then
_tt = "1/2 Heart/"..effect.."sec | "..time_string(dur) _tt = "1/2 heart/"..effect.."s | "..time_string(dur)
end end
elseif def.name == "healing" or def.name == "harming" then elseif def.name == "healing" or def.name == "harming" then
_tt = ((effect / 2) - ((effect / 2)% 0.5)).." Hearts" _tt = ((effect / 2) - ((effect / 2)% 0.5)).." Hearts"
@ -106,15 +107,32 @@ local function register_potion(def)
return function() end return function() end
end end
local desc
if not def.no_potion then
desc = S("@1 Potion", def.description)
else
desc = def.description
end
local potion_longdesc = def._longdesc
if not def.no_effect then
potion_longdesc = potion_intro .. "\n" .. def._longdesc
end
local potion_usagehelp
local basic_potion_tt
if def.name ~= "dragon_breath" then
potion_usagehelp = how_to_drink
basic_potion_tt = get_tt(def._tt, def.effect, dur)
end
minetest.register_craftitem("mcl_potions:"..def.name, { minetest.register_craftitem("mcl_potions:"..def.name, {
description = S(def.description), description = desc,
_tt_help = get_tt(def._tt, def.effect, dur), _tt_help = basic_potion_tt,
_doc_items_longdesc = def._longdesc, _doc_items_longdesc = potion_longdesc,
_doc_items_usagehelp = how_to_drink, _doc_items_usagehelp = potion_usagehelp,
stack_max = def.stack_max or 1, stack_max = def.stack_max or 1,
inventory_image = def.image or potion_image(def.color), inventory_image = def.image or potion_image(def.color),
wield_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color),
groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1 },
on_place = on_use, on_place = on_use,
on_secondary_use = on_use, on_secondary_use = on_use,
}) })
@ -125,36 +143,46 @@ local function register_potion(def)
local splash_def = { local splash_def = {
tt = get_tt(def._tt, def.effect, splash_dur), tt = get_tt(def._tt, def.effect, splash_dur),
longdesc = def._longdesc,
potion_fun = get_splash_fun(def.effect, splash_dur), potion_fun = get_splash_fun(def.effect, splash_dur),
no_effect = def.no_effect,
} }
local ling_def local ling_def
if def.name == "healing" or def.name == "harming" then if def.name == "healing" or def.name == "harming" then
ling_def = { ling_def = {
tt = get_tt(def._tt, def.effect*mcl_potions.LINGERING_FACTOR, ling_dur), tt = get_tt(def._tt, def.effect*mcl_potions.LINGERING_FACTOR, ling_dur),
longdesc = def._longdesc,
potion_fun = get_lingering_fun(def.effect*mcl_potions.LINGERING_FACTOR, ling_dur), potion_fun = get_lingering_fun(def.effect*mcl_potions.LINGERING_FACTOR, ling_dur),
no_effect = def.no_effect,
} }
else else
ling_def = { ling_def = {
tt = get_tt(def._tt, def.effect, ling_dur), tt = get_tt(def._tt, def.effect, ling_dur),
longdesc = def._longdesc,
potion_fun = get_lingering_fun(def.effect, ling_dur), potion_fun = get_lingering_fun(def.effect, ling_dur),
no_effect = def.no_effect,
} }
end end
local arrow_def = { local arrow_def = {
tt = get_tt(def._tt, def.effect, dur/8.), tt = get_tt(def._tt, def.effect, dur/8.),
longdesc = def._longdesc,
potion_fun = get_arrow_fun(def.effect, dur/8.), potion_fun = get_arrow_fun(def.effect, dur/8.),
no_effect = def.no_effect,
} }
if def.color and def.name ~= "dragon_breath" then -- dont' splash dragon's breath... if def.color and not def.no_throwable then
mcl_potions.register_splash(def.name, S("Splash "..def.description), def.color, splash_def) mcl_potions.register_splash(def.name, S("Splash @1 Potion", def.description), def.color, splash_def)
mcl_potions.register_lingering(def.name, S("Lingering "..def.description), def.color, ling_def) mcl_potions.register_lingering(def.name, S("Lingering @1 Potion", def.description), def.color, ling_def)
mcl_potions.register_arrow(def.name, S("Arrow of "..def.description), def.color, arrow_def) if not def.no_arrow then
mcl_potions.register_arrow(def.name, S("Arrow of @1", def.description), def.color, arrow_def)
end
end end
if def.is_II then if def.is_II then
local desc_mod = " II" local desc_mod = S(" II")
local effect_II local effect_II
if def.name == "healing" or def.name == "harming" then if def.name == "healing" or def.name == "harming" then
@ -171,7 +199,7 @@ local function register_potion(def)
if def.name == "slowness" then if def.name == "slowness" then
dur_2 = 20 dur_2 = 20
effect_II = 0.40 effect_II = 0.40
desc_mod = " IV" desc_mod = S(" IV")
end end
local on_use = function (itemstack, user, pointed_thing) local on_use = function (itemstack, user, pointed_thing)
@ -182,14 +210,14 @@ local function register_potion(def)
end end
minetest.register_craftitem("mcl_potions:"..def.name.."_2", { minetest.register_craftitem("mcl_potions:"..def.name.."_2", {
description = S(def.description..desc_mod), description = S("@1 Potion@2", def.description, desc_mod),
_tt_help = get_tt(def._tt_2, effect_II, dur_2), _tt_help = get_tt(def._tt_2, effect_II, dur_2),
_doc_items_longdesc = def._longdesc, _doc_items_longdesc = potion_longdesc,
_doc_items_usagehelp = how_to_drink, _doc_items_usagehelp = potion_usagehelp,
stack_max = def.stack_max or 1, stack_max = def.stack_max or 1,
inventory_image = def.image or potion_image(def.color), inventory_image = def.image or potion_image(def.color),
wield_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color),
groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1},
on_place = on_use, on_place = on_use,
on_secondary_use = on_use, on_secondary_use = on_use,
}) })
@ -202,12 +230,16 @@ local function register_potion(def)
if def.name == "healing" then if def.name == "healing" then
splash_def_2 = { splash_def_2 = {
tt = get_tt(def._tt_2, 7, splash_dur_2), tt = get_tt(def._tt_2, 7, splash_dur_2),
longdesc = def._longdesc,
potion_fun = get_splash_fun(7, splash_dur_2), potion_fun = get_splash_fun(7, splash_dur_2),
no_effect = def.no_effect,
} }
else else
splash_def_2 = { splash_def_2 = {
tt = get_tt(def._tt_2, effect_II, splash_dur_2), tt = get_tt(def._tt_2, effect_II, splash_dur_2),
longdesc = def._longdesc,
potion_fun = get_splash_fun(effect_II, splash_dur_2), potion_fun = get_splash_fun(effect_II, splash_dur_2),
no_effect = def.no_effect,
} }
end end
@ -216,24 +248,32 @@ local function register_potion(def)
if def.name == "healing" or def.name == "harming" then if def.name == "healing" or def.name == "harming" then
ling_def_2 = { ling_def_2 = {
tt = get_tt(def._tt_2, effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), tt = get_tt(def._tt_2, effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2),
longdesc = def._longdesc,
potion_fun = get_lingering_fun(effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), potion_fun = get_lingering_fun(effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2),
no_effect = def.no_effect,
} }
else else
ling_def_2 = { ling_def_2 = {
tt = get_tt(def._tt_2, effect_II, ling_dur_2), tt = get_tt(def._tt_2, effect_II, ling_dur_2),
longdesc = def._longdesc,
potion_fun = get_lingering_fun(effect_II, ling_dur_2), potion_fun = get_lingering_fun(effect_II, ling_dur_2),
no_effect = def.no_effect,
} }
end end
local arrow_def_2 = { local arrow_def_2 = {
tt = get_tt(def._tt_2, effect_II, dur_2/8.), tt = get_tt(def._tt_2, effect_II, dur_2/8.),
longdesc = def._longdesc,
potion_fun = get_arrow_fun(effect_II, dur_2/8.), potion_fun = get_arrow_fun(effect_II, dur_2/8.),
no_effect = def.no_effect,
} }
if def.color then if def.color and not def.no_throwable then
mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2) mcl_potions.register_splash(def.name.."_2", S("Splash @1@2 Potion", def.description, desc_mod), def.color, splash_def_2)
mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2) mcl_potions.register_lingering(def.name.."_2", S("Lingering @1@2 Potion", def.description, desc_mod), def.color, ling_def_2)
mcl_potions.register_arrow(def.name.."_2", S("Arrow of "..def.description..desc_mod), def.color, arrow_def_2) if not def.no_arrow then
mcl_potions.register_arrow(def.name.."_2", S("Arrow of @1@2", def.description, desc_mod), def.color, arrow_def_2)
end
end end
end end
@ -253,14 +293,14 @@ local function register_potion(def)
end end
minetest.register_craftitem("mcl_potions:"..def.name.."_plus", { minetest.register_craftitem("mcl_potions:"..def.name.."_plus", {
description = S(def.description.." +"), description = S("@1 + Potion", def.description),
_tt_help = get_tt(def._tt_plus, def.effect, dur_pl), _tt_help = get_tt(def._tt_plus, def.effect, dur_pl),
_doc_items_longdesc = def._longdesc, _doc_items_longdesc = potion_longdesc,
_doc_items_usagehelp = how_to_drink, _doc_items_usagehelp = potion_usagehelp,
stack_max = 1, stack_max = 1,
inventory_image = def.image or potion_image(def.color), inventory_image = def.image or potion_image(def.color),
wield_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color),
groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1},
on_place = on_use, on_place = on_use,
on_secondary_use = on_use, on_secondary_use = on_use,
}) })
@ -271,20 +311,28 @@ local function register_potion(def)
local splash_def_pl = { local splash_def_pl = {
tt = get_tt(def._tt_plus, def.effect, splash_dur_pl), tt = get_tt(def._tt_plus, def.effect, splash_dur_pl),
longdesc = def._longdesc,
potion_fun = get_splash_fun(def.effect, splash_dur_pl), potion_fun = get_splash_fun(def.effect, splash_dur_pl),
no_effect = def.no_effect,
} }
local ling_def_pl = { local ling_def_pl = {
tt = get_tt(def._tt_plus, def.effect, ling_dur_pl), tt = get_tt(def._tt_plus, def.effect, ling_dur_pl),
longdesc = def._longdesc,
potion_fun = get_lingering_fun(def.effect, ling_dur_pl), potion_fun = get_lingering_fun(def.effect, ling_dur_pl),
no_effect = def.no_effect,
} }
local arrow_def_pl = { local arrow_def_pl = {
tt = get_tt(def._tt_pl, def.effect, dur_pl/8.), tt = get_tt(def._tt_pl, def.effect, dur_pl/8.),
longdesc = def._longdesc,
potion_fun = get_arrow_fun(def.effect, dur_pl/8.), potion_fun = get_arrow_fun(def.effect, dur_pl/8.),
no_effect = def.no_effect,
} }
if def.color then if def.color and not def.no_throwable then
mcl_potions.register_splash(def.name.."_plus", S("Splash "..def.description.." +"), def.color, splash_def_pl) mcl_potions.register_splash(def.name.."_plus", S("Splash @1 + Potion", def.description), def.color, splash_def_pl)
mcl_potions.register_lingering(def.name.."_plus", S("Lingering "..def.description.." +"), def.color, ling_def_pl) mcl_potions.register_lingering(def.name.."_plus", S("Lingering @1 + Potion", def.description), def.color, ling_def_pl)
mcl_potions.register_arrow(def.name.."_plus", S("Arrow of"..def.description.." +"), def.color, arrow_def_pl) if not def.no_arrow then
mcl_potions.register_arrow(def.name.."_plus", S("Arrow of @1 +", def.description), def.color, arrow_def_pl)
end
end end
end end
@ -309,26 +357,32 @@ end
local awkward_def = { local awkward_def = {
name = "awkward", name = "awkward",
description = "Awkward Potion", description = S("Awkward"),
no_arrow = true,
no_effect = true,
_tt = S("No effect"), _tt = S("No effect"),
_longdesc = S("Has an awkward taste and is used for brewing potions."), _longdesc = S("Has an awkward taste and is used for brewing potions."),
color = "#0000FF", color = "#0000FF",
groups = {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, groups = {brewitem=1, food=3, can_eat_when_full=1},
on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
} }
local mundane_def = { local mundane_def = {
name = "mundane", name = "mundane",
description = "Mundane Potion", description = S("Mundane"),
no_arrow = true,
no_effect = true,
_tt = S("No effect"), _tt = S("No effect"),
longdesc = S("Has a terrible taste and is not useful for brewing potions."), _longdesc = S("Has a terrible taste and is not useful for brewing potions."),
color = "#0000FF", color = "#0000FF",
on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
} }
local thick_def = { local thick_def = {
name = "thick", name = "thick",
description = "Thick Potion", description = S("Thick"),
no_arrow = true,
no_effect = true,
_tt = S("No effect"), _tt = S("No effect"),
_longdesc = S("Has a bitter taste and is not useful for brewing potions."), _longdesc = S("Has a bitter taste and is not useful for brewing potions."),
color = "#0000FF", color = "#0000FF",
@ -337,21 +391,24 @@ local thick_def = {
local dragon_breath_def = { local dragon_breath_def = {
name = "dragon_breath", name = "dragon_breath",
description = "Dragon's Breath", description = S("Dragon's Breath"),
_tt = S("No effect"), no_arrow = true,
_longdesc = S("Combine with Splash potions to create a Lingering effect"), no_potion = true,
no_throwable = true,
no_effect = true,
_longdesc = S("This item is used in brewing and can be combined with splash potions to create lingering potions."),
color = "#BF4567", color = "#BF4567",
groups = { brewitem = 1, not_in_creative_inventory = 0 }, groups = { brewitem = 1 },
on_use = nil, on_use = nil,
stack_max = 64, stack_max = 64,
} }
local healing_def = { local healing_def = {
name = "healing", name = "healing",
description = "Healing Potion", description = S("Healing"),
_tt = S("+2 Hearts"), _tt = S("+2 hearts"),
_tt_2 = S("+4 Hearts"), _tt_2 = S("+4 hearts"),
_longdesc = S("Drink to heal yourself"), _longdesc = S("Instantly heals."),
color = "#CC0000", color = "#CC0000",
effect = 4, effect = 4,
on_use = mcl_potions.healing_func, on_use = mcl_potions.healing_func,
@ -361,10 +418,10 @@ local healing_def = {
local harming_def = { local harming_def = {
name = "harming", name = "harming",
description = "Harming Potion", description = S("Harming"),
_tt = S("-3 Hearts"), _tt = S("-3 hearts"),
_tt_II = S("-6 Hearts"), _tt_II = S("-6 hearts"),
_longdesc = S("Drink to heal yourself"), _longdesc = S("Instantly deals damage."),
color = "#660099", color = "#660099",
effect = -6, effect = -6,
on_use = mcl_potions.healing_func, on_use = mcl_potions.healing_func,
@ -374,9 +431,9 @@ local harming_def = {
local night_vision_def = { local night_vision_def = {
name = "night_vision", name = "night_vision",
description = "Night Vision Potion", description = S("Night Vision"),
_tt = nil, _tt = nil,
_longdesc = S("Drink to see in the dark."), _longdesc = S("Grants the ability to see in darkness."),
color = "#1010AA", color = "#1010AA",
effect = nil, effect = nil,
is_dur = true, is_dur = true,
@ -386,9 +443,9 @@ local night_vision_def = {
local swiftness_def = { local swiftness_def = {
name = "swiftness", name = "swiftness",
description = "Swiftness Potion", description = S("Swiftness"),
_tt = nil, _tt = nil,
_longdesc = S("Drink to increase your speed."), _longdesc = S("Increases walking speed."),
color = "#009999", color = "#009999",
effect = 1.2, effect = 1.2,
is_dur = true, is_dur = true,
@ -399,9 +456,9 @@ local swiftness_def = {
local slowness_def = { local slowness_def = {
name = "slowness", name = "slowness",
description = "Slowness Potion", description = S("Slowness"),
_tt = nil, _tt = nil,
_longdesc = S("Drink to become sluggish"), _longdesc = S("Decreases walking speed."),
color = "#000080", color = "#000080",
effect = 0.85, effect = 0.85,
is_dur = true, is_dur = true,
@ -413,9 +470,9 @@ local slowness_def = {
local leaping_def = { local leaping_def = {
name = "leaping", name = "leaping",
description = "Leaping Potion", description = S("Leaping"),
_tt = nil, _tt = nil,
_longdesc = S("Drink to leap tall buildings in a single bound!"), _longdesc = S("Increases jump strength."),
color = "#00CC33", color = "#00CC33",
effect = 1.15, effect = 1.15,
is_dur = true, is_dur = true,
@ -426,9 +483,9 @@ local leaping_def = {
local poison_def = { local poison_def = {
name = "poison", name = "poison",
description = "Poison Potion", description = S("Poison"),
_tt = nil, _tt = nil,
_longdesc = S("Poison mobs or players with this dangerous potion."), _longdesc = S("Applies the poison effect which deals damage at a regular interval."),
color = "#447755", color = "#447755",
effect = 2.5, effect = 2.5,
is_dur = true, is_dur = true,
@ -440,9 +497,9 @@ local poison_def = {
local regeneration_def = { local regeneration_def = {
name = "regeneration", name = "regeneration",
description = "Regeneration Potion", description = S("Regeneration"),
_tt = nil, _tt = nil,
_longdesc = S("Regenerate mobs or players with this healing potion over time."), _longdesc = S("Regenerates health over time."),
color = "#B52CC2", color = "#B52CC2",
effect = 2.5, effect = 2.5,
is_dur = true, is_dur = true,
@ -453,9 +510,9 @@ local regeneration_def = {
local invisibility_def = { local invisibility_def = {
name = "invisibility", name = "invisibility",
description = "Invisibility Potion", description = S("Invisibility"),
_tt = nil, _tt = nil,
_longdesc = S("Drink and become invisibile to mobs and players."), _longdesc = S("Grants invisibility."),
color = "#B0B0B0", color = "#B0B0B0",
is_dur = true, is_dur = true,
on_use = mcl_potions.invisiblility_func, on_use = mcl_potions.invisiblility_func,
@ -464,9 +521,9 @@ local invisibility_def = {
local water_breathing_def = { local water_breathing_def = {
name = "water_breathing", name = "water_breathing",
description = "Water Breathing Potion", description = S("Water Breathing"),
_tt = nil, _tt = nil,
_longdesc = S("Drink and breath underwater."), _longdesc = S("Grants limitless breath underwater."),
color = "#0000AA", color = "#0000AA",
is_dur = true, is_dur = true,
on_use = mcl_potions.water_breathing_func, on_use = mcl_potions.water_breathing_func,
@ -475,9 +532,9 @@ local water_breathing_def = {
local fire_resistance_def = { local fire_resistance_def = {
name = "fire_resistance", name = "fire_resistance",
description = "Fire Resistance Potion", description = S("Fire Resistance"),
_tt = nil, _tt = nil,
_longdesc = S("Drink and resist fire damage."), _longdesc = S("Grants immunity to damage from heat sources like fire."),
color = "#D0A040", color = "#D0A040",
is_dur = true, is_dur = true,
on_use = mcl_potions.fire_resistance_func, on_use = mcl_potions.fire_resistance_func,
@ -499,12 +556,12 @@ end
-- minetest.register_craftitem("mcl_potions:weakness", { -- minetest.register_craftitem("mcl_potions:weakness", {
-- description = S("Weakness Potion"), -- description = S("Weakness"),
-- _tt_help = S("-4 HP damage | 1:30"), -- _tt_help = S("-4 HP damage | 1:30"),
-- _doc_items_longdesc = brewhelp, -- _doc_items_longdesc = brewhelp,
-- wield_image = potion_image("#6600AA"), -- wield_image = potion_image("#6600AA"),
-- inventory_image = potion_image("#6600AA"), -- inventory_image = potion_image("#6600AA"),
-- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, -- groups = { brewitem=1, food=3, can_eat_when_full=1 },
-- stack_max = 1, -- stack_max = 1,
-- --
-- on_place = function(itemstack, user, pointed_thing) -- on_place = function(itemstack, user, pointed_thing)
@ -523,12 +580,12 @@ end
-- }) -- })
-- --
-- minetest.register_craftitem("mcl_potions:weakness_plus", { -- minetest.register_craftitem("mcl_potions:weakness_plus", {
-- description = S("Weakness Potion +"), -- description = S("Weakness +"),
-- _tt_help = S("-4 HP damage | 4:00"), -- _tt_help = S("-4 HP damage | 4:00"),
-- _doc_items_longdesc = brewhelp, -- _doc_items_longdesc = brewhelp,
-- wield_image = potion_image("#7700BB"), -- wield_image = potion_image("#7700BB"),
-- inventory_image = potion_image("#7700BB"), -- inventory_image = potion_image("#7700BB"),
-- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, -- groups = { brewitem=1, food=3, can_eat_when_full=1 },
-- stack_max = 1, -- stack_max = 1,
-- --
-- on_place = function(itemstack, user, pointed_thing) -- on_place = function(itemstack, user, pointed_thing)
@ -547,12 +604,12 @@ end
-- }) -- })
-- --
-- minetest.register_craftitem("mcl_potions:strength", { -- minetest.register_craftitem("mcl_potions:strength", {
-- description = S("Strength Potion"), -- description = S("Strength"),
-- _tt_help = S("+3 HP damage | 3:00"), -- _tt_help = S("+3 HP damage | 3:00"),
-- _doc_items_longdesc = brewhelp, -- _doc_items_longdesc = brewhelp,
-- wield_image = potion_image("#D444D4"), -- wield_image = potion_image("#D444D4"),
-- inventory_image = potion_image("#D444D4"), -- inventory_image = potion_image("#D444D4"),
-- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, -- groups = { brewitem=1, food=3, can_eat_when_full=1 },
-- stack_max = 1, -- stack_max = 1,
-- --
-- on_place = function(itemstack, user, pointed_thing) -- on_place = function(itemstack, user, pointed_thing)
@ -571,12 +628,12 @@ end
-- }) -- })
-- --
-- minetest.register_craftitem("mcl_potions:strength_2", { -- minetest.register_craftitem("mcl_potions:strength_2", {
-- description = S("Strength Potion II"), -- description = S("Strength II"),
-- _tt_help = S("+6 HP damage | 1:30"), -- _tt_help = S("+6 HP damage | 1:30"),
-- _doc_items_longdesc = brewhelp, -- _doc_items_longdesc = brewhelp,
-- wield_image = potion_image("#D444E4"), -- wield_image = potion_image("#D444E4"),
-- inventory_image = potion_image("#D444E4"), -- inventory_image = potion_image("#D444E4"),
-- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, -- groups = { brewitem=1, food=3, can_eat_when_full=1 },
-- stack_max = 1, -- stack_max = 1,
-- --
-- on_place = function(itemstack, user, pointed_thing) -- on_place = function(itemstack, user, pointed_thing)
@ -595,12 +652,12 @@ end
-- }) -- })
-- --
-- minetest.register_craftitem("mcl_potions:strength_plus", { -- minetest.register_craftitem("mcl_potions:strength_plus", {
-- description = S("Strength Potion +"), -- description = S("Strength +"),
-- _tt_help = S("+3 HP damage | 8:00"), -- _tt_help = S("+3 HP damage | 8:00"),
-- _doc_items_longdesc = brewhelp, -- _doc_items_longdesc = brewhelp,
-- wield_image = potion_image("#D444F4"), -- wield_image = potion_image("#D444F4"),
-- inventory_image = potion_image("#D444F4"), -- inventory_image = potion_image("#D444F4"),
-- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, -- groups = { brewitem=1, food=3, can_eat_when_full=1 },
-- stack_max = 1, -- stack_max = 1,
-- --
-- on_place = function(itemstack, user, pointed_thing) -- on_place = function(itemstack, user, pointed_thing)

View File

@ -11,9 +11,18 @@ end
function mcl_potions.register_splash(name, descr, color, def) function mcl_potions.register_splash(name, descr, color, def)
local id = "mcl_potions:"..name.."_splash" local id = "mcl_potions:"..name.."_splash"
local longdesc = def.longdesc
if not def.no_effect then
longdesc = S("A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.")
if def.longdesc then
longdesc = longdesc .. "\n" .. def.longdesc
end
end
minetest.register_craftitem(id, { minetest.register_craftitem(id, {
description = descr, description = descr,
_tt_help = def.tt, _tt_help = def.tt,
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = S("Use the “Punch” key to throw it."),
inventory_image = splash_image(color), inventory_image = splash_image(color),
groups = {brewitem=1, not_in_creative_inventory=0}, groups = {brewitem=1, not_in_creative_inventory=0},
on_use = function(item, placer, pointed_thing) on_use = function(item, placer, pointed_thing)

View File

@ -27,19 +27,23 @@ local function arrow_image(colorstring, opacity)
end end
local how_to_shoot = minetest.registered_items["mcl_bows:arrow"]._doc_items_usagehelp
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
local mod_button = minetest.get_modpath("mesecons_button") local mod_button = minetest.get_modpath("mesecons_button")
function mcl_potions.register_arrow(name, desc, color, def) function mcl_potions.register_arrow(name, desc, color, def)
local longdesc = def.longdesc or ""
minetest.register_craftitem("mcl_potions:"..name.."_arrow", { minetest.register_craftitem("mcl_potions:"..name.."_arrow", {
description = desc, description = desc,
_tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3").."\n"..def.tt, _tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3").."\n"..def.tt,
_doc_items_longdesc = S("Arrows are ammunition for bows and dispensers.").."\n".. _doc_items_longdesc = S("Arrows are ammunition for bows and dispensers.").."\n"..
S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there's a 20% chance of a critical hit dealing 10 damage instead. An arrow fired from a dispenser always deals 3 damage.").."\n".. S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there's a 20% chance of a critical hit dealing 10 damage instead. An arrow fired from a dispenser always deals 3 damage.").."\n"..
S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons."), S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons.").."\n"..
_doc_items_usagehelp = S("To use arrows as ammunition for a bow, just put them anywhere in your inventory, they will be used up automatically. To use arrows as ammunition for a dispenser, place them in the dispenser's inventory. To retrieve an arrow that sticks in a block, simply walk close to it."), S("This particular arrow is tipped and will give an effect when it hits a player or mob.").."\n"..
longdesc,
_doc_items_usagehelp = how_to_shoot,
inventory_image = "mcl_bows_arrow_inv.png^(mcl_potions_arrow_inv.png^[colorize:"..color..":100)", inventory_image = "mcl_bows_arrow_inv.png^(mcl_potions_arrow_inv.png^[colorize:"..color..":100)",
groups = { ammo=1, ammo_bow=1, brewitem=1}, groups = { ammo=1, ammo_bow=1, brewitem=1},
_on_dispense = function(itemstack, dispenserpos, droppos, dropnode, dropdir) _on_dispense = function(itemstack, dispenserpos, droppos, dropnode, dropdir)

View File

@ -36,6 +36,8 @@ local wip_items = {
-- "mcl_potions:strength_lingering", -- "mcl_potions:strength_lingering",
-- "mcl_potions:strength_plus_lingering", -- "mcl_potions:strength_plus_lingering",
-- "mcl_potions:strength_2_lingering", -- "mcl_potions:strength_2_lingering",
"mcl_potions:night_vision_arrow",
"mcl_potions:night_vision_plus_arrow",
} }
local experimental_items = { local experimental_items = {
} }