script.on_event(defines.events.on_player_setup_blueprint, function(event) local player = game.get_player(event.player_index) if not player then return end -- Find bp local bp = nil if event.record then bp = event.record.get_selected_record(player) elseif event.stack then local stack = event.stack while stack and stack.is_blueprint_book do stack = stack.get_inventory(defines.inventory.item_main)[stack.active_index] end if stack and stack.is_blueprint then bp = stack end end if not bp then return end -- Set entities to the result of get_entities. This should make no -- change to the bp. local entities = bp.get_blueprint_entities() or {} bp.set_blueprint_entities(entities) end)