forked from VoxeLibre/VoxeLibre
Compare commits
79 Commits
Author | SHA1 | Date |
---|---|---|
|
647a53c354 | |
|
910c9083e5 | |
|
66a64439c6 | |
|
7fe3217cd0 | |
|
01df02667b | |
|
03feb36558 | |
|
1f925b6c84 | |
|
9a4d26c2ae | |
|
2d1ac1c7fa | |
|
f0c2a0a1e9 | |
|
1fa2bd3477 | |
|
7f56e5efa4 | |
|
c1e295de5f | |
|
dac3c21628 | |
|
b0c7941b3a | |
|
0996a83ba0 | |
|
1621c23308 | |
|
1873080046 | |
|
46541a4adc | |
|
10154d5778 | |
|
c877d6e922 | |
|
12745bd450 | |
|
03be45b983 | |
|
34dbddb40a | |
|
b871433c47 | |
|
a40e1c4737 | |
|
df8fdda2c5 | |
|
249b5cfd1e | |
|
f5f85a2148 | |
|
d168bfa791 | |
|
c20bd768ec | |
|
67cedf1308 | |
|
9391628813 | |
|
327bb68927 | |
|
906aa3b434 | |
|
ecd27a4cdb | |
|
55df2a57f4 | |
|
4ff987ccc5 | |
|
f3c37f49b9 | |
|
f3580efced | |
|
4a53ba67ab | |
|
d02fc0c83d | |
|
e474ce6397 | |
|
b71566aad6 | |
|
4fbb95bed3 | |
|
2571c6124b | |
|
e61f1e38f2 | |
|
a482a18a67 | |
|
ed30fa0868 | |
|
8d473a42ca | |
|
0f2c487dca | |
|
dc41c594aa | |
|
bfe51316ee | |
|
13268965ee | |
|
521f96b4ab | |
|
c8b543991f | |
|
8f9650abe4 | |
|
4c46eb2b4b | |
|
fe770c19a5 | |
|
0112825a9f | |
|
cff0130506 | |
|
7b93f68ed8 | |
|
ece4c892f4 | |
|
bec1f786a6 | |
|
6458565bf9 | |
|
2e9b3c2259 | |
|
5193730652 | |
|
e77473e800 | |
|
922bdbc601 | |
|
3241dbbec5 | |
|
b47733507d | |
|
f0528b11d7 | |
|
503b3a8149 | |
|
5b5a254b1a | |
|
0c90dda04c | |
|
fa86d4e5eb | |
|
f8461d5e90 | |
|
fb6f5eae7a | |
|
558fa57cc6 |
4
API.md
4
API.md
|
@ -17,6 +17,10 @@ Items can have these fields:
|
|||
anvil.
|
||||
See `mcl_banners` for an example.
|
||||
|
||||
Tools can have these fields:
|
||||
* `_mcl_diggroups`: Specifies the digging groups that a tool can dig and how
|
||||
efficiently. See `_mcl_autogroup` for more information.
|
||||
|
||||
All nodes can have these fields:
|
||||
|
||||
* `_mcl_hardness`: Hardness of the block, ranges from 0 to infinity (represented by -1). Determines digging times. Default: 0
|
||||
|
|
|
@ -33,10 +33,10 @@ mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_de
|
|||
keepInventory = false
|
||||
|
||||
# Performance settings
|
||||
dedicated_server_step = 0.001
|
||||
abm_interval = 0.25
|
||||
max_objects_per_block = 4096
|
||||
max_packets_per_iteration = 10096
|
||||
# dedicated_server_step = 0.001
|
||||
# abm_interval = 0.25
|
||||
# max_objects_per_block = 4096
|
||||
# max_packets_per_iteration = 10096
|
||||
|
||||
# Clientmodding to support official client
|
||||
enable_client_modding = true
|
||||
|
|
|
@ -4,6 +4,11 @@ Specifically, this mod has 2 purposes:
|
|||
1) Automatically adding the group “solid” for blocks considered “solid” in Minecraft.
|
||||
2) Generating digging time group for all nodes based on node metadata (it's complicated)
|
||||
|
||||
This mod also requires another mod called “mcl_autogroup” to function properly.
|
||||
“mcl_autogroup” exposes the API used to register digging groups, while this mod
|
||||
uses those digging groups to set the digging time groups for all the nodes and
|
||||
tools.
|
||||
|
||||
See init.lua for more infos.
|
||||
|
||||
The leading underscore in the name “_mcl_autogroup” was added to force Minetest to load this mod as late as possible.
|
||||
|
|
|
@ -1,169 +1,358 @@
|
|||
--[[ Mining times. Yeah, mining times … Alright, this is going to be FUN!
|
||||
--[[
|
||||
This mod implements a HACK to make 100% sure the digging times of all tools
|
||||
match Minecraft's perfectly. The digging times system of Minetest is very
|
||||
different, so this weird group trickery has to be used. In Minecraft, each
|
||||
block has a hardness and the actual Minecraft digging time is determined by
|
||||
this:
|
||||
|
||||
This mod does include a HACK to make 100% sure the digging times of all tools match Minecraft's perfectly.
|
||||
The digging times system of Minetest is very different, so this weird group trickery has to be used.
|
||||
In Minecraft, each block has a hardness and the actual Minecraft digging time is determined by this:
|
||||
1) The block's hardness
|
||||
2) The tool being used
|
||||
3) Whether the tool is considered as “eligible” for the block
|
||||
2) The tool being used (the tool speed and its efficiency level)
|
||||
3) Whether the tool is considered as "eligible" for the block
|
||||
(e.g. only diamond pick eligible for obsidian)
|
||||
See Minecraft Wiki <http://minecraft.gamepedia.com/Minecraft_Wiki> for more information.
|
||||
|
||||
In MineClone 2, all diggable node have the hardness set in the custom field “_mcl_hardness” (0 by default).
|
||||
The nodes are also required to specify the “eligible” tools in groups like “pickaxey”, “shovely”, etc.
|
||||
This mod then calculates the real digging time based on the node meta data. The real digging times
|
||||
are then added into mcl_autogroup.digtimes where the table indices are group rating and the values are the
|
||||
digging times in seconds. These digging times can be then added verbatim into the tool definitions.
|
||||
See Minecraft Wiki <http://minecraft.gamepedia.com/Minecraft_Wiki> for more
|
||||
information.
|
||||
|
||||
Example:
|
||||
mcl_autogroup.digtimes.pickaxey_dig_diamond[1] = 0.2
|
||||
How the mod is used
|
||||
===================
|
||||
|
||||
→ This means that when a node has been assigned the group “pickaxey_dig_diamond=1”, it can be dug by the
|
||||
diamond pickaxe in 0.2 seconds.
|
||||
In MineClone 2, all diggable nodes have the hardness set in the custom field
|
||||
"_mcl_hardness" (0 by default). These values are used together with digging
|
||||
groups by this mod to create the correct digging times for nodes. Digging
|
||||
groups are registered using the following code:
|
||||
|
||||
mcl_autogroup.register_diggroup("shovely")
|
||||
mcl_autogroup.register_diggroup("pickaxey", {
|
||||
levels = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
})
|
||||
|
||||
The first line registers a simple digging group. The second line registers a
|
||||
digging group with 5 different levels (in this case one for each material of a
|
||||
pickaxes).
|
||||
|
||||
This strange setup with mcl_autogroup has been done to minimize the amount of required digging times
|
||||
a single tool needs to use. If this is not being done, the loading time will increase considerably
|
||||
(>10s).
|
||||
Nodes indicate that they belong to a particular digging group by being member of
|
||||
the digging group in their node definition. "mcl_core:dirt" for example has
|
||||
shovely=1 in its groups. If the digging group has multiple levels the value of
|
||||
the group indicates which digging level the node requires.
|
||||
"mcl_core:stone_with_gold" for example has pickaxey=4 because it requires a
|
||||
pickaxe of level 4 be mined.
|
||||
|
||||
]]
|
||||
For tools to be able to dig nodes of digging groups they need to use the have
|
||||
the custom field "_mcl_diggroups" function to get the groupcaps. The value of
|
||||
this field is a table which defines which groups the tool can dig and how
|
||||
efficiently.
|
||||
|
||||
local materials = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
local basegroups = { "pickaxey", "axey", "shovely" }
|
||||
local minigroups = { "handy", "shearsy", "swordy", "shearsy_wool", "swordy_cobweb" }
|
||||
local divisors = {
|
||||
["wood"] = 2,
|
||||
["gold"] = 12,
|
||||
["stone"] = 4,
|
||||
["iron"] = 6,
|
||||
["diamond"] = 8,
|
||||
["handy"] = 1,
|
||||
["shearsy"] = 15,
|
||||
["swordy"] = 1.5,
|
||||
["shearsy_wool"] = 5,
|
||||
["swordy_cobweb"] = 15,
|
||||
}
|
||||
local max_efficiency_level = 5
|
||||
_mcl_diggroups = {
|
||||
handy = { speed = 1, level = 1, uses = 0 },
|
||||
pickaxey = { speed = 1, level = 0, uses = 0 },
|
||||
}
|
||||
|
||||
mcl_autogroup = {}
|
||||
mcl_autogroup.digtimes = {}
|
||||
mcl_autogroup.creativetimes = {} -- Copy of digtimes, except that all values are 0. Used for creative mode
|
||||
The "uses" field indicate how many uses (0 for infinite) a tool has when used on
|
||||
the specified digging group. The "speed" field is a multiplier to the dig speed
|
||||
on that digging group.
|
||||
|
||||
for m=1, #materials do
|
||||
for g=1, #basegroups do
|
||||
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
mcl_autogroup.creativetimes[basegroups[g].."_dig_"..materials[m]] = {}
|
||||
for e=1, max_efficiency_level do
|
||||
mcl_autogroup.digtimes[basegroups[g].."_dig_"..materials[m].."_efficiency_"..e] = {}
|
||||
The "level" field indicates which levels of the group the tool can harvest. A
|
||||
level of 0 means that the tool cannot harvest blocks of that node. A level of 1
|
||||
or above means that the tool can harvest nodes with that level or below. See
|
||||
"mcl_tools/init.lua" for examples on how "_mcl_diggroups" is used in practice.
|
||||
|
||||
Information about the mod
|
||||
=========================
|
||||
|
||||
The mod is split up into two parts, mcl_autogroup and _mcl_autogroup.
|
||||
mcl_autogroup contains the API functions used to register custom digging groups.
|
||||
_mcl_autogroup contains most of the code. The leading underscore in the name
|
||||
"_mcl_autogroup" is used to force Minetest to load that part of the mod as late
|
||||
as possible. Minetest loads mods in reverse alphabetical order.
|
||||
|
||||
This also means that it is very important that no mod adds _mcl_autogroup as a
|
||||
dependency.
|
||||
--]]
|
||||
|
||||
assert(minetest.get_modpath("mcl_autogroup"), "This mod requires the mod mcl_autogroup to function")
|
||||
|
||||
-- Returns a table containing the unique "_mcl_hardness" for nodes belonging to
|
||||
-- each diggroup.
|
||||
local function get_hardness_values_for_groups()
|
||||
local maps = {}
|
||||
local values = {}
|
||||
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
||||
maps[g] = {}
|
||||
values[g] = {}
|
||||
end
|
||||
|
||||
for _, ndef in pairs(minetest.registered_nodes) do
|
||||
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
||||
if ndef.groups[g] ~= nil then
|
||||
maps[g][ndef._mcl_hardness or 0] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for g=1, #minigroups do
|
||||
mcl_autogroup.digtimes[minigroups[g].."_dig"] = {}
|
||||
mcl_autogroup.creativetimes[minigroups[g].."_dig"] = {}
|
||||
for e=1, max_efficiency_level do
|
||||
mcl_autogroup.digtimes[minigroups[g].."_dig_efficiency_"..e] = {}
|
||||
mcl_autogroup.creativetimes[minigroups[g].."_dig_efficiency_"..e] = {}
|
||||
|
||||
for g, map in pairs(maps) do
|
||||
for k, _ in pairs(map) do
|
||||
table.insert(values[g], k)
|
||||
end
|
||||
end
|
||||
|
||||
for g, _ in pairs(mcl_autogroup.registered_diggroups) do
|
||||
table.sort(values[g])
|
||||
end
|
||||
return values
|
||||
end
|
||||
|
||||
-- Returns a table containing a table indexed by "_mcl_hardness_value" to get
|
||||
-- its index in the list of unique hardnesses for each diggroup.
|
||||
local function get_hardness_lookup_for_groups(hardness_values)
|
||||
local map = {}
|
||||
for g, values in pairs(hardness_values) do
|
||||
map[g] = {}
|
||||
for k, v in pairs(values) do
|
||||
map[g][v] = k
|
||||
end
|
||||
end
|
||||
return map
|
||||
end
|
||||
|
||||
-- Array of unique hardness values for each group which affects dig time.
|
||||
local hardness_values = get_hardness_values_for_groups()
|
||||
|
||||
-- Map indexed by hardness values which return the index of that value in
|
||||
-- hardness_value. Used for quick lookup.
|
||||
local hardness_lookup = get_hardness_lookup_for_groups(hardness_values)
|
||||
|
||||
local function compute_creativetimes(group)
|
||||
local creativetimes = {}
|
||||
|
||||
for index, hardness in pairs(hardness_values[group]) do
|
||||
table.insert(creativetimes, 0)
|
||||
end
|
||||
|
||||
return creativetimes
|
||||
end
|
||||
|
||||
-- Get the list of digging times for using a specific tool on a specific
|
||||
-- diggroup.
|
||||
--
|
||||
-- Parameters:
|
||||
-- group - the group which it is digging
|
||||
-- can_harvest - if the tool can harvest the block
|
||||
-- speed - dig speed multiplier for tool (default 1)
|
||||
-- efficiency - efficiency level for the tool if applicable
|
||||
local function get_digtimes(group, can_harvest, speed, efficiency)
|
||||
local speed = speed or 1
|
||||
if efficiency then
|
||||
speed = speed + efficiency * efficiency + 1
|
||||
end
|
||||
|
||||
local digtimes = {}
|
||||
|
||||
for index, hardness in pairs(hardness_values[group]) do
|
||||
local digtime = (hardness or 0) / speed
|
||||
if can_harvest then
|
||||
digtime = digtime * 1.5
|
||||
else
|
||||
digtime = digtime * 5
|
||||
end
|
||||
|
||||
if digtime <= 0.05 then
|
||||
digtime = 0
|
||||
else
|
||||
digtime = math.ceil(digtime * 20) / 20
|
||||
end
|
||||
table.insert(digtimes, digtime)
|
||||
end
|
||||
|
||||
return digtimes
|
||||
end
|
||||
|
||||
-- Get one groupcap field for using a specific tool on a specific group.
|
||||
local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
||||
return {
|
||||
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
||||
uses = uses,
|
||||
maxlevel = 0,
|
||||
}
|
||||
end
|
||||
|
||||
-- Add the groupcaps from a field in "_mcl_diggroups" to the groupcaps of a
|
||||
-- tool.
|
||||
local function add_groupcaps(toolname, groupcaps, groupcaps_def, efficiency)
|
||||
for g, capsdef in pairs(groupcaps_def) do
|
||||
local mult = capsdef.speed or 1
|
||||
local uses = capsdef.uses
|
||||
local def = mcl_autogroup.registered_diggroups[g]
|
||||
local max_level = def.levels and #def.levels or 1
|
||||
|
||||
assert(capsdef.level, toolname .. ' is missing level for ' .. g)
|
||||
local level = math.min(capsdef.level, max_level)
|
||||
|
||||
if def.levels then
|
||||
groupcaps[g .. "_dig_default"] = get_groupcap(g, false, mult, efficiency, uses)
|
||||
if level > 0 then
|
||||
groupcaps[g .. "_dig_" .. def.levels[level]] = get_groupcap(g, true, mult, efficiency, uses)
|
||||
end
|
||||
else
|
||||
groupcaps[g .. "_dig"] = get_groupcap(g, level > 0, mult, efficiency, uses)
|
||||
end
|
||||
end
|
||||
return groupcaps
|
||||
end
|
||||
|
||||
-- Checks if the given node would drop its useful drop if dug by a given tool.
|
||||
-- Returns true if it will yield its useful drop, false otherwise.
|
||||
function mcl_autogroup.can_harvest(nodename, toolname)
|
||||
local ndef = minetest.registered_nodes[nodename]
|
||||
|
||||
if minetest.get_item_group(nodename, "dig_immediate") >= 2 then
|
||||
return true
|
||||
end
|
||||
|
||||
-- Check if it can be dug by tool
|
||||
local tdef = minetest.registered_tools[toolname]
|
||||
if tdef and tdef._mcl_diggroups then
|
||||
for g, gdef in pairs(tdef._mcl_diggroups) do
|
||||
if ndef.groups[g] then
|
||||
if ndef.groups[g] <= gdef.level then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if it can be dug by hand
|
||||
local tdef = minetest.registered_tools[""]
|
||||
if tdef then
|
||||
for g, gdef in pairs(tdef._mcl_diggroups) do
|
||||
if ndef.groups[g] then
|
||||
if ndef.groups[g] <= gdef.level then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- Get one groupcap field for using a specific tool on a specific group.
|
||||
local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
||||
return {
|
||||
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
||||
uses = uses,
|
||||
maxlevel = 0,
|
||||
}
|
||||
end
|
||||
|
||||
-- Returns the tool_capabilities from a tool definition or a default set of
|
||||
-- tool_capabilities
|
||||
local function get_tool_capabilities(tdef)
|
||||
if tdef.tool_capabilities then
|
||||
return tdef.tool_capabilities
|
||||
end
|
||||
|
||||
-- If the damage group and punch interval from hand is not included,
|
||||
-- then the user will not be able to attack with the tool.
|
||||
local hand_toolcaps = minetest.registered_tools[""].tool_capabilities
|
||||
return {
|
||||
full_punch_interval = hand_toolcaps.full_punch_interval,
|
||||
damage_groups = hand_toolcaps.damage_groups
|
||||
}
|
||||
end
|
||||
|
||||
-- Get the groupcaps for a tool. This function returns "groupcaps" table of
|
||||
-- digging which should be put in the "tool_capabilities" of the tool definition
|
||||
-- or in the metadata of an enchanted tool.
|
||||
--
|
||||
-- Parameters:
|
||||
-- toolname - Name of the tool being enchanted (like "mcl_tools:diamond_pickaxe")
|
||||
-- efficiency - The efficiency level the tool is enchanted with (default 0)
|
||||
--
|
||||
-- NOTE:
|
||||
-- This function can only be called after mod initialization. Otherwise a mod
|
||||
-- would have to add _mcl_autogroup as a dependency which would break the mod
|
||||
-- loading order.
|
||||
function mcl_autogroup.get_groupcaps(toolname, efficiency)
|
||||
local tdef = minetest.registered_tools[toolname]
|
||||
local groupcaps = table.copy(get_tool_capabilities(tdef).groupcaps or {})
|
||||
add_groupcaps(toolname, groupcaps, tdef._mcl_diggroups, efficiency)
|
||||
return groupcaps
|
||||
end
|
||||
|
||||
-- Get the wear from using a tool on a digging group.
|
||||
--
|
||||
-- Parameters
|
||||
-- toolname - Name of the tool used
|
||||
-- diggroup - The name of the diggroup the tool is used on
|
||||
--
|
||||
-- NOTE:
|
||||
-- This function can only be called after mod initialization. Otherwise a mod
|
||||
-- would have to add _mcl_autogroup as a dependency which would break the mod
|
||||
-- loading order.
|
||||
function mcl_autogroup.get_wear(toolname, diggroup)
|
||||
local tdef = minetest.registered_tools[toolname]
|
||||
local uses = tdef._mcl_diggroups[diggroup].uses
|
||||
return math.ceil(65535 / uses)
|
||||
end
|
||||
|
||||
local overwrite = function()
|
||||
for nname, ndef in pairs(minetest.registered_nodes) do
|
||||
local groups_changed = false
|
||||
local newgroups = table.copy(ndef.groups)
|
||||
if (nname ~= "ignore" and ndef.diggable) then
|
||||
-- Automatically assign the “solid” group for solid nodes
|
||||
-- Automatically assign the "solid" group for solid nodes
|
||||
if (ndef.walkable == nil or ndef.walkable == true)
|
||||
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
||||
and (ndef.node_box == nil or ndef.node_box.type == "regular")
|
||||
and (ndef.groups.not_solid == 0 or ndef.groups.not_solid == nil) then
|
||||
newgroups.solid = 1
|
||||
groups_changed = true
|
||||
end
|
||||
-- Automatically assign the “opaque” group for opaque nodes
|
||||
-- Automatically assign the "opaque" group for opaque nodes
|
||||
if (not (ndef.paramtype == "light" or ndef.sunlight_propagates)) and
|
||||
(ndef.groups.not_opaque == 0 or ndef.groups.not_opaque == nil) then
|
||||
newgroups.opaque = 1
|
||||
groups_changed = true
|
||||
end
|
||||
|
||||
local function calculate_group(hardness, material, diggroup, newgroups, actual_rating, expected_rating, efficiency)
|
||||
local time, validity_factor
|
||||
if actual_rating >= expected_rating then
|
||||
-- Valid tool
|
||||
validity_factor = 1.5
|
||||
else
|
||||
-- Wrong tool (higher digging time)
|
||||
validity_factor = 5
|
||||
end
|
||||
local speed_multiplier = divisors[material]
|
||||
if efficiency then
|
||||
speed_multiplier = speed_multiplier + efficiency * efficiency + 1
|
||||
end
|
||||
time = (hardness * validity_factor) / speed_multiplier
|
||||
if time <= 0.05 then
|
||||
time = 0
|
||||
else
|
||||
time = math.ceil(time * 20) / 20
|
||||
end
|
||||
table.insert(mcl_autogroup.digtimes[diggroup], time)
|
||||
if not efficiency then
|
||||
table.insert(mcl_autogroup.creativetimes[diggroup], 0)
|
||||
end
|
||||
newgroups[diggroup] = #mcl_autogroup.digtimes[diggroup]
|
||||
return newgroups
|
||||
end
|
||||
local creative_breakable = false
|
||||
|
||||
-- Hack in digging times
|
||||
local hardness = ndef._mcl_hardness
|
||||
if not hardness then
|
||||
hardness = 0
|
||||
end
|
||||
-- Assign groups used for digging this node depending on
|
||||
-- the registered digging groups
|
||||
for g, gdef in pairs(mcl_autogroup.registered_diggroups) do
|
||||
creative_breakable = true
|
||||
local index = hardness_lookup[g][ndef._mcl_hardness or 0]
|
||||
if ndef.groups[g] then
|
||||
if gdef.levels then
|
||||
newgroups[g .. "_dig_default"] = index
|
||||
|
||||
-- Handle pickaxey, axey and shovely
|
||||
for _, basegroup in pairs(basegroups) do
|
||||
if (hardness ~= -1 and ndef.groups[basegroup]) then
|
||||
for g=1,#materials do
|
||||
local diggroup = basegroup.."_dig_"..materials[g]
|
||||
newgroups = calculate_group(hardness, materials[g], diggroup, newgroups, g, ndef.groups[basegroup])
|
||||
for e=1,max_efficiency_level do
|
||||
newgroups = calculate_group(hardness, materials[g], diggroup .. "_efficiency_" .. e, newgroups, g, ndef.groups[basegroup], e)
|
||||
for i = ndef.groups[g], #gdef.levels do
|
||||
newgroups[g .. "_dig_" .. gdef.levels[i]] = index
|
||||
end
|
||||
groups_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
for m=1, #minigroups do
|
||||
local minigroup = minigroups[m]
|
||||
if hardness ~= -1 then
|
||||
local diggroup = minigroup.."_dig"
|
||||
-- actual rating
|
||||
local ar = ndef.groups[minigroup]
|
||||
if ar == nil then
|
||||
ar = 0
|
||||
end
|
||||
if (minigroup == "handy")
|
||||
or
|
||||
(ndef.groups.shearsy_wool and minigroup == "shearsy_wool" and ndef.groups.wool)
|
||||
or
|
||||
(ndef.groups.swordy_cobweb and minigroup == "swordy_cobweb" and nname == "mcl_core:cobweb")
|
||||
or
|
||||
(ndef.groups[minigroup] and minigroup ~= "swordy_cobweb" and minigroup ~= "shearsy_wool") then
|
||||
newgroups = calculate_group(hardness, minigroup, diggroup, newgroups, ar, 1)
|
||||
for e=1,max_efficiency_level do
|
||||
newgroups = calculate_group(hardness, minigroup, diggroup .. "_efficiency_" .. e, newgroups, ar, 1, e)
|
||||
end
|
||||
groups_changed = true
|
||||
else
|
||||
newgroups[g .. "_dig"] = index
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if groups_changed then
|
||||
minetest.override_item(nname, {
|
||||
groups = newgroups
|
||||
})
|
||||
end
|
||||
-- Automatically assign the node to the
|
||||
-- creative_breakable group if it belongs to any digging
|
||||
-- group.
|
||||
newgroups["creative_breakable"] = 1
|
||||
|
||||
minetest.override_item(nname, {
|
||||
groups = newgroups
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
for tname, tdef in pairs(minetest.registered_tools) do
|
||||
-- Assign groupcaps for digging the registered digging groups
|
||||
-- depending on the _mcl_diggroups in the tool definition
|
||||
if tdef._mcl_diggroups then
|
||||
local toolcaps = table.copy(get_tool_capabilities(tdef))
|
||||
toolcaps.groupcaps = mcl_autogroup.get_groupcaps(tname)
|
||||
|
||||
minetest.override_item(tname, {
|
||||
tool_capabilities = toolcaps
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
name = _mcl_autogroup
|
||||
author = Wuzzy
|
||||
author = ryvnf
|
||||
description = MineClone 2 core mod which automatically adds groups to all items. Very important for digging times.
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
--[[
|
||||
This is one part of a mod to replicate the digging times from Minecraft. This
|
||||
part only exposes a function to register digging groups. The rest of the mod is
|
||||
implemented and documented in the _mcl_autogroup.
|
||||
|
||||
The mod is split up into two parts, mcl_autogroup and _mcl_autogroup.
|
||||
mcl_autogroup contains the API functions used to register custom digging groups.
|
||||
_mcl_autogroup contains most of the code. The leading underscore in the name
|
||||
"_mcl_autogroup" is used to force Minetest to load that part of the mod as late
|
||||
as possible. Minetest loads mods in reverse alphabetical order.
|
||||
--]]
|
||||
mcl_autogroup = {}
|
||||
mcl_autogroup.registered_diggroups = {}
|
||||
|
||||
assert(minetest.get_modpath("_mcl_autogroup"), "This mod requires the mod _mcl_autogroup to function")
|
||||
|
||||
-- Register a group as a digging group.
|
||||
--
|
||||
-- Parameters:
|
||||
-- group - Name of the group to register as a digging group
|
||||
-- def - Table with information about the diggroup (defaults to {} if unspecified)
|
||||
--
|
||||
-- Values in def:
|
||||
-- level - If specified it is an array containing the names of the different
|
||||
-- digging levels the digging group supports.
|
||||
function mcl_autogroup.register_diggroup(group, def)
|
||||
mcl_autogroup.registered_diggroups[group] = def or {}
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
name = mcl_autogroup
|
||||
author = ryvnf
|
||||
description = MineClone 2 core mod which automatically adds groups to all items. Very important for digging times.
|
|
@ -33,25 +33,26 @@ mcl_vars.MAP_BLOCKSIZE = math.max(1, core.MAP_BLOCKSIZE or 16)
|
|||
mcl_vars.mapgen_limit = math.max(1, tonumber(minetest.get_mapgen_setting("mapgen_limit")) or 31000)
|
||||
mcl_vars.MAX_MAP_GENERATION_LIMIT = math.max(1, core.MAX_MAP_GENERATION_LIMIT or 31000)
|
||||
local central_chunk_offset = -math.floor(mcl_vars.chunksize / 2)
|
||||
local chunk_size_in_nodes = mcl_vars.chunksize * mcl_vars.MAP_BLOCKSIZE
|
||||
mcl_vars.central_chunk_offset_in_nodes = central_chunk_offset * mcl_vars.MAP_BLOCKSIZE
|
||||
mcl_vars.chunk_size_in_nodes = mcl_vars.chunksize * mcl_vars.MAP_BLOCKSIZE
|
||||
local central_chunk_min_pos = central_chunk_offset * mcl_vars.MAP_BLOCKSIZE
|
||||
local central_chunk_max_pos = central_chunk_min_pos + chunk_size_in_nodes - 1
|
||||
local central_chunk_max_pos = central_chunk_min_pos + mcl_vars.chunk_size_in_nodes - 1
|
||||
local ccfmin = central_chunk_min_pos - mcl_vars.MAP_BLOCKSIZE -- Fullminp/fullmaxp of central chunk, in nodes
|
||||
local ccfmax = central_chunk_max_pos + mcl_vars.MAP_BLOCKSIZE
|
||||
local mapgen_limit_b = math.floor(math.min(mcl_vars.mapgen_limit, mcl_vars.MAX_MAP_GENERATION_LIMIT) / mcl_vars.MAP_BLOCKSIZE)
|
||||
local mapgen_limit_min = -mapgen_limit_b * mcl_vars.MAP_BLOCKSIZE
|
||||
local mapgen_limit_max = (mapgen_limit_b + 1) * mcl_vars.MAP_BLOCKSIZE - 1
|
||||
local numcmin = math.max(math.floor((ccfmin - mapgen_limit_min) / chunk_size_in_nodes), 0) -- Number of complete chunks from central chunk
|
||||
local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / chunk_size_in_nodes), 0) -- fullminp/fullmaxp to effective mapgen limits.
|
||||
mcl_vars.mapgen_edge_min = central_chunk_min_pos - numcmin * chunk_size_in_nodes
|
||||
mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * chunk_size_in_nodes
|
||||
local numcmin = math.max(math.floor((ccfmin - mapgen_limit_min) / mcl_vars.chunk_size_in_nodes), 0) -- Number of complete chunks from central chunk
|
||||
local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / mcl_vars.chunk_size_in_nodes), 0) -- fullminp/fullmaxp to effective mapgen limits.
|
||||
mcl_vars.mapgen_edge_min = central_chunk_min_pos - numcmin * mcl_vars.chunk_size_in_nodes
|
||||
mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * mcl_vars.chunk_size_in_nodes
|
||||
|
||||
local function coordinate_to_block(x)
|
||||
return math.floor(x / mcl_vars.MAP_BLOCKSIZE)
|
||||
end
|
||||
|
||||
local function coordinate_to_chunk(x)
|
||||
return math.floor((coordinate_to_block(x) + central_chunk_offset) / mcl_vars.chunksize)
|
||||
return math.floor((coordinate_to_block(x) - central_chunk_offset) / mcl_vars.chunksize)
|
||||
end
|
||||
|
||||
function mcl_vars.pos_to_block(pos)
|
||||
|
@ -70,7 +71,7 @@ function mcl_vars.pos_to_chunk(pos)
|
|||
}
|
||||
end
|
||||
|
||||
local k_positive = math.ceil(mcl_vars.MAX_MAP_GENERATION_LIMIT / chunk_size_in_nodes)
|
||||
local k_positive = math.ceil(mcl_vars.MAX_MAP_GENERATION_LIMIT / mcl_vars.chunk_size_in_nodes)
|
||||
local k_positive_z = k_positive * 2
|
||||
local k_positive_y = k_positive_z * k_positive_z
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ mcl_worlds = {}
|
|||
function mcl_worlds.is_in_void(pos)
|
||||
local void =
|
||||
not ((pos.y < mcl_vars.mg_overworld_max and pos.y > mcl_vars.mg_overworld_min) or
|
||||
(pos.y < mcl_vars.mg_nether_max and pos.y > mcl_vars.mg_nether_min) or
|
||||
(pos.y < mcl_vars.mg_nether_max+128 and pos.y > mcl_vars.mg_nether_min) or
|
||||
(pos.y < mcl_vars.mg_end_max and pos.y > mcl_vars.mg_end_min))
|
||||
|
||||
local void_deadly = false
|
||||
|
@ -15,11 +15,11 @@ function mcl_worlds.is_in_void(pos)
|
|||
-- Overworld → Void → End → Void → Nether → Void
|
||||
if pos.y < mcl_vars.mg_overworld_min and pos.y > mcl_vars.mg_end_max then
|
||||
void_deadly = pos.y < mcl_vars.mg_overworld_min - deadly_tolerance
|
||||
elseif pos.y < mcl_vars.mg_end_min and pos.y > mcl_vars.mg_nether_max then
|
||||
elseif pos.y < mcl_vars.mg_end_min and pos.y > mcl_vars.mg_nether_max+128 then
|
||||
-- The void between End and Nether. Like usual, but here, the void
|
||||
-- *above* the Nether also has a small tolerance area, so player
|
||||
-- can fly above the Nether without getting hurt instantly.
|
||||
void_deadly = (pos.y < mcl_vars.mg_end_min - deadly_tolerance) and (pos.y > mcl_vars.mg_nether_max + deadly_tolerance)
|
||||
void_deadly = (pos.y < mcl_vars.mg_end_min - deadly_tolerance) and (pos.y > mcl_vars.mg_nether_max+128 + deadly_tolerance)
|
||||
elseif pos.y < mcl_vars.mg_nether_min then
|
||||
void_deadly = pos.y < mcl_vars.mg_nether_min - deadly_tolerance
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ end
|
|||
function mcl_worlds.y_to_layer(y)
|
||||
if y >= mcl_vars.mg_overworld_min then
|
||||
return y - mcl_vars.mg_overworld_min, "overworld"
|
||||
elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max then
|
||||
elseif y >= mcl_vars.mg_nether_min and y <= mcl_vars.mg_nether_max+128 then
|
||||
return y - mcl_vars.mg_nether_min, "nether"
|
||||
elseif y >= mcl_vars.mg_end_min and y <= mcl_vars.mg_end_max then
|
||||
return y - mcl_vars.mg_end_min, "end"
|
||||
|
@ -73,7 +73,7 @@ end
|
|||
-- Takes a position and returns true if this position can have Nether dust
|
||||
function mcl_worlds.has_dust(pos)
|
||||
-- Weather in the Overworld and the high part of the void below
|
||||
return pos.y <= mcl_vars.mg_nether_max + 64 and pos.y >= mcl_vars.mg_nether_min - 64
|
||||
return pos.y <= mcl_vars.mg_nether_max + 138 and pos.y >= mcl_vars.mg_nether_min - 10
|
||||
end
|
||||
|
||||
-- Takes a position (pos) and returns true if compasses are working here
|
||||
|
|
|
@ -117,6 +117,10 @@ function mcl_burning.damage(obj)
|
|||
end
|
||||
|
||||
function mcl_burning.set_on_fire(obj, burn_time, reason)
|
||||
if obj:get_hp() < 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local luaentity = obj:get_luaentity()
|
||||
if luaentity and luaentity.fire_resistant then
|
||||
return
|
||||
|
@ -145,7 +149,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
|||
end
|
||||
|
||||
if old_burn_time <= burn_time then
|
||||
local sound_id = mcl_burning.get(obj, "int", "sound_id")
|
||||
--[[local sound_id = mcl_burning.get(obj, "int", "sound_id")
|
||||
if sound_id == 0 then
|
||||
sound_id = minetest.sound_play("fire_fire", {
|
||||
object = obj,
|
||||
|
@ -153,7 +157,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
|||
max_hear_distance = 16,
|
||||
loop = true,
|
||||
}) + 1
|
||||
end
|
||||
end]]--
|
||||
|
||||
local hud_id
|
||||
if obj:is_player() then
|
||||
|
@ -163,7 +167,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
|||
hud_elem_type = "image",
|
||||
position = {x = 0.5, y = 0.5},
|
||||
scale = {x = -100, y = -100},
|
||||
text = "fire_basic_flame.png",
|
||||
text = "mcl_burning_hud_flame_animated.png",
|
||||
z_index = 1000,
|
||||
}) + 1
|
||||
end
|
||||
|
@ -171,7 +175,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason)
|
|||
mcl_burning.set(obj, "float", "burn_time", burn_time)
|
||||
mcl_burning.set(obj, "string", "reason", reason)
|
||||
mcl_burning.set(obj, "int", "hud_id", hud_id)
|
||||
mcl_burning.set(obj, "int", "sound_id", sound_id)
|
||||
--mcl_burning.set(obj, "int", "sound_id", sound_id)
|
||||
|
||||
local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire")
|
||||
local minp, maxp = mcl_burning.get_collisionbox(obj)
|
||||
|
@ -194,8 +198,8 @@ end
|
|||
|
||||
function mcl_burning.extinguish(obj)
|
||||
if mcl_burning.is_burning(obj) then
|
||||
local sound_id = mcl_burning.get(obj, "int", "sound_id") - 1
|
||||
minetest.sound_stop(sound_id)
|
||||
--local sound_id = mcl_burning.get(obj, "int", "sound_id") - 1
|
||||
--minetest.sound_stop(sound_id)
|
||||
|
||||
if obj:is_player() then
|
||||
local hud_id = mcl_burning.get(obj, "int", "hud_id") - 1
|
||||
|
@ -206,7 +210,7 @@ function mcl_burning.extinguish(obj)
|
|||
mcl_burning.set(obj, "float", "burn_time")
|
||||
mcl_burning.set(obj, "float", "damage_timer")
|
||||
mcl_burning.set(obj, "int", "hud_id")
|
||||
mcl_burning.set(obj, "int", "sound_id")
|
||||
--mcl_burning.set(obj, "int", "sound_id")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -165,66 +165,6 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end)
|
||||
|
||||
local minigroups = { "shearsy", "swordy", "shearsy_wool", "swordy_cobweb" }
|
||||
local basegroups = { "pickaxey", "axey", "shovely" }
|
||||
local materials = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
|
||||
-- Checks if the given node would drop its useful drop if dug by a tool
|
||||
-- with the given tool capabilities. Returns true if it will yield its useful
|
||||
-- drop, false otherwise.
|
||||
local check_can_drop = function(node_name, tool_capabilities)
|
||||
local handy = minetest.get_item_group(node_name, "handy")
|
||||
local dig_immediate = minetest.get_item_group(node_name, "dig_immediate")
|
||||
if handy == 1 or dig_immediate == 2 or dig_immediate == 3 then
|
||||
return true
|
||||
else
|
||||
local toolgroupcaps
|
||||
if tool_capabilities then
|
||||
toolgroupcaps = tool_capabilities.groupcaps
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
-- Compare node groups with tool capabilities
|
||||
for m=1, #minigroups do
|
||||
local minigroup = minigroups[m]
|
||||
local g = minetest.get_item_group(node_name, minigroup)
|
||||
if g ~= 0 then
|
||||
local plus = minigroup .. "_dig"
|
||||
if toolgroupcaps[plus] then
|
||||
return true
|
||||
end
|
||||
for e=1,5 do
|
||||
local effplus = plus .. "_efficiency_" .. e
|
||||
if toolgroupcaps[effplus] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for b=1, #basegroups do
|
||||
local basegroup = basegroups[b]
|
||||
local g = minetest.get_item_group(node_name, basegroup)
|
||||
if g ~= 0 then
|
||||
for m=g, #materials do
|
||||
local plus = basegroup .. "_dig_"..materials[m]
|
||||
if toolgroupcaps[plus] then
|
||||
return true
|
||||
end
|
||||
for e=1,5 do
|
||||
local effplus = plus .. "_efficiency_" .. e
|
||||
if toolgroupcaps[effplus] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Stupid workaround to get drops from a drop table:
|
||||
-- Create a temporary table in minetest.registered_nodes that contains the proper drops,
|
||||
-- because unfortunately minetest.get_node_drops needs the drop table to be inside a registered node definition
|
||||
|
@ -281,17 +221,20 @@ function minetest.handle_node_drops(pos, drops, digger)
|
|||
|
||||
-- Check if node will yield its useful drop by the digger's tool
|
||||
local dug_node = minetest.get_node(pos)
|
||||
local toolcaps
|
||||
local tooldef
|
||||
local tool
|
||||
if digger ~= nil then
|
||||
tool = digger:get_wielded_item()
|
||||
toolcaps = tool:get_tool_capabilities()
|
||||
tooldef = minetest.registered_tools[tool:get_name()]
|
||||
|
||||
if not check_can_drop(dug_node.name, toolcaps) then
|
||||
if not mcl_autogroup.can_harvest(dug_node.name, tool:get_name()) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local diggroups = tooldef and tooldef._mcl_diggroups
|
||||
local shearsy_level = diggroups and diggroups.shearsy and diggroups.shearsy.level
|
||||
|
||||
--[[ Special node drops when dug by shears by reading _mcl_shears_drop or with a silk touch tool reading _mcl_silk_touch_drop
|
||||
from the node definition.
|
||||
Definition of _mcl_shears_drop / _mcl_silk_touch_drop:
|
||||
|
@ -303,7 +246,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
|||
|
||||
local silk_touch_drop = false
|
||||
local nodedef = minetest.registered_nodes[dug_node.name]
|
||||
if toolcaps ~= nil and toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
|
||||
if shearsy_level and shearsy_level > 0 and nodedef._mcl_shears_drop then
|
||||
if nodedef._mcl_shears_drop == true then
|
||||
drops = { dug_node.name }
|
||||
else
|
||||
|
|
|
@ -2826,7 +2826,7 @@ local falling = function(self, pos)
|
|||
end
|
||||
|
||||
if mcl_portals ~= nil then
|
||||
if mcl_portals.nether_portal_cooloff[self.object] then
|
||||
if mcl_portals.nether_portal_cooloff(self.object) then
|
||||
return false -- mob has teleported through Nether portal - it's 99% not falling
|
||||
end
|
||||
end
|
||||
|
@ -2856,6 +2856,18 @@ local falling = function(self, pos)
|
|||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||
end
|
||||
|
||||
if minetest.registered_nodes[node_ok(pos).name].groups.lava then
|
||||
|
||||
if self.floats_on_lava == 1 then
|
||||
|
||||
self.object:set_acceleration({
|
||||
x = 0,
|
||||
y = -self.fall_speed / (max(1, v.y) ^ 2),
|
||||
z = 0
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- in water then float up
|
||||
if minetest.registered_nodes[node_ok(pos).name].groups.water then
|
||||
|
||||
|
@ -3773,6 +3785,7 @@ minetest.register_entity(name, {
|
|||
knock_back = def.knock_back ~= false,
|
||||
shoot_offset = def.shoot_offset or 0,
|
||||
floats = def.floats or 1, -- floats in water by default
|
||||
floats_on_lava = def.floats_on_lava or 0,
|
||||
replace_rate = def.replace_rate,
|
||||
replace_what = def.replace_what,
|
||||
replace_with = def.replace_with,
|
||||
|
|
|
@ -450,7 +450,7 @@ mobs:spawn_specific("mobs_mc:donkey", mobs_mc.spawn.grassland_savanna, {"air"},
|
|||
|
||||
-- spawn eggs
|
||||
mobs:register_egg("mobs_mc:horse", S("Horse"), "mobs_mc_spawn_icon_horse.png", 0)
|
||||
--mobs:register_egg("mobs_mc:skeleton_horse", S("Skeleton Horse"), "mobs_mc_spawn_icon_horse_skeleton.png", 0)
|
||||
mobs:register_egg("mobs_mc:skeleton_horse", S("Skeleton Horse"), "mobs_mc_spawn_icon_horse_skeleton.png", 0)
|
||||
--mobs:register_egg("mobs_mc:zombie_horse", S("Zombie Horse"), "mobs_mc_spawn_icon_horse_zombie.png", 0)
|
||||
mobs:register_egg("mobs_mc:donkey", S("Donkey"), "mobs_mc_spawn_icon_donkey.png", 0)
|
||||
mobs:register_egg("mobs_mc:mule", S("Mule"), "mobs_mc_spawn_icon_mule.png", 0)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -960,7 +960,7 @@ mobs:register_mob("mobs_mc:villager", {
|
|||
"mobs_mc_villager_smith.png", --hat
|
||||
},
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
makes_footstep_sound = true,
|
||||
walk_velocity = 1.2,
|
||||
run_velocity = 2.4,
|
||||
|
|
|
@ -28,7 +28,7 @@ mobs:register_mob("mobs_mc:evoker", {
|
|||
"blank.png", --no hat
|
||||
-- TODO: Attack glow
|
||||
} },
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
makes_footstep_sound = true,
|
||||
damage = 6,
|
||||
walk_velocity = 0.2,
|
||||
|
|
|
@ -36,7 +36,7 @@ mobs:register_mob("mobs_mc:illusioner", {
|
|||
-- TODO: more sounds
|
||||
distance = 16,
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
walk_velocity = 0.6,
|
||||
run_velocity = 2,
|
||||
jump = true,
|
||||
|
|
|
@ -30,7 +30,7 @@ mobs:register_mob("mobs_mc:vindicator", {
|
|||
-- TODO: Glow when attacking (mobs_mc_vindicator.png)
|
||||
},
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
makes_footstep_sound = true,
|
||||
damage = 13,
|
||||
reach = 2,
|
||||
|
|
|
@ -45,7 +45,7 @@ mobs:register_mob("mobs_mc:villager_zombie", {
|
|||
{"mobs_mc_zombie_smith.png"},
|
||||
{"mobs_mc_zombie_villager.png"}
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
makes_footstep_sound = true,
|
||||
damage = 3,
|
||||
reach = 2,
|
||||
|
|
|
@ -25,7 +25,7 @@ mobs:register_mob("mobs_mc:witch", {
|
|||
textures = {
|
||||
{"mobs_mc_witch.png"},
|
||||
},
|
||||
visual_size = {x=3, y=3},
|
||||
visual_size = {x=2.75, y=2.75},
|
||||
makes_footstep_sound = true,
|
||||
damage = 2,
|
||||
reach = 2,
|
||||
|
|
|
@ -38,6 +38,7 @@ mcl_weather.reg_weathers["none"] = {
|
|||
local storage = minetest.get_mod_storage()
|
||||
-- Save weather into mod storage, so it can be loaded after restarting the server
|
||||
local save_weather = function()
|
||||
if not mcl_weather.end_time then return end
|
||||
storage:set_string("mcl_weather_state", mcl_weather.state)
|
||||
storage:set_int("mcl_weather_end_time", mcl_weather.end_time)
|
||||
minetest.log("verbose", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
mesecons
|
||||
mcl_sounds
|
||||
doc?
|
||||
screwdriver?
|
|
@ -1,2 +1,3 @@
|
|||
name = mcl_comparators
|
||||
depends = mcl_wip
|
||||
depends = mcl_wip, mesecons, mcl_sounds
|
||||
optional_depends = doc, screwdriver
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
mcl_init
|
||||
mcl_formspec
|
||||
mesecons
|
||||
mcl_sounds
|
||||
mcl_tnt
|
||||
mcl_worlds
|
||||
mcl_core
|
||||
mcl_nether
|
||||
mcl_armor_stand
|
||||
mcl_armor
|
||||
doc?
|
||||
screwdriver?
|
|
@ -0,0 +1,3 @@
|
|||
name = mcl_dispensers
|
||||
depends = mcl_init, mcl_formspec, mesecons, mcl_sounds, mcl_tnt, mcl_worlds, mcl_core, mcl_nether, mcl_armor_stand, mcl_armor
|
||||
optional_depends = doc, screwdriver
|
|
@ -1,6 +0,0 @@
|
|||
mcl_init
|
||||
mcl_formspec
|
||||
mesecons
|
||||
mcl_util
|
||||
doc?
|
||||
screwdriver?
|
|
@ -0,0 +1,3 @@
|
|||
name = mcl_droppers
|
||||
depends = mcl_init, mcl_formspec, mesecons, mcl_util
|
||||
optional_depends = doc, screwdriver
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
mcl_util
|
|
@ -0,0 +1,2 @@
|
|||
name = mcl_observers
|
||||
depends = mesecons, mcl_util
|
|
@ -1,3 +0,0 @@
|
|||
mcl_sounds
|
||||
mcl_core
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons
|
||||
depends = mcl_sounds, mcl_core
|
||||
optional_depends = doc
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -0,0 +1,2 @@
|
|||
name = mesecons_alias
|
||||
depends = mesecons
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_button
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -1,3 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
||||
doc_items?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_commandblock
|
||||
depends = mesecons
|
||||
optional_depends = doc, doc_items
|
|
@ -1,3 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
||||
screwdriver?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_delayer
|
||||
depends = mesecons
|
||||
optional_depends = doc, screwdriver
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_lightstone
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -0,0 +1,2 @@
|
|||
name = mesecons_mvps
|
||||
depends = mesecons
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
mcl_particles
|
|
@ -0,0 +1,2 @@
|
|||
name = mesecons_noteblock
|
||||
depends = mesecons, mcl_particles
|
|
@ -1,5 +0,0 @@
|
|||
mesecons
|
||||
mesecons_mvps
|
||||
mcl_mobitems
|
||||
doc?
|
||||
screwdriver?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_pistons
|
||||
depends = mesecons, mesecons_mvps, mcl_mobitems
|
||||
optional_depends = doc, screwdriver
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_pressureplates
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_solarpanel
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -1,3 +0,0 @@
|
|||
mesecons
|
||||
mcl_torches
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_torch
|
||||
depends = mesecons, mcl_torches
|
||||
optional_depends = doc
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_walllever
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
doc?
|
|
@ -0,0 +1,3 @@
|
|||
name = mesecons_wires
|
||||
depends = mesecons
|
||||
optional_depends = doc
|
|
@ -149,8 +149,8 @@ armor.set_player_armor = function(self, player)
|
|||
if level then
|
||||
local texture = def.texture or item:gsub("%:", "_")
|
||||
local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "")
|
||||
table.insert(textures, texture..".png"..enchanted_addition)
|
||||
preview = "player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..""..(preview and "^"..preview or "")
|
||||
table.insert(textures, "("..texture..".png"..enchanted_addition..")")
|
||||
preview = "(player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..")"..(preview and "^"..preview or "")
|
||||
armor_level = armor_level + level
|
||||
items = items + 1
|
||||
mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0)
|
||||
|
|
|
@ -16,23 +16,17 @@ local dir_to_pitch = function(dir)
|
|||
end
|
||||
|
||||
local random_arrow_positions = function(positions, placement)
|
||||
local min = 0
|
||||
local max = 0
|
||||
if positions == 'x' then
|
||||
min = -4
|
||||
max = 4
|
||||
return math.random(-4, 4)
|
||||
elseif positions == 'y' then
|
||||
min = 0
|
||||
max = 10
|
||||
return math.random(0, 10)
|
||||
end
|
||||
if placement == 'front' and positions == 'z' then
|
||||
min = 3
|
||||
max = 3
|
||||
return 3
|
||||
elseif placement == 'back' and positions == 'z' then
|
||||
min = -3
|
||||
max = -3
|
||||
return -3
|
||||
end
|
||||
return math.random(max, min)
|
||||
return 0
|
||||
end
|
||||
|
||||
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
|
||||
|
@ -304,8 +298,8 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
|||
else
|
||||
self._attach_parent = 'Body'
|
||||
end
|
||||
self._z_rotation = math.random(30, -30)
|
||||
self._y_rotation = math.random(30, -30)
|
||||
self._z_rotation = math.random(-30, 30)
|
||||
self._y_rotation = math.random( -30, 30)
|
||||
self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation})
|
||||
minetest.after(150, function()
|
||||
self.object:remove()
|
||||
|
@ -337,8 +331,8 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
|||
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true)
|
||||
end
|
||||
end
|
||||
mcl_burning.extinguish(self.object)
|
||||
if not obj:is_player() then
|
||||
mcl_burning.extinguish(self.object)
|
||||
self.object:remove()
|
||||
end
|
||||
return
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
mcl_core
|
||||
mclx_core?
|
||||
mcl_sounds
|
||||
doc?
|
|
@ -1 +1,3 @@
|
|||
name = mcl_cauldrons
|
||||
depends = mcl_core, mcl_sounds
|
||||
optional_depends = mclx_core, doc
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
mcl_init
|
||||
mcl_formspec
|
||||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_end
|
||||
mesecons
|
||||
doc?
|
||||
screwdriver?
|
|
@ -0,0 +1,3 @@
|
|||
name = mcl_chests
|
||||
depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_end, mesecons
|
||||
optional_depends = doc, screwdriver
|
|
@ -1,4 +0,0 @@
|
|||
mcl_init
|
||||
mcl_worlds
|
||||
mesecons
|
||||
doc?
|
|
@ -1 +0,0 @@
|
|||
A fantasy clock item roughly shows the time of day.
|
|
@ -1 +1,4 @@
|
|||
name = mcl_clock
|
||||
description = A fantasy clock item roughly shows the time of day.
|
||||
depends = mcl_init, mcl_worlds, mesecons
|
||||
optional_depends = doc
|
||||
|
|
|
@ -19,7 +19,7 @@ function mcl_cocoas.place(itemstack, placer, pt, plantname)
|
|||
-- Am I right-clicking on something that has a custom on_rightclick set?
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[under.name] and minetest.registered_nodes[under.name].on_rightclick then
|
||||
return minetest.registered_nodes[under.name].on_rightclick(pointed_thing.under, under, placer, itemstack) or itemstack
|
||||
return minetest.registered_nodes[under.name].on_rightclick(pt.under, under, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_dye
|
||||
doc?
|
||||
screwdriver?
|
|
@ -1 +0,0 @@
|
|||
Adds blocks which can be colored, namely hardened clay.
|
|
@ -1 +1,4 @@
|
|||
name = mcl_colorblocks
|
||||
description = Adds blocks which can be colored, namely hardened clay.
|
||||
depends = mcl_core, mcl_sounds, mcl_dye
|
||||
optional_depends = doc, screwdriver
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
mcl_core
|
||||
mcl_worlds
|
||||
mesecons
|
||||
doc?
|
|
@ -1 +0,0 @@
|
|||
A compass item which points towards the world origin.
|
|
@ -1 +1,4 @@
|
|||
name = mcl_compass
|
||||
description = A compass item which points towards the world origin.
|
||||
depends = mcl_core, mcl_worlds, mesecons
|
||||
optional_depends = doc
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
mcl_init
|
||||
mcl_sounds
|
||||
mcl_particles
|
||||
mcl_util
|
||||
mcl_worlds
|
||||
doc_items
|
||||
doc?
|
||||
mcl_enchanting
|
|
@ -1 +0,0 @@
|
|||
Core items of MineClone 2: Basic biome blocks (dirt, sand, stones, etc.), derived items, glass, sugar cane, cactus, barrier, mining tools, hand, craftitems, and misc. items which don't really fit anywhere else.
|
|
@ -3,6 +3,19 @@ mcl_core = {}
|
|||
-- Repair percentage for toolrepair
|
||||
mcl_core.repair = 0.05
|
||||
|
||||
mcl_autogroup.register_diggroup("handy")
|
||||
mcl_autogroup.register_diggroup("pickaxey", {
|
||||
levels = { "wood", "gold", "stone", "iron", "diamond" }
|
||||
})
|
||||
mcl_autogroup.register_diggroup("axey")
|
||||
mcl_autogroup.register_diggroup("shovely")
|
||||
mcl_autogroup.register_diggroup("shearsy")
|
||||
mcl_autogroup.register_diggroup("shearsy_wool")
|
||||
mcl_autogroup.register_diggroup("shearsy_cobweb")
|
||||
mcl_autogroup.register_diggroup("swordy")
|
||||
mcl_autogroup.register_diggroup("swordy_cobweb")
|
||||
mcl_autogroup.register_diggroup("hoey")
|
||||
|
||||
-- Load files
|
||||
local modpath = minetest.get_modpath("mcl_core")
|
||||
dofile(modpath.."/functions.lua")
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
name = mcl_core
|
||||
name = mcl_core
|
||||
description = Core items of MineClone 2: Basic biome blocks (dirt, sand, stones, etc.), derived items, glass, sugar cane, cactus, barrier, mining tools, hand, craftitems, and misc. items which don't really fit anywhere else.
|
||||
depends = mcl_autogroup, mcl_init, mcl_sounds, mcl_particles, mcl_util, mcl_worlds, doc_items, mcl_enchanting
|
||||
optional_depends = doc
|
||||
|
|
|
@ -108,7 +108,7 @@ minetest.register_node("mcl_core:cobweb", {
|
|||
liquid_renewable = false,
|
||||
liquid_range = 0,
|
||||
walkable = false,
|
||||
groups = {swordy_cobweb=1,shearsy=1, fake_liquid=1, disable_jump=1, deco_block=1, dig_by_piston=1, dig_by_water=1,destroy_by_lava_flow=1,},
|
||||
groups = {swordy_cobweb=1, shearsy_cobweb=1, fake_liquid=1, disable_jump=1, deco_block=1, dig_by_piston=1, dig_by_water=1,destroy_by_lava_flow=1,},
|
||||
drop = "mcl_mobitems:string",
|
||||
_mcl_shears_drop = true,
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
|
|
|
@ -108,7 +108,19 @@ local register_leaves = function(subname, description, longdesc, tiles, sapling,
|
|||
tiles = tiles,
|
||||
paramtype = "light",
|
||||
stack_max = 64,
|
||||
groups = {handy=1,shearsy=1,swordy=1, leafdecay=leafdecay_distance, flammable=2, leaves=1, deco_block=1, dig_by_piston=1, fire_encouragement=30, fire_flammability=60},
|
||||
groups = {
|
||||
handy=1,
|
||||
hoey=1,
|
||||
shearsy=1,
|
||||
swordy=1,
|
||||
leafdecay=leafdecay_distance,
|
||||
flammable=2,
|
||||
leaves=1,
|
||||
deco_block=1,
|
||||
dig_by_piston=1,
|
||||
fire_encouragement=30,
|
||||
fire_flammability=60
|
||||
},
|
||||
drop = get_drops(0),
|
||||
_mcl_shears_drop = true,
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
doc?
|
||||
screwdriver?
|
||||
mesecons
|
|
@ -1 +1,3 @@
|
|||
name = mcl_doors
|
||||
depends = mcl_core, mcl_sounds, mesecons
|
||||
optional_depends = doc, screwdriver
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
mcl_core
|
||||
mcl_flowers
|
||||
mcl_mobitems
|
||||
mcl_cocoas
|
|
@ -1 +1,2 @@
|
|||
name = mcl_dye
|
||||
depends = mcl_core, mcl_flowers, mcl_mobitems, mcl_cocoas
|
||||
|
|
|
@ -155,15 +155,7 @@ mcl_enchanting.enchantments.efficiency = {
|
|||
description = S("Increases mining speed."),
|
||||
curse = false,
|
||||
on_enchant = function(itemstack, level)
|
||||
local tool_capabilities = itemstack:get_tool_capabilities()
|
||||
local groupcaps = {}
|
||||
for group, capability in pairs(tool_capabilities.groupcaps) do
|
||||
local groupname = group .. "_efficiency_" .. level
|
||||
capability.times = mcl_autogroup.digtimes[groupname]
|
||||
groupcaps[groupname] = capability
|
||||
end
|
||||
tool_capabilities.groupcaps = groupcaps
|
||||
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
|
||||
mcl_enchanting.update_groupcaps(itemstack)
|
||||
end,
|
||||
requires_tool = false,
|
||||
treasure = false,
|
||||
|
|
|
@ -219,6 +219,38 @@ function mcl_enchanting.enchantments_snippet(_, _, itemstack)
|
|||
end
|
||||
end
|
||||
|
||||
-- Returns the after_use callback function to use when registering an enchanted
|
||||
-- item. The after_use callback is used to update the tool_capabilities of
|
||||
-- efficiency enchanted tools with outdated digging times.
|
||||
--
|
||||
-- It does this by calling apply_efficiency to reapply the efficiency
|
||||
-- enchantment. That function is written to use hash values to only update the
|
||||
-- tool if neccessary.
|
||||
--
|
||||
-- This is neccessary for digging times of tools to be in sync when MineClone2
|
||||
-- or mods add new hardness values.
|
||||
local function get_after_use_callback(itemdef)
|
||||
if itemdef.after_use then
|
||||
-- If the tool already has an after_use, make sure to call that
|
||||
-- one too.
|
||||
return function(itemstack, user, node, digparams)
|
||||
itemdef.after_use(itemstack, user, node, digparams)
|
||||
mcl_enchanting.update_groupcaps(itemstack)
|
||||
end
|
||||
end
|
||||
|
||||
-- If the tool does not have after_use, add wear to the tool as if no
|
||||
-- after_use was registered.
|
||||
return function(itemstack, user, node, digparams)
|
||||
if not minetest.is_creative_enabled(user) then
|
||||
itemstack:add_wear(digparams.wear)
|
||||
end
|
||||
|
||||
local enchantments = mcl_enchanting.get_enchantments(itemstack)
|
||||
mcl_enchanting.update_groupcaps(itemstack)
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_enchanting.initialize()
|
||||
local register_tool_list = {}
|
||||
local register_item_list = {}
|
||||
|
@ -236,6 +268,7 @@ function mcl_enchanting.initialize()
|
|||
new_def.groups.enchanted = 1
|
||||
new_def.texture = itemdef.texture or itemname:gsub("%:", "_")
|
||||
new_def._mcl_enchanting_enchanted_tool = new_name
|
||||
new_def.after_use = get_after_use_callback(itemdef)
|
||||
local register_list = register_item_list
|
||||
if itemdef.type == "tool" then
|
||||
register_list = register_tool_list
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
local groupcaps_cache = {}
|
||||
|
||||
-- Compute a hash value.
|
||||
function compute_hash(value)
|
||||
-- minetest.get_password_hash is quite fast, even if it uses a
|
||||
-- cryptographic hashing function (SHA-1). It is written in C++ and it
|
||||
-- is probably hard to write a faster hashing function in Lua.
|
||||
return string.sub(minetest.get_password_hash("ryvnf", minetest.serialize(value)), 1, 8)
|
||||
end
|
||||
|
||||
-- Get the groupcaps and hash for an enchanted tool. If this function is called
|
||||
-- repeatedly with the same values it will return data from a cache.
|
||||
--
|
||||
-- Parameters:
|
||||
-- toolname - Name of the tool
|
||||
-- level - The efficiency level of the tool
|
||||
--
|
||||
-- Returns a table with the following two fields:
|
||||
-- values - The groupcaps table
|
||||
-- hash - The hash of the groupcaps table
|
||||
local function get_efficiency_groupcaps(toolname, level)
|
||||
local toolcache = groupcaps_cache[toolname]
|
||||
local level = level
|
||||
|
||||
if not toolcache then
|
||||
toolcache = {}
|
||||
groupcaps_cache[toolname] = toolcache
|
||||
end
|
||||
|
||||
local levelcache = toolcache[level]
|
||||
if not levelcache then
|
||||
levelcache = {}
|
||||
levelcache.values = mcl_autogroup.get_groupcaps(toolname, level)
|
||||
levelcache.hash = compute_hash(levelcache.values)
|
||||
toolcache[level] = levelcache
|
||||
end
|
||||
|
||||
return levelcache
|
||||
end
|
||||
|
||||
-- Update groupcaps of an enchanted tool. This function will be called
|
||||
-- repeatedly to make sure the digging times stored in groupcaps stays in sync
|
||||
-- when the digging times of nodes can change.
|
||||
--
|
||||
-- To make it more efficient it will first check a hash value to determine if
|
||||
-- the tool needs to be updated.
|
||||
function mcl_enchanting.update_groupcaps(itemstack)
|
||||
if not itemstack:get_tool_capabilities() then
|
||||
return
|
||||
end
|
||||
|
||||
local name = itemstack:get_name()
|
||||
local level = mcl_enchanting.get_enchantment(itemstack, "efficiency")
|
||||
local groupcaps = get_efficiency_groupcaps(name, level)
|
||||
local hash = itemstack:get_meta():get_string("groupcaps_hash")
|
||||
|
||||
if not hash or hash ~= groupcaps.hash then
|
||||
local tool_capabilities = itemstack:get_tool_capabilities()
|
||||
tool_capabilities.groupcaps = groupcaps.values
|
||||
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
|
||||
itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash)
|
||||
end
|
||||
end
|
|
@ -59,6 +59,7 @@ mcl_enchanting = {
|
|||
}
|
||||
|
||||
dofile(modpath .. "/engine.lua")
|
||||
dofile(modpath .. "/groupcaps.lua")
|
||||
dofile(modpath .. "/enchantments.lua")
|
||||
|
||||
minetest.register_chatcommand("enchant", {
|
||||
|
|
|
@ -85,14 +85,15 @@ minetest.register_craftitem("mcl_end:crystal", {
|
|||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
||||
local node = minetest.get_node(pos).name
|
||||
local node = minetest.get_node(pos)
|
||||
local node_name = node.name
|
||||
if placer and not placer: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, placer, itemstack) or itemstack
|
||||
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, placer, itemstack) or itemstack
|
||||
end
|
||||
end
|
||||
if find_crystal(pos) then return itemstack end
|
||||
if node == "mcl_core:obsidian" or node == "mcl_core:bedrock" then
|
||||
if node_name == "mcl_core:obsidian" or node_name == "mcl_core:bedrock" then
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_wool
|
||||
mcl_torches
|
||||
mcl_weather
|
||||
mcl_armor?
|
||||
mobs_mc
|
||||
doc?
|
|
@ -78,6 +78,9 @@ minetest.register_tool("mcl_farming:hoe_wood", {
|
|||
},
|
||||
_repair_material = "group:wood",
|
||||
_mcl_toollike_wield = true,
|
||||
_mcl_diggroups = {
|
||||
hoey = { speed = 2, level = 1, uses = 60 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -118,6 +121,9 @@ minetest.register_tool("mcl_farming:hoe_stone", {
|
|||
},
|
||||
_repair_material = "mcl_core:cobble",
|
||||
_mcl_toollike_wield = true,
|
||||
_mcl_diggroups = {
|
||||
hoey = { speed = 4, level = 3, uses = 132 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -154,6 +160,9 @@ minetest.register_tool("mcl_farming:hoe_iron", {
|
|||
},
|
||||
_repair_material = "mcl_core:iron_ingot",
|
||||
_mcl_toollike_wield = true,
|
||||
_mcl_diggroups = {
|
||||
hoey = { speed = 6, level = 4, uses = 251 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -196,6 +205,9 @@ minetest.register_tool("mcl_farming:hoe_gold", {
|
|||
},
|
||||
_repair_material = "mcl_core:gold_ingot",
|
||||
_mcl_toollike_wield = true,
|
||||
_mcl_diggroups = {
|
||||
hoey = { speed = 12, level = 2, uses = 33 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -240,6 +252,9 @@ minetest.register_tool("mcl_farming:hoe_diamond", {
|
|||
},
|
||||
_repair_material = "mcl_core:diamond",
|
||||
_mcl_toollike_wield = true,
|
||||
_mcl_diggroups = {
|
||||
hoey = { speed = 8, level = 5, uses = 1562 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
name = mcl_farming
|
||||
depends = mcl_core, mcl_sounds, mcl_wool, mcl_torches, mcl_weather, mobs_mc
|
||||
optional_depends = mcl_armor, doc
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 303 B |
|
@ -146,7 +146,7 @@ minetest.register_node("mcl_farming:hay_block", {
|
|||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
on_place = mcl_util.rotate_axis,
|
||||
groups = {handy=1, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80},
|
||||
groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_rotate = on_rotate,
|
||||
_mcl_blast_resistance = 0.5,
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
doc?
|
||||
screwdriver?
|
|
@ -1 +1,3 @@
|
|||
name = mcl_fences
|
||||
depends = mcl_core, mcl_sounds
|
||||
optional_depends = doc, screwdriver
|
||||
|
|
|
@ -50,69 +50,69 @@ local alldirs=
|
|||
-- 3 exptime variants because the animation is not tied to particle expiration time.
|
||||
-- 3 colorized variants to imitate minecraft's
|
||||
local smoke_pdef_base = {
|
||||
amount = 0.001,
|
||||
time = 0,
|
||||
-- minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 }),
|
||||
-- maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 }),
|
||||
minvel = { x = -0.1, y = 0.3, z = -0.1 },
|
||||
maxvel = { x = 0.1, y = 1.6, z = 0.1 },
|
||||
-- minexptime = 3 exptime variants,
|
||||
-- maxexptime = 3 exptime variants
|
||||
minsize = 4.0,
|
||||
maxsize = 4.5,
|
||||
-- texture = "mcl_particles_smoke_anim.png^[colorize:#000000:(3 colourize variants)",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 8,
|
||||
aspect_h = 8,
|
||||
-- length = 3 exptime variants
|
||||
},
|
||||
collisiondetection = true,
|
||||
amount = 0.001,
|
||||
time = 0,
|
||||
-- minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 }),
|
||||
-- maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 }),
|
||||
minvel = { x = -0.1, y = 0.3, z = -0.1 },
|
||||
maxvel = { x = 0.1, y = 1.6, z = 0.1 },
|
||||
-- minexptime = 3 exptime variants,
|
||||
-- maxexptime = 3 exptime variants
|
||||
minsize = 4.0,
|
||||
maxsize = 4.5,
|
||||
-- texture = "mcl_particles_smoke_anim.png^[colorize:#000000:(3 colourize variants)",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 8,
|
||||
aspect_h = 8,
|
||||
-- length = 3 exptime variants
|
||||
},
|
||||
collisiondetection = true,
|
||||
}
|
||||
local smoke_pdef_cached = {}
|
||||
local spawn_smoke = function(pos)
|
||||
local min = math.min
|
||||
local new_minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 })
|
||||
local new_maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 })
|
||||
local min = math.min
|
||||
local new_minpos = vector.add(pos, { x = -0.45, y = -0.45, z = -0.45 })
|
||||
local new_maxpos = vector.add(pos, { x = 0.45, y = 0.45, z = 0.45 })
|
||||
|
||||
-- populate the cache
|
||||
if not next(smoke_pdef_cached) then
|
||||
-- the last frame plays for 1/8 * N seconds, so we can take advantage of it
|
||||
-- to have varying exptime for each variant.
|
||||
local exptimes = { 0.75, 1.5, 4.0 }
|
||||
local colorizes = { "199", "209", "243" } -- round(78%, 82%, 90% of 256) - 1
|
||||
-- populate the cache
|
||||
if not next(smoke_pdef_cached) then
|
||||
-- the last frame plays for 1/8 * N seconds, so we can take advantage of it
|
||||
-- to have varying exptime for each variant.
|
||||
local exptimes = { 0.75, 1.5, 4.0 }
|
||||
local colorizes = { "199", "209", "243" } -- round(78%, 82%, 90% of 256) - 1
|
||||
|
||||
local id = 1
|
||||
for _,exptime in ipairs(exptimes) do
|
||||
for _,colorize in ipairs(colorizes) do
|
||||
smoke_pdef_base.minpos = new_minpos
|
||||
smoke_pdef_base.maxpos = new_maxpos
|
||||
smoke_pdef_base.maxexptime = exptime
|
||||
smoke_pdef_base.animation.length = exptime + 0.1
|
||||
-- minexptime must be set such that the last frame is actully rendered,
|
||||
-- even if its very short. Larger exptime -> larger range
|
||||
smoke_pdef_base.minexptime = min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1))
|
||||
smoke_pdef_base.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize
|
||||
local id = 1
|
||||
for _,exptime in ipairs(exptimes) do
|
||||
for _,colorize in ipairs(colorizes) do
|
||||
smoke_pdef_base.minpos = new_minpos
|
||||
smoke_pdef_base.maxpos = new_maxpos
|
||||
smoke_pdef_base.maxexptime = exptime
|
||||
smoke_pdef_base.animation.length = exptime + 0.1
|
||||
-- minexptime must be set such that the last frame is actully rendered,
|
||||
-- even if its very short. Larger exptime -> larger range
|
||||
smoke_pdef_base.minexptime = min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1))
|
||||
smoke_pdef_base.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize
|
||||
|
||||
smoke_pdef_cached[id] = table.copy(smoke_pdef_base)
|
||||
smoke_pdef_cached[id] = table.copy(smoke_pdef_base)
|
||||
|
||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef_cached[id], "high")
|
||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef_cached[id], "high")
|
||||
|
||||
id = id + 1
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- cache already populated
|
||||
else
|
||||
for i, smoke_pdef in ipairs(smoke_pdef_cached) do
|
||||
smoke_pdef.minpos = new_minpos
|
||||
smoke_pdef.maxpos = new_maxpos
|
||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high")
|
||||
end
|
||||
end
|
||||
-- cache already populated
|
||||
else
|
||||
for i, smoke_pdef in ipairs(smoke_pdef_cached) do
|
||||
smoke_pdef.minpos = new_minpos
|
||||
smoke_pdef.maxpos = new_maxpos
|
||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high")
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Old smoke pdef
|
||||
local spawn_smoke = function(pos)
|
||||
local spawn_smoke = function(pos)
|
||||
mcl_particles.add_node_particlespawner(pos, {
|
||||
amount = 0.1,
|
||||
time = 0,
|
||||
|
@ -132,7 +132,7 @@ local spawn_smoke = function(pos)
|
|||
length = 2.1,
|
||||
},
|
||||
}, "high")
|
||||
-- ]]
|
||||
-- ]]
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_loot
|
||||
mcl_mobs
|
||||
mcl_enchanting
|
|
@ -1 +0,0 @@
|
|||
Adds fish and fishing poles to go fishing.
|
|
@ -1 +1,3 @@
|
|||
name = mcl_fishing
|
||||
description = Adds fish and fishing poles to go fishing.
|
||||
depends = mcl_core, mcl_sounds, mcl_loot, mcl_mobs, mcl_enchanting
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
mcl_init
|
||||
mcl_formspec
|
||||
mcl_core
|
||||
mcl_sounds
|
||||
mcl_craftguide
|
||||
mcl_achievements
|
||||
mcl_particles
|
||||
doc?
|
||||
screwdriver?
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue