From 48204108c7e4970f3c77ab88db08c88051d5f5db Mon Sep 17 00:00:00 2001 From: ThePython Date: Sun, 26 Mar 2023 15:19:19 -0700 Subject: [PATCH] Breaking might drop contents now --- README.md | 15 ++++++++++----- constructor.lua | 15 ++++++++++++++- deconstructor.lua | 15 ++++++++++++++- energy_collector.lua | 15 ++++++++++++++- orb.lua | 6 ++++++ 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2ca95b9..2b63b08 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,23 @@ ![GitHub license](https://img.shields.io/github/license/thepython10110/minetest_exchangeclone) ![GitHub issues](https://img.shields.io/github/issues/thepython10110/minetest_exchangeclone) -A [Minetest](https://www.minetest.net/) mod to exchange nodes into other nodes. This is mod is inspired by the "Equivalent Exchange" mod for Minecraft, and forked and modified from [Element Exchange](https://github.com/enchant97/minetest_element_exchange). In other words, 90% of the code is not mine. +A [Minetest](https://www.minetest.net/) mod to exchange nodes into other nodes. This is mod is inspired by the "Equivalent Exchange" mod for MineCraft, and forked and modified from [Element Exchange](https://github.com/enchant97/minetest_element_exchange). In other words, most of the code is not mine. ![In Game Screenshot](screenshot.png) ## Features -- Orb that holds energy +- Orb that holds energy (left click while holding it to show charge) - Collector that collects energy from the sun -- Constructor that can convert one node into different node -- Deconstructor that can extract energy from a node +- Deconstructor that can turn nodes into energy +- Constructor that can create nodes from energy ## Config -You can change the default values in the minetest settings under `mods > exchangeclone`. +You can change the default values in the Minetest settings under `mods > exchangeclone`. + +## New features added by ThePython10110 +Support for MineClone, including hoppers. +Shift-clicking mostly works (ListRings). +Fixed a bug where items could be placed in the output slot of the Element Constructor. ## Original License Copyright (C) 2021 Leo Spratt diff --git a/constructor.lua b/constructor.lua index ce998bd..d26a878 100644 --- a/constructor.lua +++ b/constructor.lua @@ -161,7 +161,20 @@ minetest.register_node("exchangeclone:element_constructor", { }, groups = {cracky = 2, container = 4}, is_ground_content = false, - can_dig=can_dig, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + local meta = minetest.get_meta(pos) + local meta2 = meta:to_table() + meta:from_table(oldmetadata) + local inv = meta:get_inventory() + for _, listname in ipairs({"src", "dst", "fuel"}) do + local stack = inv:get_stack(listname, 1) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2) + end, on_timer = on_timer, on_construct = on_construct, on_metadata_inventory_move = function(pos) diff --git a/deconstructor.lua b/deconstructor.lua index bc8334b..2f24e6e 100644 --- a/deconstructor.lua +++ b/deconstructor.lua @@ -133,7 +133,20 @@ minetest.register_node("exchangeclone:element_deconstructor", { }, groups = {cracky = 2, container = 3}, is_ground_content = false, - can_dig = can_dig, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + local meta = minetest.get_meta(pos) + local meta2 = meta:to_table() + meta:from_table(oldmetadata) + local inv = meta:get_inventory() + for _, listname in ipairs({"main", "dst"}) do + local stack = inv:get_stack(listname, 1) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2) + end, on_timer = on_timer, on_construct = on_construct, on_metadata_inventory_move = function(pos) diff --git a/energy_collector.lua b/energy_collector.lua index 39db963..e8c1760 100644 --- a/energy_collector.lua +++ b/energy_collector.lua @@ -113,7 +113,20 @@ minetest.register_node("exchangeclone:energy_collector", { }, groups = {cracky = 2, container = 2}, is_ground_content = false, - can_dig = can_dig, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + local meta = minetest.get_meta(pos) + local meta2 = meta:to_table() + meta:from_table(oldmetadata) + local inv = meta:get_inventory() + for _, listname in ipairs({"main"}) do + local stack = inv:get_stack(listname, 1) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2) + end, on_timer = on_timer, on_construct = on_construct, on_metadata_inventory_move = function(pos) diff --git a/orb.lua b/orb.lua index 3c51c2c..93e069b 100644 --- a/orb.lua +++ b/orb.lua @@ -23,9 +23,15 @@ end minetest.register_craft({ type = "shaped", output = "exchangeclone:exchange_orb", + groups = {}, recipe = { {recipe_item_3, recipe_item_2, recipe_item_3}, {recipe_item_2, recipe_item_1, recipe_item_2}, {recipe_item_3, recipe_item_2, recipe_item_3} } }) +minetest.register_craft({ --Making it fuel so hopper will work with constructor better + type = "fuel", + recipe = "exchangeclone:exchange_orb", + burntime = 800 +}) \ No newline at end of file