forked from VoxeLibre/VoxeLibre
Merge branch 'master' into beds
This commit is contained in:
commit
c22c2063ad
|
@ -575,7 +575,7 @@ minetest.register_entity(":__builtin:item", {
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime, moveresult)
|
||||||
if self._removed then
|
if self._removed then
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
physical = false
|
physical = false
|
||||||
|
@ -642,6 +642,18 @@ minetest.register_entity(":__builtin:item", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Destroy item when it collides with a cactus
|
||||||
|
if moveresult and moveresult.collides then
|
||||||
|
for _, collision in pairs(moveresult.collisions) do
|
||||||
|
local pos = collision.node_pos
|
||||||
|
if collision.type == "node" and minetest.get_node(pos).name == "mcl_core:cactus" then
|
||||||
|
self._removed = true
|
||||||
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Push item out when stuck inside solid opaque node
|
-- Push item out when stuck inside solid opaque node
|
||||||
if def and def.walkable and def.groups and def.groups.opaque == 1 then
|
if def and def.walkable and def.groups and def.groups.opaque == 1 then
|
||||||
local shootdir
|
local shootdir
|
||||||
|
|
|
@ -233,4 +233,4 @@ mobs:spawn(spawn_grass)
|
||||||
mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0)
|
mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0)
|
||||||
|
|
||||||
-- Note: This spawn egg does not exist in Minecraft
|
-- Note: This spawn egg does not exist in Minecraft
|
||||||
mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit.png^[colorize:#FF0000:192", 0) -- TODO: Update inventory image
|
mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit_caerbannog.png", 0)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -168,6 +168,60 @@ local dispenserdef = {
|
||||||
end
|
end
|
||||||
|
|
||||||
inv:set_stack("main", stack_id, stack)
|
inv:set_stack("main", stack_id, stack)
|
||||||
|
|
||||||
|
-- Use shears on sheeps
|
||||||
|
elseif igroups.shears then
|
||||||
|
for _, obj in pairs(minetest.get_objects_inside_radius(droppos, 1)) do
|
||||||
|
local entity = obj:get_luaentity()
|
||||||
|
if entity and not entity.child and not entity.gotten then
|
||||||
|
local entname = entity.name
|
||||||
|
local pos = obj:get_pos()
|
||||||
|
local used, texture = false
|
||||||
|
if entname == "mobs_mc:sheep" then
|
||||||
|
minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3))
|
||||||
|
if not entity.color then
|
||||||
|
entity.color = "unicolor_white"
|
||||||
|
end
|
||||||
|
entity.base_texture = { "blank.png", "mobs_mc_sheep.png" }
|
||||||
|
texture = entity.base_texture
|
||||||
|
entity.drops = {
|
||||||
|
{ name = mobs_mc.items.mutton_raw, chance = 1, min = 1, max = 2 },
|
||||||
|
}
|
||||||
|
used = true
|
||||||
|
elseif entname == "mobs_mc:snowman" then
|
||||||
|
texture = {
|
||||||
|
"mobs_mc_snowman.png",
|
||||||
|
"blank.png", "blank.png",
|
||||||
|
"blank.png", "blank.png",
|
||||||
|
"blank.png", "blank.png",
|
||||||
|
}
|
||||||
|
used = true
|
||||||
|
elseif entname == "mobs_mc:mooshroom" then
|
||||||
|
local droppos = vector.offset(pos, 0, 1.4, 0)
|
||||||
|
if entity.base_texture[1] == "mobs_mc_mooshroom_brown.png" then
|
||||||
|
minetest.add_item(droppos, mobs_mc.items.mushroom_brown .. " 5")
|
||||||
|
else
|
||||||
|
minetest.add_item(droppos, mobs_mc.items.mushroom_red .. " 5")
|
||||||
|
end
|
||||||
|
local oldyaw = obj:get_yaw()
|
||||||
|
obj:remove()
|
||||||
|
local cow = minetest.add_entity(pos, "mobs_mc:cow")
|
||||||
|
cow:set_yaw(oldyaw)
|
||||||
|
obj = cow
|
||||||
|
entity = cow:get_luaentity()
|
||||||
|
used = true
|
||||||
|
end
|
||||||
|
if used then
|
||||||
|
obj:set_properties({ textures = texture })
|
||||||
|
entity.gotten = true
|
||||||
|
minetest.sound_play("mcl_tools_shears_cut", { pos = pos }, true)
|
||||||
|
stack:add_wear(65535 / stackdef._mcl_diggroups.shearsy.uses)
|
||||||
|
inv:set_stack("main", stack_id, stack)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Spawn Egg
|
-- Spawn Egg
|
||||||
elseif igroups.spawn_egg then
|
elseif igroups.spawn_egg then
|
||||||
-- Spawn mob
|
-- Spawn mob
|
||||||
|
|
|
@ -53,6 +53,15 @@ local function get_consumed_materials(tool, material)
|
||||||
return materials_used
|
return materials_used
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function contains(table, value)
|
||||||
|
for _, i in pairs(table) do
|
||||||
|
if i == value then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Given 2 input stacks, tells you which is the tool and which is the material.
|
-- Given 2 input stacks, tells you which is the tool and which is the material.
|
||||||
-- Returns ("tool", input1, input2) if input1 is tool and input2 is material.
|
-- Returns ("tool", input1, input2) if input1 is tool and input2 is material.
|
||||||
-- Returns ("material", input2, input1) if input1 is material and input2 is tool.
|
-- Returns ("material", input2, input1) if input1 is material and input2 is tool.
|
||||||
|
@ -60,9 +69,15 @@ end
|
||||||
local function distinguish_tool_and_material(input1, input2)
|
local function distinguish_tool_and_material(input1, input2)
|
||||||
local def1 = input1:get_definition()
|
local def1 = input1:get_definition()
|
||||||
local def2 = input2:get_definition()
|
local def2 = input2:get_definition()
|
||||||
if def1.type == "tool" and def1._repair_material then
|
local r1 = def1._repair_material
|
||||||
|
local r2 = def2._repair_material
|
||||||
|
if def1.type == "tool" and r1 and type(r1) == "table" and contains(r1, input2) then
|
||||||
return "tool", input1, input2
|
return "tool", input1, input2
|
||||||
elseif def2.type == "tool" and def2._repair_material then
|
elseif def2.type == "tool" and r2 and type(r2) == "table" and contains(r2, input1) then
|
||||||
|
return "material", input2, input1
|
||||||
|
elseif def1.type == "tool" and r1 then
|
||||||
|
return "tool", input1, input2
|
||||||
|
elseif def2.type == "tool" and r2 then
|
||||||
return "material", input2, input1
|
return "material", input2, input1
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
|
@ -121,11 +136,28 @@ local function update_anvil_slots(meta)
|
||||||
local distinguished, tool, material = distinguish_tool_and_material(input1, input2)
|
local distinguished, tool, material = distinguish_tool_and_material(input1, input2)
|
||||||
if distinguished then
|
if distinguished then
|
||||||
local tooldef = tool:get_definition()
|
local tooldef = tool:get_definition()
|
||||||
|
local repair = tooldef._repair_material
|
||||||
local has_correct_material = false
|
local has_correct_material = false
|
||||||
if string.sub(tooldef._repair_material, 1, 6) == "group:" then
|
local material_name = material:get_name()
|
||||||
has_correct_material = minetest.get_item_group(material:get_name(), string.sub(tooldef._repair_material, 7)) ~= 0
|
if type(repair) == "string" then
|
||||||
elseif material:get_name() == tooldef._repair_material then
|
if string.sub(repair, 1, 6) == "group:" then
|
||||||
has_correct_material = true
|
has_correct_material = minetest.get_item_group(material_name, string.sub(repair, 7)) ~= 0
|
||||||
|
elseif material_name == repair then
|
||||||
|
has_correct_material = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if contains(repair, material_name) then
|
||||||
|
has_correct_material = true
|
||||||
|
else
|
||||||
|
for _, r in pairs(repair) do
|
||||||
|
if string.sub(r, 1, 6) == "group:" then
|
||||||
|
if minetest.get_item_group(material_name, string.sub(r, 7)) ~= 0 then
|
||||||
|
has_correct_material = true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if has_correct_material and tool:get_wear() > 0 then
|
if has_correct_material and tool:get_wear() > 0 then
|
||||||
local materials_used = get_consumed_materials(tool, material)
|
local materials_used = get_consumed_materials(tool, material)
|
||||||
|
|
|
@ -184,6 +184,7 @@ minetest.register_abm({
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Cactus mechanisms
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label = "Cactus growth",
|
label = "Cactus growth",
|
||||||
nodenames = {"mcl_core:cactus"},
|
nodenames = {"mcl_core:cactus"},
|
||||||
|
@ -195,19 +196,31 @@ minetest.register_abm({
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Make cactus destroy items
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label = "Cactus destroy items",
|
label = "Cactus mechanisms",
|
||||||
nodenames = {"mcl_core:cactus"},
|
nodenames = {"mcl_core:cactus"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do
|
for _, object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do
|
||||||
local entity = object:get_luaentity()
|
local entity = object:get_luaentity()
|
||||||
if entity and entity.name == "__builtin:item" then
|
if entity and entity.name == "__builtin:item" then
|
||||||
object:remove()
|
object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
|
||||||
|
for _, p in pairs(posses) do
|
||||||
|
if minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name].walkable then
|
||||||
|
local posy = pos.y
|
||||||
|
while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do
|
||||||
|
local pos = vector.new(pos.x, posy, pos.z)
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus")
|
||||||
|
posy = posy + 1
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,3 @@ minetest.override_item("mcl_end:ender_eye", {
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
minetest.override_item("mcl_core:bedrock", {
|
|
||||||
after_destruct = destroy_portal,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue