forked from Mineclonia/Mineclonia
Merge branch 'master' into enchanted_books_creative
This commit is contained in:
commit
139a4d94d0
|
@ -313,7 +313,7 @@ local function xp_step(self, dtime)
|
|||
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
|
||||
|
||||
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = {},
|
||||
|
@ -295,23 +296,41 @@ 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]
|
||||
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 = 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,
|
||||
velocity = v,
|
||||
acceleration = a,
|
||||
expirationtime = t,
|
||||
size = s,
|
||||
texture = tx,
|
||||
collisiondetection = false,
|
||||
playername = name
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -25,7 +25,17 @@ 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)
|
||||
|
|
|
@ -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 New Issue