Enhance dropper detection logic: implement name-based matching for improved compatibility with CC:Tweaked versions

This commit is contained in:
MayaTheShy
2026-03-21 20:31:24 -04:00
parent 98f415d7d4
commit a3d0a46b44

View File

@@ -897,9 +897,18 @@ local function refreshCache(onProgress)
cache.barrelOk = peripheral.wrap(BARREL_NAME) ~= nil
-- Discover all droppers on the network (for location-based dispensing)
-- Use name-based matching as peripheral.getType() may return "inventory"
-- as the primary type in some CC:Tweaked versions (1.99+)
local droppers = {}
for _, name in ipairs(peripheral.getNames()) do
if peripheral.getType(name) == "minecraft:dropper" and name ~= COMPOST_DROPPER then
local isDropper = name:match("^minecraft:dropper_")
if not isDropper and peripheral.hasType then
isDropper = peripheral.hasType(name, "minecraft:dropper")
end
if not isDropper then
isDropper = peripheral.getType(name) == "minecraft:dropper"
end
if isDropper and name ~= COMPOST_DROPPER then
local isDefault = (name == DROPPER_NAME)
table.insert(droppers, { name = name, isDefault = isDefault })
end