mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 23:33:44 +01:00
Merge pull request #57 from oversword/bls-258
Disallow non-fuel items to be accepted as fuel quarries and harvesters
This commit is contained in:
commit
127327c71a
@ -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
|
||||||
@ -190,7 +190,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
|
||||||
@ -443,6 +448,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)
|
||||||
|
@ -122,7 +122,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
|
||||||
@ -164,10 +164,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
|
||||||
@ -443,6 +449,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)
|
||||||
|
@ -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"}, {
|
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