Hoppers work now, among other things.

This commit is contained in:
ThePython 2023-11-19 16:01:56 -08:00
parent 3874c608f3
commit 9c9c620b84
12 changed files with 166 additions and 63 deletions

View File

@ -30,7 +30,10 @@ read_globals = {
"screwdriver",
"mcl_crafting_table",
"mcl_enchantments",
"technic",
"hopper",
"pipeworks",
"Raycast",
"Settings",

View File

@ -56,18 +56,17 @@ Dependencies: Minetest Game or MineClone.
<details><summary><h1>Changelog:</h1></summary>
### 6.0 (interestingness depends on several things)
### 6.0)
* New Features:
* 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.) now 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.
* 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!
* Repair Talisman
* Covalence Dust (Aux1+right-click with Philosopher's Stone to open repairer, only tools with an energy value can be repaired)
* Support for Pipeworks and non-MCL hoppers (MineClone 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)
* Chat commands to set/add/remove energy from a player (requires `privs` privilege):
@ -86,6 +85,7 @@ Dependencies: Minetest Game or MineClone.
* It is now impossible to transmute between bedrock and barriers (MCL). I thought it was funny originally, but now I'm realizing that I don't want this to be annoying to people who run servers (are there any servers with this mod?)
* It now costs 4 dark/red matter to make a block, which is great news if you already have some (because they're now worth more), but not so great if you don't.
* Tool abilities now cost nothing (to match ProjectE).
* Tool abilities now take upgrades into account (silk touch, fortune, etc.) except for the sword AOE ability (which is annoying).
* Bugfixes:
* Fixed potion energy values
* Fixed Red Matter Shield recipe

View File

@ -1,21 +1,17 @@
-- This lets mods add things to these lists if they want.
exchangeclone.group_values = exchangeclone.group_values or {}
exchangeclone.energy_values = exchangeclone.energy_values or {}
if exchangeclone.mcl then
--[[ Groups are organized so that order matters. Groups that are lower on the
list will have their energies applied later, making them higher priority. It's
unnecessary for single items because order doesn't matter for them. The NO_GROUP
value is for values that are not in any other group, but adding this means that
NO items will have their energy calculated by recipes. ]]
exchangeclone.group_values = {
table.insert_all(exchangeclone.group_values, {
{"flower", 8},
{"mushroom", 32},
{"smithing_template", 8192*7+1792*2},
{"decorated_pot_recipe", 4}, -- has to be 4 because of brick.
}
})
exchangeclone.energy_values = {
for itemstring, energy_value in pairs({
["fake_liquids:bucket_fake_lava"] = 832,
["fake_liquids:bucket_fake_water"] = 960,
@ -277,8 +273,12 @@ if exchangeclone.mcl then
["meat_blocks:meatball"] = 64,
["mesecons:redstone"] = 64,
["useful_green_potatoes:useful_green_potato"] = 256,
}
exchangeclone.mcl_potion_data = { -- automatically assumes base cost is awkward potion if not specified
}) do
exchangeclone.energy_values[itemstring] = exchangeclone.energy_values[itemstring] or energy_value
end
exchangeclone.mcl_potion_data = exchangeclone.mcl_potion_data or {}
table.insert_all(exchangeclone.mcl_potion_data, { -- automatically assumes base cost is awkward potion if not specified
{name = "water", ingredient_cost = 0, custom_base_cost = 0, no_arrow = true},
{name = "awkward", ingredient_cost = 0, no_arrow = true},
{name = "fire_resistance", ingredient_cost = 768, plus = true},
@ -295,9 +295,9 @@ if exchangeclone.mcl then
{name = "water_breathing", ingredient_cost = 64, plus = true},
{name = "invisibility", ingredient_cost = 192, custom_base_cost = 623, plus = true},
{name = "withering", ingredient_cost = 128, plus = true, two = true}
}
})
else
exchangeclone.energy_values = {
for itemstring, energy_value in pairs({
["bones:bones"] = 4,
["bucket:bucket_lava"] = 896,
@ -376,7 +376,9 @@ else
["technic:zinc_ingot"] = 512,
["useful_green_potatoes:useful_green_potato"] = 256
}
}) do
exchangeclone.energy_values[itemstring] = exchangeclone.energy_values[itemstring] or energy_value
end
exchangeclone.group_values = {
{"flower", 32},

View File

@ -141,6 +141,7 @@ minetest.register_on_mods_loaded(function()
if exchangeclone.mcl then
for i = 0, 31 do
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i)
exchangeclone.register_energy_alias("mcl_compass:18", "mcl_compass:"..i.."_lodestone")
end
for i = 0, 63 do
exchangeclone.register_energy_alias("mcl_clock:clock", "mcl_clock:clock_"..i)
@ -184,7 +185,7 @@ minetest.register_on_mods_loaded(function()
end
for i = 1, exchangeclone.num_passes do
minetest.log("action", "ExchangeClone: \tPASS #"..i..":")
minetest.log("action", "ExchangeClone: \tPASS #"..i)
if auto == {} then break end
for itemstring, _ in pairs(auto) do
local cheapest = get_cheapest_recipe(exchangeclone.recipes[itemstring])

View File

@ -55,6 +55,8 @@ end
minetest.register_node("exchangeclone:alchemical_chest", {
description = S("Alchemical Chest"),
groups = {container = 2, alchemical_chest = 1, cracky = 2, pickaxey = 2},
_mcl_hardness = 3,
_mcl_blast_resistance = 6,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -136,6 +138,8 @@ for dye_color, color in pairs(colors) do
minetest.register_node(advanced_itemstring, {
description = S("@1 Advanced Alchemical Chest", color).."\n"..S("Shift+right-click with an alchemical bag to change the color."),
_mcl_hardness = 3,
_mcl_blast_resistance = 6,
groups = {container = 2, advanced_alchemical_chest = 1},
on_construct = alchemical_on_construct(color)
})

View File

@ -155,7 +155,7 @@ minetest.register_node("exchangeclone:constructor", {
"exchangeclone_constructor_right.png",
"exchangeclone_constructor_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(),
@ -180,6 +180,9 @@ minetest.register_node("exchangeclone:constructor", {
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_construct = on_construct,
on_metadata_inventory_move = constructor_action,
@ -195,6 +198,36 @@ minetest.register_node("exchangeclone:constructor", {
on_timer = constructor_action,
})
if exchangeclone.pipeworks then
local function get_list(direction)
return (direction.y == 0 and "src") or "fuel"
end
minetest.override_item("exchangeclone:constructor", {
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()
minetest.get_node_timer(pos):start(1)
return inv:add_item(get_list(direction), stack)
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:pick_diamond"
if exchangeclone.mcl then

View File

@ -7,7 +7,7 @@ local formspec =
exchangeclone.inventory_formspec(0,5)..
"listring[current_player;main]"..
"listring[context;main]"..
exchangeclone.mcl and mcl_formspec.get_itemslot_bg(4,2,1,1)
(exchangeclone.mcl and mcl_formspec.get_itemslot_bg(4,2,1,1) or "")
minetest.register_alias("exchangeclone:energy_collector", "exchangeclone:energy_collector_mk1")
@ -164,6 +164,9 @@ local function on_dig_node(pos, oldnode, oldmetadata, player)
end
meta:from_table(meta2)
end
if exchangeclone.pipeworks then
pipeworks.after_dig(pos)
end
end
function exchangeclone.register_energy_collector(itemstring, name, amount, modifier, recipe)
@ -177,7 +180,7 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
"exchangeclone_energy_collector_right.png"..modifier,
"exchangeclone_energy_collector_right.png"..modifier
},
groups = {cracky = 2, container = 2, pickaxey = 2, energy_collector = amount},
groups = {cracky = 2, container = 2, pickaxey = 2, energy_collector = amount, tubedevice = 1, tubedevice_receiver = 1},
_mcl_hardness = 3,
_mcl_blast_resistance = 6,
sounds = exchangeclone.sound_mod.node_sound_metal_defaults(),
@ -204,8 +207,12 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
meta:set_int("collector_amount", amount)
meta:set_string("exchangeclone_placer", player_name)
meta:set_string("infotext", name.."\n"..S("Owned by ")..player_name)
if exchangeclone.pipeworks then
pipeworks.after_place(pos, player, itemstack, pointed_thing)
end
end,
on_blast = on_blast,
on_rotate = exchangeclone.pipeworks and pipeworks.on_rotate,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
@ -214,36 +221,30 @@ function exchangeclone.register_energy_collector(itemstring, name, amount, modif
output = itemstring,
recipe = recipe
})
end
--[[if minetest.get_modpath("pipeworks") then
minetest.override_item("exchangeclone:energy_collector", {
tube = {
input_inventory = "main",
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()
return inv:add_item("main", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if stack:get_name() == "exchangeclone:exchange_orb" then
minetest.log(inv:room_for_item("main", stack))
return inv:room_for_item("main", stack)
else
minetest.log("failed")
end
end,
},
after_place_node = function(pos, player)
pipeworks.after_place(pos)
end,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate,
})
end]]
if exchangeclone.pipeworks then
minetest.override_item(itemstring, {
tube = {
input_inventory = "main",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1},
insert_object = function(pos, node, stack, direction)
minetest.log(dump(direction))
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("main", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if stack:get_name() == "exchangeclone:exchange_orb" then
return inv:room_for_item("main", stack)
end
end,
},
on_rotate = pipeworks.on_rotate,
})
end
end
local iron = "default:steelblock"
local glass = "default:glass"

View File

@ -7,16 +7,20 @@ hopper:add_container({
{"side", "group:container=2", "main"},
})
-- Intentionally skipping 3, because I don't know if it would still block shulkers
-- If this doesn't start the node timer for the furnace, it won't work.
hopper:add_container({
{"top", "group:container=4", "src"},
{"side", "group:container=4", "fuel"},
{"bottom", "group:container=4", "dst"},
{"top", "group:container=3", "main"},
{"bottom", "group:container=3", "main"},
{"side", "group:container=3", "main"},
})
-- Hoppers will only be able to insert into one side of a double chest (unless you have 1 hopper per side)
-- I assumed "top" meant when it's on top of a node, not when there's a node on top of it. Whoops.
hopper:add_container({
{"top", "group:container=4", "dst"},
{"side", "group:container=4", "fuel"},
{"bottom", "group:container=4", "src"},
})
-- Hoppers will only be able to insert into one side of a double chest, I think (unless you have 1 hopper per side)
hopper:add_container({
{"top", "group:container=5", "main"},
{"bottom", "group:container=5", "main"},

View File

@ -10,6 +10,7 @@ end
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl is also defined.
exchangeclone.pipeworks = minetest.get_modpath("pipeworks")
exchangeclone.orb_max = 51200000 -- Max capacity of Klein Star Omega in ProjectE
@ -18,7 +19,7 @@ local modpath = minetest.get_modpath("exchangeclone")
exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 51200000
exchangeclone.num_passes = minetest.settings:get("exchangeclone.num_passes") or 10
minetest.log("action", "Loading Exchangeclone")
minetest.log("action", "ExchangeClone: Registering own stuff")
dofile(modpath.."/lib.lua")
dofile(modpath.."/constructor.lua")
@ -51,4 +52,6 @@ dofile(modpath.."/pesa.lua")
dofile(modpath.."/infinite_food.lua")
dofile(modpath.."/alchemical_chests.lua")
dofile(modpath.."/transmutation_table.lua")
dofile(modpath.."/furnaces.lua")
dofile(modpath.."/furnaces.lua")
minetest.log("action", "ExchangeClone: Done.")

View File

@ -170,8 +170,10 @@ end
-- Set a player's personal energy
function exchangeclone.set_player_energy(player, amount)
amount = tonumber(amount)
if not (player and amount) then return end
if amount < 0 or amount > exchangeclone.limit then return end
amount = math.floor(amount*4)/4 -- Floor to nearest .25
player:get_meta():set_string("exchangeclone_stored_energy", tonumber(amount))
exchangeclone.update_hud(player)
end
@ -179,7 +181,7 @@ end
-- Add to a player's personal energy (amount can be negative)
function exchangeclone.add_player_energy(player, amount)
if not (player and amount) then return end
exchangeclone.set_player_energy(exchangeclone.get_player_energy(player) + amount)
exchangeclone.set_player_energy(player, (exchangeclone.get_player_energy(player) or 0) + amount)
end
-- Through trial and error, I have found that this number (1 trillion) works the best.
@ -610,4 +612,54 @@ function exchangeclone.check_cooldown(player, name)
if exchangeclone.cooldowns[player_name] then
return exchangeclone.cooldowns[player_name][name]
end
end
end
-- Chat commands:
minetest.register_chatcommand("add_energy", {
params = "[player] <value>",
description = "Add to a player's personal energy (player is self if not included, value can be negative)",
privs = {privs = true},
func = function(name, param)
local split_param = exchangeclone.split(param, " ")
local player
local value
if #split_param == 1 then
player = minetest.get_player_by_name(name)
value = split_param[1]
end
if #split_param == 2 then
player = minetest.get_player_by_name(split_param[1])
value = split_param[2]
end
if not (player and value) then
minetest.chat_send_player(name, "Bad command. Use /add_energy [player] [value] or /add_energy [value]")
return
end
exchangeclone.add_player_energy(player, tonumber(value))
end
})
minetest.register_chatcommand("set_energy", {
params = "[player] <value>",
description = "Set a player's personal energy (player is self if not included; use 'limit' as value to set it to maximum)",
privs = {privs = true},
func = function(name, param)
local split_param = exchangeclone.split(param, " ")
local player
local value
if #split_param == 1 then
player = minetest.get_player_by_name(name)
value = split_param[1]
end
if #split_param == 2 then
player = minetest.get_player_by_name(split_param[1])
value = split_param[2]
end
if not (player and value) then
minetest.chat_send_player(name, "Bad command. Use '/set_energy player value' or '/set_energy value'")
return
end
if value == "limit" then value = exchangeclone.limit end
exchangeclone.set_player_energy(player, tonumber(value))
end
})

View File

@ -2,5 +2,5 @@ name = exchangeclone
title = ExchangeClone
description = The main part of the modpack (depends on both the other mods)
min_minetest_version = 5.5
optional_depends = mcl_core, default, 3d_armor, mcl_item_id, moreswords, hopper, pipeworks
optional_depends = mcl_core, default, mcl_armor, 3d_armor, mcl_item_id, mobs_mc, hopper, pipeworks, mcl_dispensers
author = ThePython10110

View File

@ -1,4 +1,4 @@
exchangeclone = {recipes = {}}
exchangeclone = {recipes = {}, energy_values = {}, group_values = {}}
local old_func = minetest.register_craft
function minetest.register_craft(arg, ...)