diff --git a/menu/Logo.blend b/menu/Logo.blend new file mode 100644 index 000000000..424aae4ea Binary files /dev/null and b/menu/Logo.blend differ diff --git a/menu/icon.png b/menu/icon.png index e479dfff5..e70c5a077 100644 Binary files a/menu/icon.png and b/menu/icon.png differ diff --git a/menu/icon_small.png b/menu/icon_small.png new file mode 100644 index 000000000..41e13e1e6 Binary files /dev/null and b/menu/icon_small.png differ diff --git a/mods/CORE/mcl_loot/init.lua b/mods/CORE/mcl_loot/init.lua index 1b2c50807..b90cd4428 100644 --- a/mods/CORE/mcl_loot/init.lua +++ b/mods/CORE/mcl_loot/init.lua @@ -58,26 +58,27 @@ function mcl_loot.get_loot(loot_definitions, pr) end if item then local itemstring = item.itemstring - local itemstack = item.itemstack + if itemstring then + local stack = ItemStack(itemstring) + if item.amount_min and item.amount_max then - itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max) + stack:set_count(pr:next(item.amount_min, item.amount_max)) end + if item.wear_min and item.wear_max then -- Sadly, PseudoRandom only allows very narrow ranges, so we set wear in steps of 10 local wear_min = math.floor(item.wear_min / 10) local wear_max = math.floor(item.wear_max / 10) - local wear = pr:next(wear_min, wear_max) * 10 - if not item.amount_min and not item.amount_max then - itemstring = itemstring .. " 1" - end - - itemstring = itemstring .. " " .. tostring(wear) + stack:set_wear(pr:next(wear_min, wear_max) * 10) end - table.insert(items, itemstring) - elseif itemstack then - table.insert(items, itemstack) + + if item.func then + item.func(stack, pr) + end + + table.insert(items, stack) else minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!") end diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index d91c86f09..d548f6cac 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -478,7 +478,9 @@ function mcl_util.calculate_durability(itemstack) end end end - uses = uses or (next(itemstack:get_tool_capabilities().groupcaps) or {}).uses + + local _, groupcap = next(itemstack:get_tool_capabilities().groupcaps) + uses = uses or (groupcap or {}).uses end return uses or 0 diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua deleted file mode 100644 index e17bdda40..000000000 --- a/mods/ENTITIES/drippingwater/init.lua +++ /dev/null @@ -1,114 +0,0 @@ ---Dripping Water Mod ---by kddekadenz - -local math = math - --- License of code, textures & sounds: CC0 - ---Drop entities - ---water - -local water_tex = "default_water_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_water", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 1, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k==1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - ---lava - -local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_lava", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - glow = math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {lava_tex, lava_tex, lava_tex, lava_tex, lava_tex, lava_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 0, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k == 1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - - ---Create drop - -minetest.register_abm({ - label = "Create water drops", - nodenames = {"group:opaque", "group:leaves"}, - neighbors = {"group:water"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water") - end - end, -}) - ---Create lava drop - -minetest.register_abm({ - label = "Create lava drops", - nodenames = {"group:opaque"}, - neighbors = {"group:lava"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava") - end - end, -}) \ No newline at end of file diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index f46c14d46..beff5fb52 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -342,7 +342,8 @@ function boat.on_step(self, dtime, moveresult) self.object:get_velocity().y) else p.y = p.y + 1 - if is_water(p) then + local is_obsidian_boat = self.object:get_luaentity()._itemstring == "mcl_boats:boat_obsidian" + if is_water(p) or is_obsidian_boat then -- Inside water: Slowly sink local y = self.object:get_velocity().y y = y - 0.01 @@ -382,13 +383,13 @@ end -- Register one entity for all boat types minetest.register_entity("mcl_boats:boat", boat) -local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak" } -local names = { S("Oak Boat"), S("Spruce Boat"), S("Birch Boat"), S("Jungle Boat"), S("Acacia Boat"), S("Dark Oak Boat") } +local boat_ids = { "boat", "boat_spruce", "boat_birch", "boat_jungle", "boat_acacia", "boat_dark_oak", "boat_obsidian" } +local names = { S("Oak Boat"), S("Spruce Boat"), S("Birch Boat"), S("Jungle Boat"), S("Acacia Boat"), S("Dark Oak Boat"), S("Obsidian Boat") } local craftstuffs = {} if minetest.get_modpath("mcl_core") then - craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood" } + craftstuffs = { "mcl_core:wood", "mcl_core:sprucewood", "mcl_core:birchwood", "mcl_core:junglewood", "mcl_core:acaciawood", "mcl_core:darkwood", "mcl_core:obsidian" } end -local images = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak" } +local images = { "oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "obsidian" } for b=1, #boat_ids do local itemstring = "mcl_boats:"..boat_ids[b] diff --git a/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png b/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png new file mode 100644 index 000000000..6ae10c0c4 Binary files /dev/null and b/mods/ENTITIES/mcl_boats/textures/mcl_boats_obsidian_boat.png differ diff --git a/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png b/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png new file mode 100644 index 000000000..af3c24b30 Binary files /dev/null and b/mods/ENTITIES/mcl_boats/textures/mcl_boats_texture_obsidian_boat.png differ diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 313e75dca..a47824537 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -44,18 +44,18 @@ minetest.register_on_respawnplayer(function(player) mcl_burning.extinguish(player) end) -minetest.register_on_joinplayer(function(player) - local storage - - local burn_data = player:get_meta():get_string("mcl_burning:data") - if burn_data == "" then - storage = {} - else - storage = minetest.deserialize(burn_data) +function mcl_burning.init_player(player) + local meta = player:get_meta() + -- NOTE: mcl_burning:data may be "return nil" (which deserialize into nil) for reasons unknown. + if meta:get_string("mcl_burning:data"):find("return nil", 1, true) then + minetest.log("warning", "[mcl_burning] 'mcl_burning:data' player meta field is invalid! Please report this bug") end - - mcl_burning.storage[player] = storage + mcl_burning.storage[player] = meta:contains("mcl_burning:data") and minetest.deserialize(meta:get_string("mcl_burning:data")) or {} mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name()) +end + +minetest.register_on_joinplayer(function(player) + mcl_burning.init_player(player) end) minetest.register_on_leaveplayer(function(player) diff --git a/mods/ENTITIES/mcl_dripping/init.lua b/mods/ENTITIES/mcl_dripping/init.lua new file mode 100644 index 000000000..57ba7ecfe --- /dev/null +++ b/mods/ENTITIES/mcl_dripping/init.lua @@ -0,0 +1,66 @@ +-- Dripping Water Mod +-- by kddekadenz + +local math = math + +-- License of code, textures & sounds: CC0 + +local function register_drop(liquid, glow, sound, nodes) + minetest.register_entity("mcl_dripping:drop_" .. liquid, { + hp_max = 1, + physical = true, + collide_with_objects = false, + collisionbox = {-0.01, 0.01, -0.01, 0.01, 0.01, 0.01}, + glow = glow, + pointable = false, + visual = "sprite", + visual_size = {x = 0.1, y = 0.1}, + textures = {""}, + spritediv = {x = 1, y = 1}, + initial_sprite_basepos = {x = 0, y = 0}, + static_save = false, + _dropped = false, + on_activate = function(self) + self.object:set_properties({ + textures = {"[combine:2x2:" .. -math.random(1, 16) .. "," .. -math.random(1, 16) .. "=default_" .. liquid .. "_source_animated.png"} + }) + end, + on_step = function(self, dtime) + local k = math.random(1, 222) + local ownpos = self.object:get_pos() + if k == 1 then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, 0.5, 0)).name == "air" then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, -0.1, 0)).name ~= "air" then + local ent = self.object:get_luaentity() + if not ent._dropped then + ent._dropped = true + minetest.sound_play({name = "drippingwater_" .. sound .. "drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) + end + if k < 3 then + self.object:remove() + end + end + end, + }) + minetest.register_abm({ + label = "Create drops", + nodenames = nodes, + neighbors = {"group:" .. liquid}, + interval = 2, + chance = 22, + action = function(pos) + if minetest.get_item_group(minetest.get_node(vector.offset(pos, 0, 1, 0)).name, liquid) ~= 0 + and minetest.get_node(vector.offset(pos, 0, -1, 0)).name == "air" then + local x, z = math.random(-45, 45) / 100, math.random(-45, 45) / 100 + minetest.add_entity(vector.offset(pos, x, -0.520, z), "mcl_dripping:drop_" .. liquid) + end + end, + }) +end + +register_drop("water", 1, "", {"group:opaque", "group:leaves"}) +register_drop("lava", math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), "lava", {"group:opaque"}) \ No newline at end of file diff --git a/mods/ENTITIES/drippingwater/mod.conf b/mods/ENTITIES/mcl_dripping/mod.conf similarity index 82% rename from mods/ENTITIES/drippingwater/mod.conf rename to mods/ENTITIES/mcl_dripping/mod.conf index 1de118f4c..921d5e59f 100644 --- a/mods/ENTITIES/drippingwater/mod.conf +++ b/mods/ENTITIES/mcl_dripping/mod.conf @@ -1,4 +1,4 @@ -name = drippingwater +name = mcl_dripping author = kddekadenz description = Drops are generated rarely under solid nodes depends = mcl_core diff --git a/mods/ENTITIES/drippingwater/readme.txt b/mods/ENTITIES/mcl_dripping/readme.txt similarity index 75% rename from mods/ENTITIES/drippingwater/readme.txt rename to mods/ENTITIES/mcl_dripping/readme.txt index f609163ed..afe35608e 100644 --- a/mods/ENTITIES/drippingwater/readme.txt +++ b/mods/ENTITIES/mcl_dripping/readme.txt @@ -1,12 +1,12 @@ -Dripping Water Mod +Dripping Mod by kddekadenz -modified for MineClone 2 by Wuzzy +modified for MineClone 2 by Wuzzy and NO11 Installing instructions: - 1. Copy the drippingwater mod folder into games/gamemode/mods + 1. Copy the mcl_dripping mod folder into games/gamemode/mods 2. Start game and enjoy :) diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 999cc5f2d..a7e33d1bd 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -37,7 +37,7 @@ mobs:register_mob("mobs_mc:creeper", { }, makes_footstep_sound = false, walk_velocity = 1.05, - run_velocity = 3.25, + run_velocity = 2.1, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, attack_type = "explode", eye_height = 1.25, @@ -47,8 +47,8 @@ mobs:register_mob("mobs_mc:creeper", { --explosion_radius = 3, --explosion_damage_radius = 6, --explosiontimer_reset_radius = 6, - reach = 1.5, - defuse_reach = 4, + reach = 3, + defuse_reach = 5.2, explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, @@ -95,7 +95,8 @@ mobs:register_mob("mobs_mc:creeper", { if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then - mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) + local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object) end end end, @@ -151,6 +152,7 @@ mobs:register_mob("mobs_mc:creeper_charged", { description = S("Charged Creeper"), type = "monster", spawn_class = "hostile", + hostile = true, hp_min = 20, hp_max = 20, xp_min = 5, @@ -186,8 +188,8 @@ mobs:register_mob("mobs_mc:creeper_charged", { --explosion_radius = 3, --explosion_damage_radius = 6, --explosiontimer_reset_radius = 3, - reach = 1.5, - defuse_reach = 4, + reach = 3, + defuse_reach = 5.2, explosion_timer = 0.3, allow_fuse_reset = true, stop_to_explode = true, @@ -219,7 +221,8 @@ mobs:register_mob("mobs_mc:creeper_charged", { if self._forced_explosion_countdown_timer then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then - mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) + local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false + mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object) end end end, diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 48aacfcce..9236b255e 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -31,12 +31,14 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance speed_penalty = 0.5 end local mob = minetest.add_entity(newpos, child_mob) - if (not mother_stuck) then - mob:set_velocity(vector.multiply(dir, eject_speed * speed_penalty)) + if mob then + if (not mother_stuck) then + mob:set_velocity(vector.multiply(dir, eject_speed * speed_penalty)) + end + mob:set_yaw(angle - math.pi/2) + table.insert(children, mob) + angle = angle + (math.pi*2)/children_count end - mob:set_yaw(angle - math.pi/2) - table.insert(children, mob) - angle = angle + (math.pi*2)/children_count end -- If mother was murdered, children attack the killer after 1 second if self.state == "attack" then diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 06cec9ed6..ce2e76575 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -409,7 +409,7 @@ local init_trades = function(self, inv) local offered_stack = ItemStack({name = offered_item, count = offered_count}) if mcl_enchanting.is_enchanted(offered_item) then if mcl_enchanting.is_book(offered_item) then - offered_stack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}) + mcl_enchanting.enchant_uniform_randomly(offered_stack, {"soul_speed"}) else mcl_enchanting.enchant_randomly(offered_stack, math.random(5, 19), false, false, true) mcl_enchanting.unload_enchantments(offered_stack) diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 83494462f..3579316e8 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -215,7 +215,9 @@ lightning.register_on_strike(function(pos, pos2, objects) posadd = { x=math.cos(angle),y=0,z=math.sin(angle) } posadd = vector.normalize(posadd) local mob = add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton") - mob:set_yaw(angle-math.pi/2) + if mob then + mob:set_yaw(angle-math.pi/2) + end angle = angle + (math.pi*2) / 3 end diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 2be0be4bc..f5a9574eb 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -1,5 +1,6 @@ local S = minetest.get_translator(minetest.get_current_modname()) local F = minetest.formspec_escape +local C = minetest.colorize -- Prepare player info table local players = {} @@ -289,6 +290,19 @@ filtername["inv"] = S("Survival Inventory") bg["default"] = dark_bg end]] +local function get_stack_size(player) + return player:get_meta():get_int("mcl_inventory:switch_stack") +end + +local function set_stack_size(player, n) + player:get_meta():set_int("mcl_inventory:switch_stack", n) +end + +minetest.register_on_joinplayer(function (player) + if get_stack_size(player) == 0 then + set_stack_size(player, 64) + end +end) function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, show, page, filter) --reset_menu_item_bg() @@ -349,6 +363,8 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, armor_slot_imgs = armor_slot_imgs .. "image[5.5,2.75;1,1;mcl_inventory_empty_armor_slot_boots.png]" end + local stack_size = get_stack_size(player) + -- Survival inventory slots main_list = "list[current_player;main;0,3.75;9,3;9]".. mcl_formspec.get_itemslot_bg(0,3.75,9,3).. @@ -376,7 +392,11 @@ function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, -- achievements button "image_button[9,4;1,1;mcl_achievements_button.png;__mcl_achievements;]".. --"style_type[image_button;border=;bgimg=;bgimg_pressed=]".. - "tooltip[__mcl_achievements;"..F(S("Achievements")).."]" + "tooltip[__mcl_achievements;"..F(S("Achievements")).."]".. + -- switch stack size button + "image_button[9,5;1,1;default_apple.png;__switch_stack;]".. + "label[9.4,5.4;".. F(C("#FFFFFF", stack_size ~= 1 and stack_size or "")) .."]".. + "tooltip[__switch_stack;"..F(S("Switch stack size")).."]" -- For shortcuts listrings = listrings .. @@ -544,6 +564,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) elseif fields.search and not fields.creative_next and not fields.creative_prev then set_inv_search(string.lower(fields.search),player) page = "nix" + elseif fields.__switch_stack then + local switch = 1 + if get_stack_size(player) == 1 then + switch = 64 + end + set_stack_size(player, switch) end if page then @@ -667,3 +693,11 @@ minetest.register_on_joinplayer(function(player) init(player) mcl_inventory.set_creative_formspec(player, 0, 1, nil, false, "nix", "") end) + +minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info) + if minetest.is_creative_enabled(player:get_player_name()) and get_stack_size(player) == 64 and action == "put" and inventory_info.listname == "main" then + local stack = inventory_info.stack + stack:set_count(stack:get_stack_max()) + player:get_inventory():set_stack("main", inventory_info.index, stack) + end +end) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 47acacbb9..0cd0608c4 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -82,7 +82,7 @@ local dispenserdef = { end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -92,7 +92,7 @@ local dispenserdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, _mcl_blast_resistance = 3.5, _mcl_hardness = 3.5, diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index b5bcc1d08..abb351091 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -55,7 +55,7 @@ local dropperdef = { sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -65,7 +65,7 @@ local dropperdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua index 5409e6abc..bd8c0a3c3 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init_new.lua @@ -53,7 +53,7 @@ local dropperdef = { sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1, inv:get_size("main") do @@ -63,7 +63,7 @@ local dropperdef = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 343707617..7529da167 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -73,7 +73,7 @@ local ARROW_ENTITY={ _stuckin=nil, --Position of node in which arow is stuck. _shooter=nil, -- ObjectRef of player or mob who shot it _is_arrow = true, - + _in_player = false, _viscosity=0, -- Viscosity of node the arrow is currently in _deflection_cooloff=0, -- Cooloff timer after an arrow deflection, to prevent many deflections in quick succession } @@ -439,6 +439,7 @@ function ARROW_ENTITY.get_staticdata(self) is_critical = self._is_critical, stuck = self._stuck, stuckin = self._stuckin, + stuckin_player = self._in_player, } if self._stuck then -- If _stucktimer is missing for some reason, assume the maximum @@ -455,7 +456,6 @@ end function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) self._time_in_air = 1.0 - self._in_player = false local data = minetest.deserialize(staticdata) if data then self._stuck = data.stuck @@ -488,10 +488,23 @@ function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) self._shooter = shooter end end + + if data.stuckin_player then + self.object:remove() + end end self.object:set_armor_groups({ immortal = 1 }) end +minetest.register_on_respawnplayer(function(player) + for _, obj in pairs(player:get_children()) do + local ent = obj:get_luaentity() + if ent and ent.name and string.find(ent.name, "mcl_bows:arrow_entity") then + obj:remove() + end + end +end) + minetest.register_entity("mcl_bows:arrow_entity", ARROW_ENTITY) if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then diff --git a/mods/ITEMS/mcl_bows/crossbow.lua b/mods/ITEMS/mcl_bows/crossbow.lua index e3124156b..5ae21a1f3 100644 --- a/mods/ITEMS/mcl_bows/crossbow.lua +++ b/mods/ITEMS/mcl_bows/crossbow.lua @@ -92,7 +92,7 @@ local function get_arrow(player) return arrow_stack, arrow_stack_id end -local function player_shoot_arrow(itemstack, player, power, damage, is_critical) +local function player_shoot_arrow(wielditem, player, power, damage, is_critical) local has_multishot_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "multishot") local arrow_itemstring = wielditem:get_meta():get("arrow") @@ -286,7 +286,7 @@ end) controls.register_on_press(function(player, key, time) if key~="LMB" then return end - wielditem = player:get_wielded_item() + local wielditem = player:get_wielded_item() if wielditem:get_name()=="mcl_bows:crossbow_loaded" or wielditem:get_name()=="mcl_bows:crossbow_loaded_enchanted" then local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name()) local speed, damage diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 69f6a601d..ad5c781f7 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -293,7 +293,7 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile local function drop_items_chest(pos, oldnode, oldmetadata) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() if oldmetadata then meta:from_table(oldmetadata) end @@ -305,7 +305,7 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end local function on_chest_blast(pos) @@ -608,10 +608,12 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") - if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 - or minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name].groups.opaque == 1 then - -- won't open if there is no space from the top - return false + local above_def = minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name] + local above_def_other = minetest.registered_nodes[minetest.get_node({x = pos_other.x, y = pos_other.y + 1, z = pos_other.z}).name] + + if not above_def or above_def.groups.opaque == 1 or not above_def_other or above_def_other.groups.opaque == 1 then + -- won't open if there is no space from the top + return false end local name = minetest.get_meta(pos):get_string("name") @@ -1053,6 +1055,20 @@ minetest.register_on_joinplayer(function(player) inv:set_size("enderchest", 9*3) end) +minetest.register_allow_player_inventory_action(function(player, action, inv, info) + if inv:get_location().type == "player" and ( + action == "move" and (info.from_list == "enderchest" or info.to_list == "enderchest") + or action == "put" and info.listname == "enderchest" + or action == "take" and info.listname == "enderchest" + ) then + local def = player:get_wielded_item():get_definition() + + if not minetest.find_node_near(player:get_pos(), def and def.range or ItemStack():get_definition().range, "mcl_chests:ender_chest_small", true) then + return 0 + end + end +end) + minetest.register_craft({ output = "mcl_chests:ender_chest", recipe = { diff --git a/mods/ITEMS/mcl_core/nodes_glass.lua b/mods/ITEMS/mcl_core/nodes_glass.lua index 6e7ab350b..8b3aea689 100644 --- a/mods/ITEMS/mcl_core/nodes_glass.lua +++ b/mods/ITEMS/mcl_core/nodes_glass.lua @@ -5,10 +5,11 @@ local mod_doc = minetest.get_modpath("doc") minetest.register_node("mcl_core:glass", { description = S("Glass"), _doc_items_longdesc = S("A decorative and mostly transparent block."), - drawtype = "glasslike", + drawtype = "glasslike_framed_optional", is_ground_content = false, - tiles = {"default_glass.png"}, + tiles = {"default_glass.png", "default_glass_detail.png"}, paramtype = "light", + paramtype2 = "glasslikeliquidlevel", sunlight_propagates = true, stack_max = 64, groups = {handy=1, glass=1, building_block=1, material_glass=1}, @@ -39,10 +40,11 @@ function mcl_core.add_stained_glass(desc, recipeitem, colorgroup, color) _doc_items_create_entry = create_entry, _doc_items_entry_name = entry_name, _doc_items_longdesc = longdesc, - drawtype = "glasslike", + drawtype = "glasslike_framed_optional", is_ground_content = false, - tiles = {"mcl_core_glass_"..color..".png"}, + tiles = {"mcl_core_glass_"..color..".png", "mcl_core_glass_"..color.."_detail.png"}, paramtype = "light", + paramtype2 = "glasslikeliquidlevel", sunlight_propagates = true, use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, stack_max = 64, diff --git a/mods/ITEMS/mcl_core/textures/default_glass_detail.png b/mods/ITEMS/mcl_core/textures/default_glass_detail.png new file mode 100644 index 000000000..791309817 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/default_glass_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_black_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_black_detail.png new file mode 100644 index 000000000..48bcb54c4 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_black_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_blue_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_blue_detail.png new file mode 100644 index 000000000..0d026ce7c Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_blue_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_brown_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_brown_detail.png new file mode 100644 index 000000000..e012b08f2 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_brown_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_cyan_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_cyan_detail.png new file mode 100644 index 000000000..92dedaa84 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_cyan_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_gray_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_gray_detail.png new file mode 100644 index 000000000..f7daeba19 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_gray_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_green_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_green_detail.png new file mode 100644 index 000000000..fb54f942b Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_green_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_light_blue_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_light_blue_detail.png new file mode 100644 index 000000000..5c7a34fce Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_light_blue_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_lime_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_lime_detail.png new file mode 100644 index 000000000..963933572 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_lime_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_magenta_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_magenta_detail.png new file mode 100644 index 000000000..8a1ffeda8 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_magenta_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_orange_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_orange_detail.png new file mode 100644 index 000000000..4894833f1 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_orange_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_pink_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_pink_detail.png new file mode 100644 index 000000000..38bd3a8c3 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_pink_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_purple_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_purple_detail.png new file mode 100644 index 000000000..a31284094 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_purple_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_red_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_red_detail.png new file mode 100644 index 000000000..db44333b2 Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_red_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_silver_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_silver_detail.png new file mode 100644 index 000000000..8ff77440a Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_silver_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_white_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_white_detail.png new file mode 100644 index 000000000..baddd95eb Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_white_detail.png differ diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_glass_yellow_detail.png b/mods/ITEMS/mcl_core/textures/mcl_core_glass_yellow_detail.png new file mode 100644 index 000000000..83eedf08b Binary files /dev/null and b/mods/ITEMS/mcl_core/textures/mcl_core_glass_yellow_detail.png differ diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index 02425945c..97a176b97 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -123,7 +123,7 @@ function mcl_enchanting.can_enchant(itemstack, enchantment, level) if itemname == "" then return false, "item missing" end - local supported, primary = mcl_enchanting.item_supports_enchantment(itemstack:get_name(), enchantment) + local supported, primary = mcl_enchanting.item_supports_enchantment(itemname, enchantment) if not supported then return false, "item not supported" end @@ -132,7 +132,7 @@ function mcl_enchanting.can_enchant(itemstack, enchantment, level) end if level > enchantment_def.max_level then return false, "level too high", enchantment_def.max_level - elseif level < 1 then + elseif level < 1 then return false, "level too small", 1 end local item_enchantments = mcl_enchanting.get_enchantments(itemstack) @@ -295,115 +295,125 @@ function mcl_enchanting.initialize() end end -function mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure) - local possible_enchantments, weights, accum_weight = {}, {}, 0 - for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do - local _, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) - if primary or treasure then - table.insert(possible_enchantments, enchantment) - accum_weight = accum_weight + enchantment_def.weight - weights[enchantment] = accum_weight - end +function mcl_enchanting.random(pr, ...) + local r = pr and pr:next(...) or math.random(...) + + if pr and not ({...})[1] then + r = r / 32767 end - return possible_enchantments, weights, accum_weight + + return r end -function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.get_random_enchantment(itemstack, treasure, weighted, exclude, pr) + local possible = {} + + for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do + local can_enchant, _, _, primary = mcl_enchanting.can_enchant(itemstack, enchantment, 1) + + if can_enchant and (primary or treasure) and (not exclude or table.indexof(exclude, enchantment) == -1) then + local weight = weighted and enchantment_def.weight or 1 + + for i = 1, weight do + table.insert(possible, enchantment) + end + end + end + + return #possible > 0 and possible[mcl_enchanting.random(pr, 1, #possible)] +end + +function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) local itemname = itemstack:get_name() + if not mcl_enchanting.can_enchant_freshly(itemname) and not ignore_already_enchanted then return end + itemstack = ItemStack(itemstack) + local enchantability = minetest.get_item_group(itemname, "enchantability") - enchantability = 1 + math.random(0, math.floor(enchantability / 4)) + math.random(0, math.floor(enchantability / 4)) + enchantability = 1 + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4)) + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4)) + enchantment_level = enchantment_level + enchantability - enchantment_level = enchantment_level + enchantment_level * (math.random() + math.random() - 1) * 0.15 + enchantment_level = enchantment_level + enchantment_level * (mcl_enchanting.random(pr) + mcl_enchanting.random(pr) - 1) * 0.15 enchantment_level = math.max(math.floor(enchantment_level + 0.5), 1) + local enchantments = {} local description + enchantment_level = enchantment_level * 2 + repeat enchantment_level = math.floor(enchantment_level / 2) + if enchantment_level == 0 then break end - local possible, weights, accum_weight = mcl_enchanting.get_possible_enchantments(itemstack, enchantment_level, treasure) - local selected_enchantment, enchantment_power - if #possible > 0 then - local r = math.random(accum_weight) - for _, enchantment in ipairs(possible) do - if weights[enchantment] >= r then - selected_enchantment = enchantment - break - end - end - local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] - local power_range_table = enchantment_def.power_range_table - for i = enchantment_def.max_level, 1, -1 do - local power_range = power_range_table[i] - if enchantment_level >= power_range[1] and enchantment_level <= power_range[2] then - enchantment_power = i - break - end - end - if not description then - if not enchantment_power then - return - end - description = mcl_enchanting.get_enchantment_description(selected_enchantment, enchantment_power) - end - if enchantment_power then - enchantments[selected_enchantment] = enchantment_power - mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power) - end - else + + local selected_enchantment = mcl_enchanting.get_random_enchantment(itemstack, treasure, true, nil, pr) + + if not selected_enchantment then break end - until not no_reduced_bonus_chance and math.random() >= (enchantment_level + 1) / 50 + + local enchantment_def = mcl_enchanting.enchantments[selected_enchantment] + local power_range_table = enchantment_def.power_range_table + + local enchantment_power + + for i = enchantment_def.max_level, 1, -1 do + local power_range = power_range_table[i] + if enchantment_level >= power_range[1] and enchantment_level <= power_range[2] then + enchantment_power = i + break + end + end + + if not description then + if not enchantment_power then + return + end + + description = mcl_enchanting.get_enchantment_description(selected_enchantment, enchantment_power) + end + + if enchantment_power then + enchantments[selected_enchantment] = enchantment_power + mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power) + end + + until not no_reduced_bonus_chance and mcl_enchanting.random(pr) >= (enchantment_level + 1) / 50 + return enchantments, description end -function mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) local enchantments + repeat - enchantments = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) + enchantments = mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) until enchantments + return enchantments end -function mcl_enchanting.enchant_randomly(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted) +function mcl_enchanting.enchant_randomly(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) + local enchantments = mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr) + mcl_enchanting.set_enchanted_itemstring(itemstack) - mcl_enchanting.set_enchantments(itemstack, mcl_enchanting.generate_random_enchantments_reliable(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted)) + mcl_enchanting.set_enchantments(itemstack, enchantments) + return itemstack end -function mcl_enchanting.get_randomly_enchanted_book(enchantment_level, treasure, no_reduced_bonus_chance) - return mcl_enchanting.enchant_randomly(ItemStack("mcl_books:book"), enchantment_level, treasure, no_reduced_bonus_chance, true) -end +function mcl_enchanting.enchant_uniform_randomly(stack, exclude, pr) + local enchantment = mcl_enchanting.get_random_enchantment(stack, true, false, exclude, pr) -function mcl_enchanting.get_uniform_randomly_enchanted_book(except, pr) - except = except or except - local stack = ItemStack("mcl_enchanting:book_enchanted") - local list = {} - for enchantment in pairs(mcl_enchanting.enchantments) do - if table.indexof(except, enchantment) == -1 then - table.insert(list, enchantment) - end + if enchantment then + mcl_enchanting.enchant(stack, enchantment, mcl_enchanting.random(pr, 1, mcl_enchanting.enchantments[enchantment].max_level)) end - local index, level - if pr then - index = pr:next(1,#list) - else - index = math.random(#list) - end - local enchantment = list[index] - local enchantment_def = mcl_enchanting.enchantments[enchantment] - if pr then - level = pr:next(1, enchantment_def.max_level) - else - level = math.random(enchantment_def.max_level) - end - mcl_enchanting.enchant(stack, enchantment, level) + return stack end diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 1d9ca012c..0eb71ac91 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -129,7 +129,7 @@ if minetest.get_modpath("mcl_armor") then pumpkin_blur = player:hud_add({ hud_elem_type = "image", position = {x = 0.5, y = 0.5}, - scale = {x = -100, y = -100}, + scale = {x = -101, y = -101}, text = "mcl_farming_pumpkin_hud.png", z_index = -200 }), diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index ade0be818..788e591dc 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -71,7 +71,9 @@ local fish = function(itemstack, player, pointed_thing) { itemstring = "mcl_fishing:salmon_raw", weight = 25 }, { itemstring = "mcl_fishing:clownfish_raw", weight = 2 }, { itemstring = "mcl_fishing:pufferfish_raw", weight = 13 }, - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) elseif r <= junk_value then -- Junk @@ -88,21 +90,29 @@ local fish = function(itemstack, player, pointed_thing) { itemstring = "mcl_mobitems:bone", weight = 10 }, { itemstring = "mcl_dye:black", weight = 1, amount_min = 10, amount_max = 10 }, { itemstring = "mcl_mobitems:string", weight = 10 }, -- TODO: Tripwire Hook - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) else -- Treasure items = mcl_loot.get_loot({ items = { - -- TODO: Enchanted Bow - { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage - { itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)}, - -- TODO: Enchanted Fishing Rod - { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage + { itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535, func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, false, false, pr) + end }, -- 75%-100% damage + { itemstring = "mcl_books:book", func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, true, false, pr) + end }, + { itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535, func = function(stack, pr) + mcl_enchanting.enchant_randomly(stack, 30, true, false, false, pr) + end }, -- 75%-100% damage { itemstring = "mcl_mobs:nametag", }, { itemstring = "mcl_mobitems:saddle", }, { itemstring = "mcl_flowers:waterlily", }, - } + }, + stacks_min = 1, + stacks_max = 1, }, pr) end local item diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index dca476762..9f836d161 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -461,7 +461,7 @@ minetest.register_node("mcl_furnaces:furnace", { on_timer = furnace_node_timer, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for _, listname in ipairs({"src", "dst", "fuel"}) do @@ -471,7 +471,7 @@ minetest.register_node("mcl_furnaces:furnace", { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, on_construct = function(pos) diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 9defa26ca..36a21ad95 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -61,7 +61,7 @@ local def_hopper = { after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) - local meta2 = meta + local meta2 = meta:to_table() meta:from_table(oldmetadata) local inv = meta:get_inventory() for i=1,inv:get_size("main") do @@ -71,7 +71,7 @@ local def_hopper = { minetest.add_item(p, stack) end end - meta:from_table(meta2:to_table()) + meta:from_table(meta2) end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local name = player:get_player_name() @@ -350,7 +350,7 @@ minetest.register_abm({ local inv = meta:get_inventory() for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do - if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then + if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and not object:get_luaentity()._removed then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then -- Item must get sucked in when the item just TOUCHES the block above the hopper -- This is the reason for the Y calculation. diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index 6e4b24c96..0795fb611 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -230,7 +230,7 @@ local function spawn_mobs(pos, elapsed) -- spawn up to 4 mobs in random air blocks if air then - local max = 200 + local max = 4 if spawn_count_overrides[mob] then max = spawn_count_overrides[mob] end diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 3f15a134d..46025619c 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -237,6 +237,11 @@ local function destroy_nether_portal(pos, node) check_remove({x = pos.x, y = pos.y + 1, z = pos.z}) end +local on_rotate +if minetest.get_modpath("screwdriver") then + on_rotate = screwdriver.disallow +end + minetest.register_node(PORTAL, { description = S("Nether Portal"), _doc_items_longdesc = S("A Nether portal teleports creatures and objects to the hot and dangerous Nether dimension (and back!). Enter at your own risk!"), @@ -286,6 +291,7 @@ minetest.register_node(PORTAL, { groups = { creative_breakable = 1, portal = 1, not_in_creative_inventory = 1 }, sounds = mcl_sounds.node_sound_glass_defaults(), after_destruct = destroy_nether_portal, + on_rotate = on_rotate, _mcl_hardness = -1, _mcl_blast_resistance = 0, diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index 58e23b12e..905e26396 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -63,6 +63,67 @@ local surround_vectors = { { x=0, y=0, z=1 }, } +local loottable = +{ + { + stacks_min = 1, + stacks_max = 3, + items = { + { itemstring = "mcl_mobs:nametag", weight = 20 }, + { itemstring = "mcl_mobitems:saddle", weight = 20 }, + { itemstring = "mcl_jukebox:record_1", weight = 15 }, + { itemstring = "mcl_jukebox:record_4", weight = 15 }, + { itemstring = "mobs_mc:iron_horse_armor", weight = 15 }, + { itemstring = "mcl_core:apple_gold", weight = 15 }, + { itemstring = "mcl_books:book", weight = 10, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, + { itemstring = "mobs_mc:gold_horse_armor", weight = 10 }, + { itemstring = "mobs_mc:diamond_horse_armor", weight = 5 }, + { itemstring = "mcl_core:apple_gold_enchanted", weight = 2 }, + } + }, + { + stacks_min = 1, + stacks_max = 4, + items = { + { itemstring = "mcl_farming:wheat_item", weight = 20, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_farming:bread", weight = 20 }, + { itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 }, + { itemstring = "mesecons:redstone", weight = 15, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_farming:beetroot_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_farming:melon_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_farming:pumpkin_seeds", weight = 10, amount_min = 2, amount_max = 4 }, + { itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 4 }, + { itemstring = "mcl_buckets:bucket_empty", weight = 10 }, + { itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 4 }, + }, + }, + { + stacks_min = 3, + stacks_max = 3, + items = { + { itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 }, + { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, + }, + } +} + +-- Bonus loot for v6 mapgen: Otherwise unobtainable saplings. +if mg_name == "v6" then + table.insert(loottable, { + stacks_min = 1, + stacks_max = 3, + items = { + { itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 }, + { itemstring = "mcl_core:acaciasapling", weight = 1, amount_min = 1, amount_max = 2 }, + { itemstring = "", weight = 6 }, + }, + }) +end + local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) if calls_remaining >= 1 then return end @@ -310,66 +371,6 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) set_node(pos, {name="mcl_chests:chest", param2=facedir}) local meta = get_meta(pos) - - local loottable = - { - { - stacks_min = 1, - stacks_max = 3, - items = { - { itemstring = "mcl_mobs:nametag", weight = 20 }, - { itemstring = "mcl_mobitems:saddle", weight = 20 }, - { itemstring = "mcl_jukebox:record_1", weight = 15 }, - { itemstring = "mcl_jukebox:record_4", weight = 15 }, - { itemstring = "mobs_mc:iron_horse_armor", weight = 15 }, - { itemstring = "mcl_core:apple_gold", weight = 15 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 10 }, - { itemstring = "mobs_mc:gold_horse_armor", weight = 10 }, - { itemstring = "mobs_mc:diamond_horse_armor", weight = 5 }, - { itemstring = "mcl_core:apple_gold_enchanted", weight = 2 }, - } - }, - { - stacks_min = 1, - stacks_max = 4, - items = { - { itemstring = "mcl_farming:wheat_item", weight = 20, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_farming:bread", weight = 20 }, - { itemstring = "mcl_core:coal_lump", weight = 15, amount_min = 1, amount_max = 4 }, - { itemstring = "mesecons:redstone", weight = 15, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_farming:beetroot_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_farming:melon_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_farming:pumpkin_seeds", weight = 10, amount_min = 2, amount_max = 4 }, - { itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 4 }, - { itemstring = "mcl_buckets:bucket_empty", weight = 10 }, - { itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 4 }, - }, - }, - { - stacks_min = 3, - stacks_max = 3, - items = { - { itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 }, - { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, - }, - } - } - - -- Bonus loot for v6 mapgen: Otherwise unobtainable saplings. - if mg_name == "v6" then - table_insert(loottable, { - stacks_min = 1, - stacks_max = 3, - items = { - { itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 }, - { itemstring = "mcl_core:acaciasapling", weight = 1, amount_min = 1, amount_max = 2 }, - { itemstring = "", weight = 6 }, - }, - }) - end - minetest.log("action", "[mcl_dungeons] Filling chest " .. tostring(c) .. " at " .. minetest.pos_to_string(pos)) mcl_loot.fill_inventory(meta:get_inventory(), "main", mcl_loot.get_multi_loot(loottable, pr), pr) end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 533c9cab0..be1be0f67 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -454,7 +454,9 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) { itemstring = "mcl_mobitems:bone", weight = 25, amount_min = 4, amount_max=6 }, { itemstring = "mcl_mobitems:rotten_flesh", weight = 25, amount_min = 3, amount_max=7 }, { itemstring = "mcl_mobitems:spider_eye", weight = 25, amount_min = 1, amount_max=3 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 20, }, + { itemstring = "mcl_books:book", weight = 20, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, { itemstring = "mcl_mobitems:saddle", weight = 20, }, { itemstring = "mcl_core:apple_gold", weight = 20, }, { itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 }, diff --git a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua index 168ecf535..de4b18119 100644 --- a/mods/MAPGEN/tsm_railcorridors/gameconfig.lua +++ b/mods/MAPGEN/tsm_railcorridors/gameconfig.lua @@ -66,7 +66,9 @@ function tsm_railcorridors.get_treasures(pr) items = { { itemstring = "mcl_mobs:nametag", weight = 30 }, { itemstring = "mcl_core:apple_gold", weight = 20 }, - { itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}, pr), weight = 10 }, + { itemstring = "mcl_books:book", weight = 10, func = function(stack, pr) + mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr) + end }, { itemstring = "", weight = 5}, { itemstring = "mcl_core:pick_iron", weight = 5 }, { itemstring = "mcl_core:apple_gold_enchanted", weight = 1 }, diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index f86d5e26a..50fec2bd6 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -550,7 +550,8 @@ mcl_damage.register_modifier(function(obj, damage, reason) node = minetest.get_node(pos) end if node then - if minetest.registered_nodes[node.name].walkable then + local def = minetest.registered_nodes[node.name] + if not def or def.walkable then return end if minetest.get_item_group(node.name, "water") ~= 0 then