From 8b4e3c3db008b02a18fd909a863cc20e50fcf175 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 11 Sep 2022 23:44:33 +0200 Subject: [PATCH] Fix loot, elytra and shulker spawning --- mods/ENTITIES/mobs_mc/shulker.lua | 3 +- mods/ITEMS/mcl_itemframes/init.lua | 2 ++ mods/MAPGEN/mcl_structures/api.lua | 13 +++---- mods/MAPGEN/mcl_structures/end_city.lua | 34 +++++++++++++----- .../mcl_structures_end_shipwreck_1.mts | Bin 1465 -> 1427 bytes 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/shulker.lua b/mods/ENTITIES/mobs_mc/shulker.lua index 2673da92d..e988a7c73 100644 --- a/mods/ENTITIES/mobs_mc/shulker.lua +++ b/mods/ENTITIES/mobs_mc/shulker.lua @@ -18,8 +18,9 @@ local adjacents = { vector.new(0,0,-1), } local function check_spot(pos) + pos = vector.offset(pos,0,0.5,0) local n = minetest.get_node(pos) - if n.name~="air" then return false end + if n.name ~="air" then return false end for _,a in pairs(adjacents) do local p = vector.add(pos,a) local pn = minetest.get_node(p) diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index eac5b066b..6fda0176e 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -1,3 +1,4 @@ +mcl_itemframes = {} local S = minetest.get_translator(minetest.get_current_modname()) local VISUAL_SIZE = 0.3 @@ -132,6 +133,7 @@ local update_item_entity = function(pos, node, param2) end end end +mcl_itemframes.update_item_entity = update_item_entity local drop_item = function(pos, node, meta, clicker) local cname = "" diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 443dfb584..4995cccee 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -5,7 +5,7 @@ if disabled_structures then disabled_structures = disabled_structures:split(",") else disabled_structures = {} end function mcl_structures.is_disabled(structname) - if table.indexof(disabled_structures,structname) ~= -1 then return true end + return table.indexof(disabled_structures,structname) ~= -1 end function mcl_structures.fill_chests(p1,p2,loot,pr) @@ -31,10 +31,7 @@ end local function construct_nodes(pos,def,pr) local nn = minetest.find_nodes_in_area(vector.offset(pos,-def.sidelen/2,0,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) for _,p in pairs(nn) do - local def = minetest.registered_nodes[minetest.get_node(p).name] - if def and def.on_construct then - def.on_construct(p) - end + mcl_structures.init_node_construct(p) end end @@ -187,8 +184,8 @@ function mcl_structures.place_structure(pos, def, pr, blockseed) end return true end - elseif def.place_func and def.place_func(pos,def,pr,blockseed) then - if not def.after_place or ( def.after_place and def.after_place(pos,def,pr,blockseed) ) then + elseif def.place_func and def.place_func(pp,def,pr,blockseed) then + if not def.after_place or ( def.after_place and def.after_place(pp,def,pr,blockseed) ) then if def.loot then generate_loot(pp,def,pr,blockseed) end if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end if logging then @@ -231,12 +228,12 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it y_max = def.y_max, y_min = def.y_min }) - minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups}) def.structblock = structblock def.deco_id = minetest.get_decoration_id("mcl_structures:deco_"..name) minetest.set_gen_notify({decoration=true}, { def.deco_id }) --catching of gennotify happens in mcl_mapgen_core + end) end end diff --git a/mods/MAPGEN/mcl_structures/end_city.lua b/mods/MAPGEN/mcl_structures/end_city.lua index 11e5b6fbf..bf937c7f7 100644 --- a/mods/MAPGEN/mcl_structures/end_city.lua +++ b/mods/MAPGEN/mcl_structures/end_city.lua @@ -3,13 +3,17 @@ local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) local function spawn_shulkers(pos,def,pr) - local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),def.construct_nodes) + local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,def.sidelen,def.sidelen/2),{"mcl_end:purpur_block"}) if nn and #nn > 0 then - local n = pr:next(1,#nn) - for i = 1,n do - minetest.add_entity(vector.offset(nn[i],0,1,0),"mobs_mc:shulker") + table.shuffle(nn) + for i = 1,pr:next(1,math.min(6,#nn)) do + minetest.add_entity(vector.offset(nn[i],0,0.5,0),"mobs_mc:shulker") end end + local guard = minetest.find_node_near(pos,def.sidelen,{"mcl_itemframes:item_frame"}) + if guard then + minetest.add_entity(vector.offset(guard,0,-1.5,0),"mobs_mc:shulker") + end end mcl_structures.register_structure("end_shipwreck",{ @@ -25,9 +29,24 @@ mcl_structures.register_structure("end_shipwreck",{ filenames = { modpath.."/schematics/mcl_structures_end_shipwreck_1.mts", }, - construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, - after_place = spawn_shulkers, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000","mcl_chests:violet_shulker_box_small"}, + after_place = function(pos,def,pr) + local fr = minetest.find_node_near(pos,def.sidelen,{"mcl_itemframes:item_frame"}) + if fr then + if mcl_itemframes then + mcl_itemframes.update_item_entity(fr,minetest.get_node(fr)) + end + end + return spawn_shulkers(pos,def,pr) + end, loot = { + [ "mcl_itemframes:item_frame" ] ={{ + stacks_min = 1, + stacks_max = 1, + items = { + { itemstring = "mcl_armor:elytra", weight = 100 }, + }, + }}, [ "mcl_chests:chest_small" ] ={{ stacks_min = 2, stacks_max = 6, @@ -62,7 +81,6 @@ mcl_structures.register_structure("end_shipwreck",{ { itemstring = "mcl_mobitems:gold_horse_armor", weight = 1, }, { itemstring = "mcl_mobitems:diamond_horse_armor", weight = 1, }, { itemstring = "mcl_core:apple_gold_enchanted", weight = 2, }, - { itemstring = "mcl_elytra:elytra", weight = 1, }, } }} } @@ -82,7 +100,7 @@ mcl_structures.register_structure("end_boat",{ modpath.."/schematics/mcl_structures_end_boat.mts", }, after_place = spawn_shulkers, - construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000"}, + construct_nodes = {"mcl_chests:ender_chest_small","mcl_chests:ender_chest","mcl_brewing:stand_000","mcl_chests:violet_shulker_box_small"}, loot = { [ "mcl_chests:chest_small" ] ={{ stacks_min = 2, diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_shipwreck_1.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_shipwreck_1.mts index 685c1f4fd8243d0a41c340b09d6f69ad40194eaf..5daad2f3d038f9806342e5001e46d38d51f9b8f6 100644 GIT binary patch delta 776 zcmV+j1NZ#73zG|wAORb(A=Ckr8Un0;dYdo|g>48~7PhWifo^-*z52jlBVPnIjN5vC zxBU{NW1C_r3Kt>33Z!c3WU4LGc0(9KwnKog$%TeG>)w8zvt#C zQlfWM=7~|?D~qFGPijb01^mA;QZ%UDCYV$rI&5Iizi@))pP7(|Ll=4ASxm z>B9Rv=M#p`?2bGUO&PJ}Oq_dmYnhApR23h$l3BBlNhPQ1Dr81glO z(p#Z1wS3opSh`O2re2joN1gu9YDJ$hUc9j?qZ33|vw1?Qcjd4TrO6YeqY>@b6XW}(^~C$B>xrM@SESAb^+X!yp51zmI6sl8>O%WZXBc{Z zf_{g<`H2{Ceqt}qJ-g%B|9XcV`&YW&@q75i^$q~G1ouzG(tG3n2>{lC`!T_X;12)* z00000000000001RF^)cew?0EvRYy+&>_+7fwgrUh_Q}a>b<2%2;0j?R+=1;(t{-D^ zHbkWc{|O??2(~8SxCc%8;MK;@8>05MP@&Ie$zW?9-iv?S?>2w^+ zvKbTAkwcmr_sr9YOW7tiud+>GJv-Vo4QJ}8LzX3ZLTgOEL7s@~cPAQxYjXTJlcF|$ ztSJ`M6I{P1AYr{UjLF&HFPH$AT@!$%shaL*_|t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