mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-21 05:34:07 +02:00
Disallow non-fuel items to be accepted as fuel quarries and harvesters
This commit is contained in:
parent
677c1f4148
commit
c603c85cf6
@ -117,7 +117,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
|||||||
local inv = M(pos):get_inventory()
|
local inv = M(pos):get_inventory()
|
||||||
if listname == "main" then
|
if listname == "main" then
|
||||||
return stack:get_count()
|
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()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -178,7 +178,12 @@ end
|
|||||||
-- check the fuel level and return false if empty
|
-- check the fuel level and return false if empty
|
||||||
local function check_fuel(pos, this, meta)
|
local function check_fuel(pos, this, meta)
|
||||||
if this.fuel <= 0 then
|
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
|
return false
|
||||||
end
|
end
|
||||||
this.fuel = BURNING_TIME
|
this.fuel = BURNING_TIME
|
||||||
@ -431,6 +436,9 @@ tubelib.register_node("tubelib_addons1:harvester_base", {"tubelib_addons1:harves
|
|||||||
return tubelib.get_item(M(pos), "main")
|
return tubelib.get_item(M(pos), "main")
|
||||||
end,
|
end,
|
||||||
on_push_item = function(pos, side, item)
|
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)
|
return tubelib.put_item(M(pos), "fuel", item)
|
||||||
end,
|
end,
|
||||||
on_unpull_item = function(pos, side, item)
|
on_unpull_item = function(pos, side, item)
|
||||||
|
@ -119,7 +119,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
|||||||
local inv = M(pos):get_inventory()
|
local inv = M(pos):get_inventory()
|
||||||
if listname == "main" then
|
if listname == "main" then
|
||||||
return stack:get_count()
|
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()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -161,10 +161,16 @@ local function quarry_next_node(pos, meta)
|
|||||||
-- check fuel
|
-- check fuel
|
||||||
local fuel = meta:get_int("fuel") or 0
|
local fuel = meta:get_int("fuel") or 0
|
||||||
if fuel <= 0 then
|
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)
|
State:fault(pos, meta)
|
||||||
return
|
return
|
||||||
end
|
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
|
fuel = BURNING_TIME
|
||||||
else
|
else
|
||||||
fuel = fuel - 1
|
fuel = fuel - 1
|
||||||
@ -439,6 +445,9 @@ tubelib.register_node("tubelib_addons1:quarry",
|
|||||||
return tubelib.get_item(M(pos), "main")
|
return tubelib.get_item(M(pos), "main")
|
||||||
end,
|
end,
|
||||||
on_push_item = function(pos, side, item)
|
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)
|
return tubelib.put_item(M(pos), "fuel", item)
|
||||||
end,
|
end,
|
||||||
on_unpull_item = function(pos, side, item)
|
on_unpull_item = function(pos, side, item)
|
||||||
|
@ -340,6 +340,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"}, {
|
tubelib.register_node("tubelib_addons1:reformer", {"tubelib_addons1:reformer_defect"}, {
|
||||||
on_pull_item = function(pos, side)
|
on_pull_item = function(pos, side)
|
||||||
|
Loading…
Reference in New Issue
Block a user