diff --git a/tubelib_addons1/harvester.lua b/tubelib_addons1/harvester.lua index c38f51c..b238185 100644 --- a/tubelib_addons1/harvester.lua +++ b/tubelib_addons1/harvester.lua @@ -119,7 +119,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) local inv = M(pos):get_inventory() if listname == "main" then return stack:get_count() - elseif listname == "fuel" and stack:get_name() == "tubelib_addons1:biofuel" then + elseif listname == "fuel" and tubelib.is_fuel(stack) then return stack:get_count() end return 0 @@ -190,7 +190,12 @@ end -- check the fuel level and return false if empty local function check_fuel(pos, this, meta) if this.fuel <= 0 then - if tubelib.get_this_item(meta, "fuel", 1) == nil then + local fuel_item = tubelib.get_this_item(meta, "fuel", 1) + if fuel_item == nil then + return false + end + if not tubelib.is_fuel(fuel_item) then + tubelib.put_item(meta, "fuel", fuel_item) return false end this.fuel = BURNING_TIME @@ -443,6 +448,9 @@ tubelib.register_node("tubelib_addons1:harvester_base", {"tubelib_addons1:harves return tubelib.get_item(M(pos), "main") end, on_push_item = function(pos, side, item) + if not tubelib.is_fuel(item) then + return false + end return tubelib.put_item(M(pos), "fuel", item) end, on_unpull_item = function(pos, side, item) diff --git a/tubelib_addons1/quarry.lua b/tubelib_addons1/quarry.lua index bc64107..75c26d9 100644 --- a/tubelib_addons1/quarry.lua +++ b/tubelib_addons1/quarry.lua @@ -122,7 +122,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player) local inv = M(pos):get_inventory() if listname == "main" then return stack:get_count() - elseif listname == "fuel" and stack:get_name() == "tubelib_addons1:biofuel" then + elseif listname == "fuel" and tubelib.is_fuel(stack) then return stack:get_count() end return 0 @@ -164,10 +164,16 @@ local function quarry_next_node(pos, meta) -- check fuel local fuel = meta:get_int("fuel") or 0 if fuel <= 0 then - if tubelib.get_this_item(meta, "fuel", 1) == nil then + local fuel_item = tubelib.get_this_item(meta, "fuel", 1) + if fuel_item == nil then State:fault(pos, meta) return end + if not tubelib.is_fuel(fuel_item) then + State:fault(pos, meta) + tubelib.put_item(meta, "fuel", fuel_item) + return + end fuel = BURNING_TIME else fuel = fuel - 1 @@ -443,6 +449,9 @@ tubelib.register_node("tubelib_addons1:quarry", return tubelib.get_item(M(pos), "main") end, on_push_item = function(pos, side, item) + if not tubelib.is_fuel(item) then + return false + end return tubelib.put_item(M(pos), "fuel", item) end, on_unpull_item = function(pos, side, item) diff --git a/tubelib_addons1/reformer.lua b/tubelib_addons1/reformer.lua index 3803251..90e3771 100644 --- a/tubelib_addons1/reformer.lua +++ b/tubelib_addons1/reformer.lua @@ -342,6 +342,9 @@ minetest.register_craft({ }, }) +function tubelib.is_fuel(stack) + return stack:get_name() == "tubelib_addons1:biofuel" +end tubelib.register_node("tubelib_addons1:reformer", {"tubelib_addons1:reformer_defect"}, { on_pull_item = function(pos, side)