feat: sync disabled recipes and smelting state from client, improve broadcast logic

This commit is contained in:
MayaTheShy
2026-03-22 22:31:35 -04:00
parent bdc9b3f291
commit b9b69a4966

View File

@@ -151,11 +151,9 @@ local function broadcastState()
-- Keep ctx in sync so display.lua can check ctx.craftTurtleOk directly
ctx.craftTurtleOk = payload.craftTurtleOk
if state.configDirty then
payload.smeltable = cfg.SMELTABLE
payload.craftable = cfg.CRAFTABLE
state.configDirty = false
end
payload.smeltable = cfg.SMELTABLE
payload.craftable = cfg.CRAFTABLE
state.configDirty = false
ctx.networkModem.transmit(cfg.BROADCAST_CHANNEL, cfg.ORDER_CHANNEL, payload)
state.lastBroadcastVersion = state.stateVersion
@@ -710,6 +708,21 @@ local function main()
state.needsRedraw = true
pcall(broadcastState)
elseif message.type == "sync_disabled_recipes" then
if message.disabledRecipes then
state.disabledRecipes = message.disabledRecipes
end
if message.smeltingPaused ~= nil then
state.smeltingPaused = message.smeltingPaused
end
ops.saveDisabledRecipes()
log.info("NET", "Synced smelting state from client")
state.configDirty = true
state.bumpStateVersion()
state.smelterNeedsRedraw = true
state.needsRedraw = true
pcall(broadcastState)
elseif message.type == "learn_crafting_recipe" and message.output and message.count and message.grid then
cfg.recipeBook.learnCraftingRecipe(message.output, message.count, message.grid)
cfg.refreshRecipes()