2 local switched_to_totem = 0
3 local used_sneak = true
4 local totem_move_action = InventoryAction("move")
5 totem_move_action:to("current_player", "main", 9)
7 minetest.register_globalstep(function(dtime)
8 local player = minetest.localplayer
9 if not player then return end
10 local control = player:get_control()
11 local pointed = minetest.get_pointed_thing()
12 local item = player:get_wielded_item():get_name()
13 if minetest.settings:get_bool("crystal_pvp") then
14 if placed_crystal then
15 if minetest.switch_to_item("mobs_mc:totem") then
18 placed_crystal = false
19 elseif switched_to_totem > 0 then
20 if item ~= "mobs_mc:totem" then
22 elseif pointed and pointed.type == "object" then
26 switched_to_totem = switched_to_totem
28 elseif control.place and item == "mcl_end:crystal" then
30 elseif control.sneak then
31 if pointed and pointed.type == "node" and not used_sneak then
32 local pos = minetest.get_pointed_thing_position(pointed)
33 local node = minetest.get_node_or_nil(pos)
34 if node and (node.name == "mcl_core:obsidian" or node.name == "mcl_core:bedrock") then
35 minetest.switch_to_item("mcl_end:crystal")
36 minetest.place_node(pos)
46 if minetest.settings:get_bool("autototem") then
47 local totem_stack = minetest.get_inventory("current_player").main[9]
48 if totem_stack and totem_stack:get_name() ~= "mobs_mc:totem" then
49 local totem_index = minetest.find_item("mobs_mc:totem")
51 totem_move_action:from("current_player", "main", totem_index)
52 totem_move_action:apply()
53 player:set_wield_index(9)
59 minetest.register_cheat("CrystalPvP", "Combat", "crystal_pvp")
60 minetest.register_cheat("AutoTotem", "Combat", "autototem")