mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Merge branch 'master' into enchanted_books_creative
This commit is contained in:
commit
139a4d94d0
9 changed files with 64 additions and 35 deletions
|
@ -163,7 +163,7 @@ minetest.register_on_joinplayer(function(player)
|
|||
|
||||
name = player:get_player_name()
|
||||
temp_pool = pool[name]
|
||||
|
||||
|
||||
hud_manager.add_hud(player,"experience_bar",
|
||||
{
|
||||
hud_elem_type = "image",
|
||||
|
@ -175,7 +175,7 @@ minetest.register_on_joinplayer(function(player)
|
|||
alignment = { x = 1, y = 1 },
|
||||
z_index = 11,
|
||||
})
|
||||
|
||||
|
||||
hud_manager.add_hud(player,"xp_level",
|
||||
{
|
||||
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()
|
||||
temp_pool = pool[name]
|
||||
xp_amount = temp_pool.xp
|
||||
|
||||
|
||||
temp_pool.xp = 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)
|
||||
|
@ -312,11 +312,11 @@ local function xp_step(self, dtime)
|
|||
--get the variables
|
||||
pos = self.object: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
|
||||
|
||||
|
||||
direction = vector.direction(pos,pos2)
|
||||
distance = vector.distance(pos2,pos)
|
||||
multiplier = distance
|
||||
|
@ -332,7 +332,7 @@ local function xp_step(self, dtime)
|
|||
goal = velocity
|
||||
acceleration = vector.new(goal.x-currentvel.x,goal.y-currentvel.y,goal.z-currentvel.z)
|
||||
self.object:add_velocity(vector.add(acceleration,player_velocity))
|
||||
elseif distance < 0.4 then
|
||||
elseif distance < 0.8 then
|
||||
local xp = self._xp
|
||||
local inv = collector:get_inventory()
|
||||
local candidates = {
|
||||
|
@ -413,7 +413,7 @@ local function xp_step(self, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
self.age = self.age + dtime
|
||||
if self.age > max_orb_age then
|
||||
self.object:remove()
|
||||
|
@ -598,8 +598,8 @@ function mcl_experience.throw_experience(pos, amount)
|
|||
return false
|
||||
end
|
||||
obj:set_velocity({
|
||||
x=math.random(-2,2)*math.random(),
|
||||
y=math.random(2,5),
|
||||
x=math.random(-2,2)*math.random(),
|
||||
y=math.random(2,5),
|
||||
z=math.random(-2,2)*math.random()
|
||||
})
|
||||
i = i + xp
|
||||
|
|
|
@ -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
|
||||
-- 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
|
||||
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!"))
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -279,7 +279,7 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve
|
|||
if weights[enchantment] >= r then
|
||||
selected_enchantment = enchantment
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local enchantment_def = mcl_enchanting.enchantments[selected_enchantment]
|
||||
local power_range_table = enchantment_def.power_range_table
|
||||
|
@ -340,7 +340,7 @@ end
|
|||
function mcl_enchanting.get_random_glyph_row()
|
||||
local glyphs = ""
|
||||
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]"
|
||||
x = x + 0.6
|
||||
end
|
||||
|
@ -560,7 +560,7 @@ end
|
|||
function mcl_enchanting.set_book_animation(self, 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]
|
||||
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.anim_length = (stop - start) / 40
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ mcl_enchanting = {
|
|||
book_offset = vector.new(0, 0.75, 0),
|
||||
book_animations = {["close"] = 1, ["opening"] = 2, ["open"] = 3, ["closing"] = 4},
|
||||
book_animation_steps = {0, 640, 680, 700, 740},
|
||||
book_animation_loop = {["open"] = true, ["close"] = true},
|
||||
book_animation_speed = 40,
|
||||
roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49
|
||||
enchantments = {},
|
||||
|
@ -278,7 +279,7 @@ minetest.register_node("mcl_enchanting:table", {
|
|||
drop = "",
|
||||
_mcl_blast_resistance = 1200,
|
||||
_mcl_hardness = 5,
|
||||
})
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mcl_enchanting:table",
|
||||
|
@ -295,24 +296,42 @@ minetest.register_abm({
|
|||
chance = 1,
|
||||
nodenames = "mcl_enchanting:table",
|
||||
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)
|
||||
for i, ap in ipairs(absolute) do
|
||||
if math.random(10) == 1 then
|
||||
if math.random(5) == 1 then
|
||||
local rp = relative[i]
|
||||
minetest.add_particle({
|
||||
pos = ap,
|
||||
velocity = vector.subtract(vector.new(0, 5, 0), rp),
|
||||
acceleration = {x = 0, y = -9.81, z = 0},
|
||||
expirationtime = 2,
|
||||
size = 2,
|
||||
texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png",
|
||||
collision_detection = true,
|
||||
collision_removal = true,
|
||||
})
|
||||
local t = math.random()+1 --time
|
||||
local d = {x = rp.x, y=rp.y-0.7, z=rp.z} --distance
|
||||
local v = {x = -math.random()*d.x, y = math.random(), z = -math.random()*d.z} --velocity
|
||||
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
|
||||
local s = math.random()+0.9 --size
|
||||
t = t - 0.1 --slightly decrease time to avoid texture overlappings
|
||||
local tx = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
|
||||
for _, name in pairs(playernames) do
|
||||
minetest.add_particle({
|
||||
pos = ap,
|
||||
velocity = v,
|
||||
acceleration = a,
|
||||
expirationtime = t,
|
||||
size = s,
|
||||
texture = tx,
|
||||
collisiondetection = false,
|
||||
playername = name
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
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_allow_player_inventory_action(mcl_enchanting.allow_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)
|
||||
|
|
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.0.ogg
Normal file
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.0.ogg
Normal file
Binary file not shown.
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.1.ogg
Normal file
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.1.ogg
Normal file
Binary file not shown.
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.2.ogg
Normal file
BIN
mods/ITEMS/mcl_enchanting/sounds/mcl_enchanting_enchant.2.ogg
Normal file
Binary file not shown.
|
@ -25,21 +25,31 @@ local bobber_ENTITY={
|
|||
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 objs = minetest.get_objects_inside_radius(pos, 125)
|
||||
local num = 0
|
||||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
|
||||
|
||||
|
||||
local durability = 65
|
||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
if unbreaking > 0 then
|
||||
durability = durability * (unbreaking + 1)
|
||||
end
|
||||
|
||||
|
||||
--Check for bobber if so handle.
|
||||
for n = 1, #objs do
|
||||
ent = objs[n]:get_luaentity()
|
||||
|
@ -253,7 +263,7 @@ local bobber_on_step = function(self, dtime)
|
|||
-- wait for random number of ticks.
|
||||
local lure_enchantment = wield and mcl_enchanting.get_enchantment(wield, "lure") or 0
|
||||
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
|
||||
if self._time < self._waittime then
|
||||
self._time = self._time + dtime
|
||||
|
|
|
@ -156,7 +156,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso
|
|||
-- Special item definition field: _food_particles
|
||||
-- If false, force item to not spawn any food partiles when eaten
|
||||
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 maxvel = vector.add(v, {x=1, y=2, z=1})
|
||||
|
||||
|
|
Loading…
Reference in a new issue