1
0
Fork 0

Merge branch 'master' into itemframe

This commit is contained in:
Lizzy Fleckenstein 2021-01-05 14:27:08 +01:00
commit a0ffe92587
9 changed files with 64 additions and 35 deletions

View File

@ -163,7 +163,7 @@ minetest.register_on_joinplayer(function(player)
name = player:get_player_name() name = player:get_player_name()
temp_pool = pool[name] temp_pool = pool[name]
hud_manager.add_hud(player,"experience_bar", hud_manager.add_hud(player,"experience_bar",
{ {
hud_elem_type = "image", hud_elem_type = "image",
@ -175,7 +175,7 @@ minetest.register_on_joinplayer(function(player)
alignment = { x = 1, y = 1 }, alignment = { x = 1, y = 1 },
z_index = 11, z_index = 11,
}) })
hud_manager.add_hud(player,"xp_level", hud_manager.add_hud(player,"xp_level",
{ {
hud_elem_type = "text", position = {x=0.5, y=1}, hud_elem_type = "text", position = {x=0.5, y=1},
@ -279,7 +279,7 @@ minetest.register_on_dieplayer(function(player)
name = player:get_player_name() name = player:get_player_name()
temp_pool = pool[name] temp_pool = pool[name]
xp_amount = temp_pool.xp xp_amount = temp_pool.xp
temp_pool.xp = 0 temp_pool.xp = 0
temp_pool.level = 0 temp_pool.level = 0
temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level)
@ -312,11 +312,11 @@ local function xp_step(self, dtime)
--get the variables --get the variables
pos = self.object:get_pos() pos = self.object:get_pos()
pos2 = collector:get_pos() pos2 = collector:get_pos()
player_velocity = collector:get_player_velocity() player_velocity = collector:get_velocity() or collector:get_player_velocity()
pos2.y = pos2.y + 0.8 pos2.y = pos2.y + 0.8
direction = vector.direction(pos,pos2) direction = vector.direction(pos,pos2)
distance = vector.distance(pos2,pos) distance = vector.distance(pos2,pos)
multiplier = distance multiplier = distance
@ -332,7 +332,7 @@ local function xp_step(self, dtime)
goal = velocity goal = velocity
acceleration = vector.new(goal.x-currentvel.x,goal.y-currentvel.y,goal.z-currentvel.z) acceleration = vector.new(goal.x-currentvel.x,goal.y-currentvel.y,goal.z-currentvel.z)
self.object:add_velocity(vector.add(acceleration,player_velocity)) self.object:add_velocity(vector.add(acceleration,player_velocity))
elseif distance < 0.4 then elseif distance < 0.8 then
local xp = self._xp local xp = self._xp
local inv = collector:get_inventory() local inv = collector:get_inventory()
local candidates = { local candidates = {
@ -413,7 +413,7 @@ local function xp_step(self, dtime)
end end
end end
self.age = self.age + dtime self.age = self.age + dtime
if self.age > max_orb_age then if self.age > max_orb_age then
self.object:remove() self.object:remove()
@ -598,8 +598,8 @@ function mcl_experience.throw_experience(pos, amount)
return false return false
end end
obj:set_velocity({ obj:set_velocity({
x=math.random(-2,2)*math.random(), x=math.random(-2,2)*math.random(),
y=math.random(2,5), y=math.random(2,5),
z=math.random(-2,2)*math.random() z=math.random(-2,2)*math.random()
}) })
i = i + xp i = i + xp

View File

@ -92,7 +92,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
-- FIXME: Velocity threshold should be 0.01 but Minetest 5.3.0 -- FIXME: Velocity threshold should be 0.01 but Minetest 5.3.0
-- sometimes reports incorrect Y speed. A velocity threshold -- sometimes reports incorrect Y speed. A velocity threshold
-- of 0.125 still seems good enough. -- of 0.125 still seems good enough.
if vector.length(player:get_player_velocity()) > 0.125 then if vector.length(player:get_velocity() or 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

View File

@ -279,7 +279,7 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve
if weights[enchantment] >= r then if weights[enchantment] >= r then
selected_enchantment = enchantment selected_enchantment = enchantment
break break
end end
end end
local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] local enchantment_def = mcl_enchanting.enchantments[selected_enchantment]
local power_range_table = enchantment_def.power_range_table local power_range_table = enchantment_def.power_range_table
@ -340,7 +340,7 @@ end
function mcl_enchanting.get_random_glyph_row() function mcl_enchanting.get_random_glyph_row()
local glyphs = "" local glyphs = ""
local x = 1.3 local x = 1.3
for i = 1, 9 do for i = 1, 9 do
glyphs = glyphs .. "image[".. x .. ",0.1;0.5,0.5;mcl_enchanting_glyph_" .. math.random(18) .. ".png^[colorize:#675D49:255]" glyphs = glyphs .. "image[".. x .. ",0.1;0.5,0.5;mcl_enchanting_glyph_" .. math.random(18) .. ".png^[colorize:#675D49:255]"
x = x + 0.6 x = x + 0.6
end end
@ -560,7 +560,7 @@ end
function mcl_enchanting.set_book_animation(self, anim) function mcl_enchanting.set_book_animation(self, anim)
local anim_index = mcl_enchanting.book_animations[anim] local anim_index = mcl_enchanting.book_animations[anim]
local start, stop = mcl_enchanting.book_animation_steps[anim_index], mcl_enchanting.book_animation_steps[anim_index + 1] local start, stop = mcl_enchanting.book_animation_steps[anim_index], mcl_enchanting.book_animation_steps[anim_index + 1]
self.object:set_animation({x = start, y = stop}, mcl_enchanting.book_animation_speed) self.object:set_animation({x = start, y = stop}, mcl_enchanting.book_animation_speed, 0, mcl_enchanting.book_animation_loop[anim] or false)
self.scheduled_anim = nil self.scheduled_anim = nil
self.anim_length = (stop - start) / 40 self.anim_length = (stop - start) / 40
end end

View File

@ -5,6 +5,7 @@ mcl_enchanting = {
book_offset = vector.new(0, 0.75, 0), book_offset = vector.new(0, 0.75, 0),
book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4}, book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4},
book_animation_steps = {0, 640, 680, 700, 740}, book_animation_steps = {0, 640, 680, 700, 740},
book_animation_loop = {["open"] = true, ["close"] = true},
book_animation_speed = 40, book_animation_speed = 40,
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49 roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
enchantments = {}, enchantments = {},
@ -278,7 +279,7 @@ minetest.register_node("mcl_enchanting:table", {
drop = "", drop = "",
_mcl_blast_resistance = 1200, _mcl_blast_resistance = 1200,
_mcl_hardness = 5, _mcl_hardness = 5,
}) })
minetest.register_craft({ minetest.register_craft({
output = "mcl_enchanting:table", output = "mcl_enchanting:table",
@ -295,24 +296,42 @@ minetest.register_abm({
chance = 1, chance = 1,
nodenames = "mcl_enchanting:table", nodenames = "mcl_enchanting:table",
action = function(pos) action = function(pos)
local playernames = {}
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do
if obj:is_player() then
table.insert(playernames, obj:get_player_name())
end
end
if #playernames < 1 then
return
end
local absolute, relative = mcl_enchanting.get_bookshelves(pos) local absolute, relative = mcl_enchanting.get_bookshelves(pos)
for i, ap in ipairs(absolute) do for i, ap in ipairs(absolute) do
if math.random(10) == 1 then if math.random(5) == 1 then
local rp = relative[i] local rp = relative[i]
minetest.add_particle({ local t = math.random()+1 --time
pos = ap, local d = {x = rp.x, y=rp.y-0.7, z=rp.z} --distance
velocity = vector.subtract(vector.new(0, 5, 0), rp), local v = {x = -math.random()*d.x, y = math.random(), z = -math.random()*d.z} --velocity
acceleration = {x = 0, y = -9.81, z = 0}, local a = {x = 2*(-v.x*t - d.x)/t/t, y = 2*(-v.y*t - d.y)/t/t, z = 2*(-v.z*t - d.z)/t/t} --acceleration
expirationtime = 2, local s = math.random()+0.9 --size
size = 2, t = t - 0.1 --slightly decrease time to avoid texture overlappings
texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png", local tx = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
collision_detection = true, for _, name in pairs(playernames) do
collision_removal = true, minetest.add_particle({
}) pos = ap,
velocity = v,
acceleration = a,
expirationtime = t,
size = s,
texture = tx,
collisiondetection = false,
playername = name
})
end
end end
end end
end end
}) })
minetest.register_lbm({ minetest.register_lbm({
label = "(Re-)spawn book entity above enchanting table", label = "(Re-)spawn book entity above enchanting table",
@ -330,4 +349,4 @@ minetest.register_on_joinplayer(mcl_enchanting.initialize_player)
minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields) minetest.register_on_player_receive_fields(mcl_enchanting.handle_formspec_fields)
minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action) minetest.register_allow_player_inventory_action(mcl_enchanting.allow_inventory_action)
minetest.register_on_player_inventory_action(mcl_enchanting.on_inventory_action) minetest.register_on_player_inventory_action(mcl_enchanting.on_inventory_action)
table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet) table.insert(tt.registered_snippets, 1, mcl_enchanting.enchantments_snippet)

View File

@ -25,21 +25,31 @@ local bobber_ENTITY={
objtype="fishing", objtype="fishing",
} }
local fish = function(itemstack, player) local fish = function(itemstack, player, pointed_thing)
if pointed_thing and pointed_thing.type == "node" then
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if player and not player:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack
end
end
end
local pos = player:get_pos() local pos = player:get_pos()
local objs = minetest.get_objects_inside_radius(pos, 125) local objs = minetest.get_objects_inside_radius(pos, 125)
local num = 0 local num = 0
local ent = nil local ent = nil
local noent = true local noent = true
local durability = 65 local durability = 65
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
if unbreaking > 0 then if unbreaking > 0 then
durability = durability * (unbreaking + 1) durability = durability * (unbreaking + 1)
end end
--Check for bobber if so handle. --Check for bobber if so handle.
for n = 1, #objs do for n = 1, #objs do
ent = objs[n]:get_luaentity() ent = objs[n]:get_luaentity()
@ -253,7 +263,7 @@ local bobber_on_step = function(self, dtime)
-- wait for random number of ticks. -- wait for random number of ticks.
local lure_enchantment = wield and mcl_enchanting.get_enchantment(wield, "lure") or 0 local lure_enchantment = wield and mcl_enchanting.get_enchantment(wield, "lure") or 0
local reduced = lure_enchantment * 5 local reduced = lure_enchantment * 5
self._waittime = math.random(math.max(0, 5 - reduced), 30 - reduced) self._waittime = math.random(math.max(0, 5 - reduced), 30 - reduced)
else else
if self._time < self._waittime then if self._time < self._waittime then
self._time = self._time + dtime self._time = self._time + dtime

View File

@ -156,7 +156,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso
-- Special item definition field: _food_particles -- Special item definition field: _food_particles
-- If false, force item to not spawn any food partiles when eaten -- If false, force item to not spawn any food partiles when eaten
if def._food_particles ~= false and texture and texture ~= "" then if def._food_particles ~= false and texture and texture ~= "" then
local v = user:get_player_velocity() local v = user:get_velocity() or user:get_player_velocity()
local minvel = vector.add(v, {x=-1, y=1, z=-1}) local minvel = vector.add(v, {x=-1, y=1, z=-1})
local maxvel = vector.add(v, {x=1, y=2, z=1}) local maxvel = vector.add(v, {x=1, y=2, z=1})