Breaking might drop contents now

This commit is contained in:
ThePython 2023-03-26 15:19:19 -07:00
parent 765786d44c
commit 48204108c7
5 changed files with 58 additions and 8 deletions

View File

@ -3,18 +3,23 @@
![GitHub license](https://img.shields.io/github/license/thepython10110/minetest_exchangeclone) ![GitHub license](https://img.shields.io/github/license/thepython10110/minetest_exchangeclone)
![GitHub issues](https://img.shields.io/github/issues/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) ![In Game Screenshot](screenshot.png)
## Features ## Features
- Orb that holds energy - Orb that holds energy (left click while holding it to show charge)
- Collector that collects energy from the sun - Collector that collects energy from the sun
- Constructor that can convert one node into different node - Deconstructor that can turn nodes into energy
- Deconstructor that can extract energy from a node - Constructor that can create nodes from energy
## Config ## 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 ## Original License
Copyright (C) 2021 Leo Spratt Copyright (C) 2021 Leo Spratt

View File

@ -161,7 +161,20 @@ minetest.register_node("exchangeclone:element_constructor", {
}, },
groups = {cracky = 2, container = 4}, groups = {cracky = 2, container = 4},
is_ground_content = false, 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_timer = on_timer,
on_construct = on_construct, on_construct = on_construct,
on_metadata_inventory_move = function(pos) on_metadata_inventory_move = function(pos)

View File

@ -133,7 +133,20 @@ minetest.register_node("exchangeclone:element_deconstructor", {
}, },
groups = {cracky = 2, container = 3}, groups = {cracky = 2, container = 3},
is_ground_content = false, 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_timer = on_timer,
on_construct = on_construct, on_construct = on_construct,
on_metadata_inventory_move = function(pos) on_metadata_inventory_move = function(pos)

View File

@ -113,7 +113,20 @@ minetest.register_node("exchangeclone:energy_collector", {
}, },
groups = {cracky = 2, container = 2}, groups = {cracky = 2, container = 2},
is_ground_content = false, 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_timer = on_timer,
on_construct = on_construct, on_construct = on_construct,
on_metadata_inventory_move = function(pos) on_metadata_inventory_move = function(pos)

View File

@ -23,9 +23,15 @@ end
minetest.register_craft({ minetest.register_craft({
type = "shaped", type = "shaped",
output = "exchangeclone:exchange_orb", output = "exchangeclone:exchange_orb",
groups = {},
recipe = { recipe = {
{recipe_item_3, recipe_item_2, recipe_item_3}, {recipe_item_3, recipe_item_2, recipe_item_3},
{recipe_item_2, recipe_item_1, recipe_item_2}, {recipe_item_2, recipe_item_1, recipe_item_2},
{recipe_item_3, recipe_item_2, recipe_item_3} {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
})