Added pipeworks support (closes #8)

This commit is contained in:
ThePython 2023-11-20 09:17:17 -08:00
parent 9c9c620b84
commit 9290294154
6 changed files with 136 additions and 23 deletions

View File

@ -61,11 +61,11 @@ Dependencies: Minetest Game or MineClone.
* Automatically generated energy values! Based on crafting and cooking recipes.
* For reasons beyond my control, things kind of vary a bit between loads because of which items are added to the `minetest.registered_items` first (which is kind of random). For instance, the Lookup Tool in MineClone2 might sometimes have an energy value of 5 (1 stick + 1 glass) or 16 (4 sticks) depending on whether the energy value for glass is added first or not. At least, I assume that's the reason.
* Depending on the number of items you have, this could increase loading time.
* Technic recipe types (grinding, alloying, etc.) will also work, as long as their `output_size` is 1.
* Technic recipe types (grinding, alloying, etc.) will also work, as long as their `output_size` is 1 and my PR gets merged.
* Added energy values for Basic Materials and Technic!
* Infinite food (costs 64 energy to use, equal to steak)
* Alchemical Chests, Alchemical Bags, and Advanced Alchemical Chests
* Support for Pipeworks and non-MCL hoppers (MineClone hoppers already worked)!
* Support for Pipeworks and Hopper mods! (MCL hoppers already worked)
* Covalence Dust (Aux1+right-click with Philosopher's Stone to open repairing menu; only tools with an energy value can be repaired)
* Mind, Life, Body, and Soul Stones (although MTG only has the soul stone).
* Mercurial Eye (maybe)
@ -76,7 +76,7 @@ Dependencies: Minetest Game or MineClone.
* Energy values are now in `_exchangeclone_energy/energy_values.lua`, and are laid out differently, and aliases now work.
* ExchangeClone is now a modpack for [annoying reasons](https://forum.minetest.net/viewtopic.php?f=47&p=429775s). *Every single mod* in the modpack is required, regardless of what it says the dependencies are. Disable and then enable it for everything to work correctly.
* The default energy value is no longer 1 but none.
* The 2-billion-ish personal energy limit is has been increased to 1,000,000,000,000 (1 trillion). Any higher and there are precision-based exploits like being able to create infinite glass panes when you have enough energy.
* The 2-billion-ish personal energy limit is has been increased to 1,000,000,000,000 (1 trillion). Any higher and there are precision-based exploits like being able to create infinite glass panes (or really anything with an energy value less than 1) when you have enough energy. It's still a 50,000% increase.
* Added comma separators when energy is shown (to make it easier to identify large numbers)
* Tools that break multiple nodes at once (hammers, hoes, katar, and morningstar) use a better method that may (?) slightly decrease lag.
* Ender pearls can now be crafted with 4 iron and the Philosopher's Stone.

View File

@ -104,7 +104,7 @@ local function on_construct(pos)
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
if player and player.get_player_name and minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "fuel" then
@ -188,7 +188,6 @@ minetest.register_node("exchangeclone:constructor", {
on_metadata_inventory_move = constructor_action,
on_metadata_inventory_put = constructor_action,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "fuel" then return end
constructor_action(pos)
end,
on_blast = on_blast,
@ -209,8 +208,11 @@ if exchangeclone.pipeworks then
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
minetest.get_node_timer(pos):start(1)
return inv:add_item(get_list(direction), stack)
local result = inv:add_item(get_list(direction), stack)
if result then
constructor_action(pos)
end
return result
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)

View File

@ -106,8 +106,7 @@ local function on_construct(pos)
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
if player and player.get_player_name and minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "fuel" then
@ -156,7 +155,7 @@ minetest.register_node("exchangeclone:deconstructor", {
"exchangeclone_deconstructor_right.png",
"exchangeclone_deconstructor_right.png"
},
groups = {cracky = 2, container = 4, pickaxey = 2},
groups = {cracky = 2, container = 4, pickaxey = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 3,
_mcl_blast_resistance = 6,
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
@ -177,17 +176,22 @@ minetest.register_node("exchangeclone:deconstructor", {
end
meta:from_table(meta2)
end
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end,
after_place_node = function(pos, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
meta:set_string("exchangeclone_placer", player:get_player_name())
if exchangeclone.pipeworks then
pipeworks.after_place(pos, player, itemstack, pointed_thing)
end
end,
on_timer = deconstructor_action,
on_construct = on_construct,
on_metadata_inventory_move = deconstructor_action,
on_metadata_inventory_put = deconstructor_action,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "fuel" then return end
deconstructor_action(pos)
end,
on_blast = on_blast,
@ -196,6 +200,39 @@ minetest.register_node("exchangeclone:deconstructor", {
allow_metadata_inventory_take = allow_metadata_inventory_take,
})
if exchangeclone.pipeworks then
local function get_list(direction)
return (direction.y == 0 and "src") or "fuel"
end
minetest.override_item("exchangeclone:deconstructor", {
tube = {
input_inventory = "fuel",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local result = inv:add_item(get_list(direction), stack)
if result then
deconstructor_action(pos)
end
return result
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if get_list(direction) == "fuel" then
if stack:get_name() == "exchangeclone:exchange_orb" then
return inv:room_for_item("fuel", stack)
end
else
return inv:room_for_item("src", stack)
end
end,
},
on_rotate = pipeworks.on_rotate,
})
end
local recipe_ingredient = "default:furnace"
if exchangeclone.mcl then

View File

@ -126,10 +126,12 @@ end]]
--
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
if player and player.get_player_name then
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
end
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -482,6 +484,9 @@ if minetest.get_modpath("screwdriver") then
return
end
spawn_flames(pos, node.param2)
if exchangeclone.pipeworks then
pipeworks.on_rotate(pos)
end
end
end
@ -496,7 +501,7 @@ local inactive_def = {
"exchangeclone_dark_matter_furnace.png",
},
paramtype2 = "facedir",
groups = {pickaxey=5, cracky = 3, container=4, material_stone=1, level = get_level(4), exchangeclone_furnace = 1},
groups = {pickaxey=5, cracky = 3, container=4, material_stone=1, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1},
is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
@ -524,6 +529,9 @@ local inactive_def = {
end
end
meta:from_table(meta2)
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end,
on_construct = function(pos)
@ -570,6 +578,7 @@ local inactive_def = {
_mcl_blast_resistance = 1500,
_mcl_hardness = 75,
on_rotate = on_rotate,
after_place_node = exchangeclone.pipeworks and pipeworks.after_place
}
local active_def = {
@ -586,7 +595,7 @@ local active_def = {
parammatter_type = "light",
light_source = LIGHT_ACTIVE_FURNACE,
drop = "exchangeclone:dark_matter_furnace",
groups = {pickaxey=5, not_in_creative_inventory = 1, container = 4, material_stone=1, cracky = 3, level = get_level(4), exchangeclone_furnace = 1},
groups = {pickaxey=5, not_in_creative_inventory = 1, container = 4, material_stone=1, cracky = 3, level = get_level(4), exchangeclone_furnace = 1, tubedevice = 1, tubedevice_receiver = 1},
is_ground_content = false,
sounds = exchangeclone.sound_mod.node_sound_stone_defaults(),
on_timer = furnace_node_timer,
@ -614,6 +623,9 @@ local active_def = {
end
end
meta:from_table(meta2)
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end,
on_construct = function(pos)
@ -636,8 +648,38 @@ local active_def = {
_mcl_hardness = 75,
on_rotate = on_rotate,
after_rotate = after_rotate_active,
after_place_node = exchangeclone.pipeworks and pipeworks.after_place
}
if exchangeclone.pipeworks then
local function get_list(direction)
return (direction.y == 0 and "src") or "fuel"
end
for _, table in pairs({inactive_def, active_def}) do
table.tube = {
input_inventory = "dst",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local result = inv:add_item(get_list(direction), stack)
if result then
local func = minetest.registered_items[node.name].on_metadata_inventory_put
if func then func(pos) end
end
return result
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if allow_metadata_inventory_put(pos, get_list(direction), 1, stack) > 0 then
return true
end
end
}
end
end
minetest.register_node("exchangeclone:dark_matter_furnace", table.copy(inactive_def))
minetest.register_node("exchangeclone:red_matter_furnace", table.copy(inactive_def))
minetest.register_node("exchangeclone:dark_matter_furnace_active", table.copy(active_def))
@ -653,7 +695,7 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
"exchangeclone_red_matter_block.png",
"exchangeclone_red_matter_furnace.png",
},
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2},
groups = {pickaxey=5, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 100,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
@ -711,6 +753,9 @@ minetest.override_item("exchangeclone:red_matter_furnace", {
end
end
meta:from_table(meta2)
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end,
})
@ -726,7 +771,7 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
"exchangeclone_red_matter_furnace.png",
},
drop = "exchangeclone:red_matter_furnace",
groups = {pickaxey=5, not_in_creative_inventory = 1, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2},
groups = {pickaxey=5, not_in_creative_inventory = 1, cracky = 3, container=4, deco_block=1, material_stone=1, level = get_level(5), exchangeclone_furnace = 2, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 100,
on_construct = function(pos)
@ -761,8 +806,10 @@ minetest.override_item("exchangeclone:red_matter_furnace_active", {
end
end
meta:from_table(meta2)
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end,
})
minetest.register_craft({

View File

@ -7,7 +7,7 @@ local function read_orb_charge(itemstack, player, pointed_thing)
end
local stored = exchangeclone.get_orb_itemstack_energy(itemstack)
minetest.chat_send_player(player:get_player_name(), S("Current Charge: @1", stored))
minetest.chat_send_player(player:get_player_name(), S("Current Charge: @1", exchangeclone.format_number(stored)))
return itemstack
end

View File

@ -94,7 +94,7 @@ end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
if player and player.get_player_name and minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "fuel" then
@ -185,7 +185,7 @@ minetest.register_node("exchangeclone:upgrader", {
meta:set_string("infotext", "Upgrader")
meta:set_string("formspec", upgrader_formspec)
end,
groups = {pickaxey=5, material_stone=1, cracky = 3, container = 4, level = get_level(4)}, --ridiculous workaround
groups = {pickaxey=5, material_stone=1, cracky = 3, container = 4, level = get_level(4), tubedevice = 1, tubedevice_receiver = 1},
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -199,6 +199,33 @@ minetest.register_node("exchangeclone:upgrader", {
_mcl_hardness = 75,
})
if exchangeclone.pipeworks then
local function get_list(direction)
return (direction.y == 0 and "src") or "fuel"
end
minetest.override_item("exchangeclone:upgrader", {tube = {
input_inventory = "dst",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local result = inv:add_item(get_list(direction), stack)
if result then
local func = minetest.registered_items[node.name].on_metadata_inventory_put
if func then func(pos) end
end
return result
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if allow_metadata_inventory_put(pos, get_list(direction), 1, stack) > 0 then
return true
end
end
}})
end
minetest.register_craft({
output = "exchangeclone:upgrader",
recipe = {